From ace4ba366aac0ec249ad563534ae600ffe93019d Mon Sep 17 00:00:00 2001 From: Tom Milewski Date: Fri, 14 Dec 2018 11:29:36 -0500 Subject: [PATCH] Fix Rubocop; Min Ruby version 2.2; Update Travis platforms --- .rubocop.yml | 9 +++++++++ .travis.yml | 9 ++++----- Gemfile | 2 +- Rakefile | 1 + lib/omniauth/auth_hash.rb | 5 ++--- lib/omniauth/builder.rb | 1 + lib/omniauth/failure_endpoint.rb | 2 ++ lib/omniauth/form.rb | 1 + lib/omniauth/strategy.rb | 7 ++++++- omniauth.gemspec | 2 +- spec/helper.rb | 2 ++ 11 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 87a1614..85a424c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,12 @@ +AllCops: + TargetRubyVersion: 2.2 + Layout/AccessModifierIndentation: EnforcedStyle: outdent +Layout/AlignHash: + Enabled: false + Layout/DotPosition: EnforcedStyle: trailing @@ -50,6 +56,9 @@ Style/EachWithObject: Style/Encoding: Enabled: false +Style/ExpandPathArguments: + Enabled: false + Style/HashSyntax: EnforcedStyle: hash_rockets diff --git a/.travis.yml b/.travis.yml index 8323fc9..b3a9e20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,11 +9,10 @@ env: language: ruby rvm: - jruby-9000 - - 2.1.10 # EOL Soon - - 2.2.6 - - 2.3.3 - - 2.4.0 - - 2.5.0 + - 2.2.9 + - 2.3.5 + - 2.4.4 + - 2.5.3 - jruby-head - ruby-head matrix: diff --git a/Gemfile b/Gemfile index 53ca189..dbb6c9d 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ group :test do gem 'rack-test' gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18] gem 'rspec', '~> 3.5.0' - gem 'rubocop', '>= 0.47', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24] + gem 'rubocop', '>= 0.58.2', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24] gem 'tins', '~> 1.13.0', :platforms => %i[jruby_18 jruby_19 ruby_19] end diff --git a/Rakefile b/Rakefile index e4daa64..6d5b0f2 100644 --- a/Rakefile +++ b/Rakefile @@ -30,6 +30,7 @@ namespace :perf do def call_app(path = ENV['GET_PATH'] || '/') result = @app.get(path) raise "Did not succeed #{result.body}" unless result.status == 200 + result end end diff --git a/lib/omniauth/auth_hash.rb b/lib/omniauth/auth_hash.rb index 4cbe206..e741bf4 100644 --- a/lib/omniauth/auth_hash.rb +++ b/lib/omniauth/auth_hash.rb @@ -20,9 +20,7 @@ module OmniAuth end def regular_writer(key, value) - if key.to_s == 'info' && value.is_a?(::Hash) && !value.is_a?(InfoHash) - value = InfoHash.new(value) - end + value = InfoHash.new(value) if key.to_s == 'info' && value.is_a?(::Hash) && !value.is_a?(InfoHash) super end @@ -36,6 +34,7 @@ module OmniAuth return "#{first_name} #{last_name}".strip if first_name? || last_name? return nickname if nickname? return email if email? + nil end diff --git a/lib/omniauth/builder.rb b/lib/omniauth/builder.rb index 6cbb6c0..a513571 100644 --- a/lib/omniauth/builder.rb +++ b/lib/omniauth/builder.rb @@ -41,6 +41,7 @@ module OmniAuth def options(options = false) return @options || {} if options == false + @options = options end diff --git a/lib/omniauth/failure_endpoint.rb b/lib/omniauth/failure_endpoint.rb index 0e2e5ef..7c39a34 100644 --- a/lib/omniauth/failure_endpoint.rb +++ b/lib/omniauth/failure_endpoint.rb @@ -33,11 +33,13 @@ module OmniAuth def strategy_name_query_param return '' unless env['omniauth.error.strategy'] + "&strategy=#{env['omniauth.error.strategy'].name}" end def origin_query_param return '' unless env['omniauth.origin'] + "&origin=#{Rack::Utils.escape(env['omniauth.origin'])}" end end diff --git a/lib/omniauth/form.rb b/lib/omniauth/form.rb index fecc636..abd0b43 100644 --- a/lib/omniauth/form.rb +++ b/lib/omniauth/form.rb @@ -82,6 +82,7 @@ module OmniAuth def footer return self if @footer + @html << "\n" unless @with_custom_button @html << <<-HTML diff --git a/lib/omniauth/strategy.rb b/lib/omniauth/strategy.rb index 3627337..ce8b348 100644 --- a/lib/omniauth/strategy.rb +++ b/lib/omniauth/strategy.rb @@ -140,6 +140,7 @@ module OmniAuth self.class.args.each do |arg| break if args.empty? + options[arg] = args.shift end @@ -187,6 +188,7 @@ module OmniAuth return request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym) return callback_call if on_callback_path? return other_phase if respond_to?(:other_phase) + @app.call(env) end @@ -268,6 +270,7 @@ module OmniAuth def mock_call!(*) return mock_request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym) return mock_callback_call if on_callback_path? + call_app! end @@ -361,6 +364,7 @@ module OmniAuth def skip_info? return false unless options.skip_info? return true unless options.skip_info.respond_to?(:call) + options.skip_info.call(uid) end @@ -377,6 +381,7 @@ module OmniAuth if options[kind].respond_to?(:call) result = options[kind].call(env) return nil unless result.is_a?(String) + result else options[kind] @@ -401,7 +406,7 @@ module OmniAuth options[:setup_path] || "#{path_prefix}/#{name}/setup" end - CURRENT_PATH_REGEX = %r{/$} + CURRENT_PATH_REGEX = %r{/$}.freeze EMPTY_STRING = ''.freeze def current_path @current_path ||= request.path_info.downcase.sub(CURRENT_PATH_REGEX, EMPTY_STRING) diff --git a/omniauth.gemspec b/omniauth.gemspec index 176e270..d26d412 100644 --- a/omniauth.gemspec +++ b/omniauth.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.name = 'omniauth' spec.require_paths = %w[lib] spec.required_rubygems_version = '>= 1.3.5' - spec.required_ruby_version = '>= 2.1.9' + spec.required_ruby_version = '>= 2.2' spec.summary = spec.description spec.version = OmniAuth::VERSION end diff --git a/spec/helper.rb b/spec/helper.rb index aa726a3..46e5815 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -48,6 +48,7 @@ class ExampleStrategy @fail = fail!(options[:failure]) if options[:failure] @last_env = env return @fail if @fail + raise('Request Phase') end @@ -56,6 +57,7 @@ class ExampleStrategy @fail = fail!(options[:failure]) if options[:failure] @last_env = env return @fail if @fail + raise('Callback Phase') end end