diff --git a/.rubocop.yml b/.rubocop.yml index ce1dc552..fa6928d0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ inherit_from: .rubocop_todo.yml AllCops: Exclude: - 'lib/generators/sorcery/templates/**/*' - TargetRubyVersion: 2.2 + TargetRubyVersion: 2.6 # See: https://github.com/rubocop-hq/rubocop/issues/3344 Style/DoubleNegation: @@ -21,7 +21,7 @@ Metrics/BlockLength: Exclude: - 'lib/**/*' - 'spec/**/*' -Metrics/LineLength: +Layout/LineLength: Exclude: - 'lib/**/*' - 'spec/**/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4d8c565f..67dfc312 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,7 +1,145 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-11-01 18:13:47 -0700 using RuboCop version 0.59.2. +# on 2019-12-18 16:18:24 -0800 using RuboCop version 0.78.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'sorcery.gemspec' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'lib/sorcery/providers/line.rb' + +# Offense count: 83 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Enabled: false + +# Offense count: 2 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'spec/rails_app/app/controllers/sorcery_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/NonDeterministicRequireOrder: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Lint/RedundantCopDisableDirective: + Exclude: + - 'lib/sorcery/controller.rb' + - 'lib/sorcery/model.rb' + - 'spec/rails_app/config/application.rb' + - 'spec/shared_examples/user_shared_examples.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Lint/SendWithMixinArgument: + Exclude: + - 'lib/sorcery.rb' + - 'lib/sorcery/engine.rb' + - 'lib/sorcery/test_helpers/internal/rails.rb' + +# Offense count: 4 +# Configuration parameters: AllowComments. +Lint/SuppressedException: + Exclude: + - 'lib/sorcery/controller.rb' + - 'lib/sorcery/model.rb' + - 'spec/rails_app/config/application.rb' + - 'spec/shared_examples/user_shared_examples.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'spec/shared_examples/user_shared_examples.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: annotated, template, unannotated +Style/FormatStringToken: + Exclude: + - 'lib/generators/sorcery/install_generator.rb' + +# Offense count: 121 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 3 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'lib/sorcery/controller/submodules/brute_force_protection.rb' + - 'lib/sorcery/controller/submodules/http_basic_auth.rb' + - 'lib/sorcery/controller/submodules/remember_me.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Exclude: + - 'lib/sorcery/adapters/active_record_adapter.rb' + - 'lib/sorcery/test_helpers/rails/integration.rb' + +# Offense count: 49 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'lib/sorcery/controller.rb' + - 'lib/sorcery/model.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/sorcery/controller/config.rb' + - 'lib/sorcery/controller/submodules/brute_force_protection.rb' + - 'lib/sorcery/controller/submodules/remember_me.rb' + - 'lib/sorcery/model.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'spec/controllers/controller_oauth2_spec.rb' + - 'spec/sorcery_crypto_providers_spec.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/UnpackFirst: + Exclude: + - 'lib/sorcery/crypto_providers/aes256.rb' + - 'spec/sorcery_crypto_providers_spec.rb' diff --git a/.travis.yml b/.travis.yml index 1ac53a5c..95f9692f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,7 @@ language: ruby rvm: - - 2.2.9 - - 2.3.6 - - 2.4.3 - - 2.5.0 + - 2.4.9 + - 2.5.7 - 2.6.5 gemfile: diff --git a/lib/sorcery/engine.rb b/lib/sorcery/engine.rb index fd3bff16..ff0b7be5 100644 --- a/lib/sorcery/engine.rb +++ b/lib/sorcery/engine.rb @@ -9,11 +9,11 @@ class Engine < Rails::Engine initializer 'extend Controller with sorcery' do # TODO: Should this include a modified version of the helper methods? - if defined?(ActionController::API) + ActiveSupport.on_load(:action_controller_api) do ActionController::API.send(:include, Sorcery::Controller) end - if defined?(ActionController::Base) + ActiveSupport.on_load(:action_controller_base) do ActionController::Base.send(:include, Sorcery::Controller) ActionController::Base.helper_method :current_user ActionController::Base.helper_method :logged_in? diff --git a/sorcery.gemspec b/sorcery.gemspec index a62c40b0..3ec42c14 100644 --- a/sorcery.gemspec +++ b/sorcery.gemspec @@ -19,20 +19,20 @@ Gem::Specification.new do |s| ] # TODO: Cleanup formatting. - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength s.description = 'Provides common authentication needs such as signing in/out, activating by email and resetting password.' s.summary = 'Magical authentication for Rails applications' s.homepage = 'https://github.com/Sorcery/sorcery' s.post_install_message = "As of version 1.0 oauth/oauth2 won't be automatically bundled so you may need to add those dependencies to your Gemfile.\n" s.post_install_message += 'You may need oauth2 if you use external providers such as any of these: https://github.com/Sorcery/sorcery/tree/master/lib/sorcery/providers' - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) s.require_paths = ['lib'] s.licenses = ['MIT'] - s.required_ruby_version = '>= 2.2.9' + s.required_ruby_version = '>= 2.4.9' s.add_dependency 'bcrypt', '~> 3.1' s.add_dependency 'oauth', '~> 0.4', '>= 0.4.4'