diff --git a/.rubocop.yml b/.rubocop.yml index 00d3129d03b..e4e614283cd 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -803,6 +803,9 @@ Performance/Squeeze: Performance/StartWith: Enabled: true +Performance/StringBytesize: + Enabled: true + Performance/StringIdentifierArgument: Enabled: true @@ -1050,6 +1053,12 @@ Rails/WhereRange: RSpec/LeakyConstantDeclaration: Enabled: true +RSpec/MissingExpectationTargetMethod: + Enabled: true + +RSpec/RedundantPredicateMatcher: + Enabled: true + Security/Eval: Enabled: true diff --git a/Gemfile b/Gemfile index 8c3c853be75..a78cabedce0 100644 --- a/Gemfile +++ b/Gemfile @@ -118,10 +118,10 @@ group :development, :test do gem 'psych' gem 'rspec', '~> 3.13.0' gem 'rspec-rails', '~> 7.0' - gem 'rubocop', '~> 1.62.0', require: false - gem 'rubocop-performance', '~> 1.20.2', require: false - gem 'rubocop-rails', '>= 2.26.2', require: false - gem 'rubocop-rspec', require: false + gem 'rubocop', '~> 1.69.1', require: false + gem 'rubocop-performance', '~> 1.23.0', require: false + gem 'rubocop-rails', '~> 2.27.0', require: false + gem 'rubocop-rspec', '~> 3.2.0', require: false gem 'sqlite3', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index e27bf114bc0..385f74234d7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -382,7 +382,7 @@ GEM jmespath (1.6.2) jsbundling-rails (1.1.2) railties (>= 6.0.0) - json (2.7.2) + json (2.9.0) jwe (0.4.0) jwt (2.7.1) knapsack (4.0.0) @@ -460,7 +460,7 @@ GEM openssl-signature_algorithm (1.2.1) openssl (> 2.0, < 3.1) orm_adapter (0.5.0) - parallel (1.25.1) + parallel (1.26.3) parser (3.3.4.2) ast (~> 2.4.1) racc @@ -571,7 +571,7 @@ GEM redis-client (>= 0.22.0) redis-client (0.22.2) connection_pool - regexp_parser (2.9.2) + regexp_parser (2.9.3) reline (0.5.9) io-console (~> 0.5) request_store (1.5.1) @@ -612,35 +612,28 @@ GEM rspec-support (3.13.1) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.62.1) + rubocop (1.69.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.36.2) parser (>= 3.3.1.0) - rubocop-capybara (2.19.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.24.0) - rubocop (~> 1.33) - rubocop-performance (1.20.2) + rubocop-performance (1.23.0) rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.26.2) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.27.0) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.52.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (2.24.1) - rubocop (~> 1.33) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop-rspec (3.2.0) + rubocop (~> 1.61) ruby-progressbar (1.13.0) ruby-saml (1.17.0) nokogiri (>= 1.13.10) @@ -851,10 +844,10 @@ DEPENDENCIES rspec-rails (~> 7.0) rspec-retry rspec_junit_formatter - rubocop (~> 1.62.0) - rubocop-performance (~> 1.20.2) - rubocop-rails (>= 2.26.2) - rubocop-rspec + rubocop (~> 1.69.1) + rubocop-performance (~> 1.23.0) + rubocop-rails (~> 2.27.0) + rubocop-rspec (~> 3.2.0) ruby-progressbar ruby-saml safe_target_blank (>= 1.0.2) diff --git a/app/jobs/account_creation_threat_metrix_job.rb b/app/jobs/account_creation_threat_metrix_job.rb index 4d1dd53fe32..aa5b439e01d 100644 --- a/app/jobs/account_creation_threat_metrix_job.rb +++ b/app/jobs/account_creation_threat_metrix_job.rb @@ -7,7 +7,6 @@ def perform( request_ip: nil, email: nil ) - device_profiling_result = AccountCreation::DeviceProfiling.new.proof( request_ip: request_ip, threatmetrix_session_id: threatmetrix_session_id, diff --git a/config/initializers/strong_migrations.rb b/config/initializers/strong_migrations.rb index b7e3d6c5a8a..8320ec2edb2 100644 --- a/config/initializers/strong_migrations.rb +++ b/config/initializers/strong_migrations.rb @@ -15,13 +15,13 @@ class IdpStrongMigrations StrongMigrations.add_check do |method, (table, column, type, _options)| is_excluded = IdpStrongMigrations::EXCLUDED_COLUMNS.include?([table, column]) if !is_excluded && method == :add_column && column.to_s.ends_with?('_id') && type == :integer - stop! """ + stop! " Columns referencing another table should use :bigint instead of integer. add_column #{table.inspect}, #{column.inspect}, :bigint OR t.bigint #{column.inspect} - """ + " end end diff --git a/lib/linters/analytics_event_name_linter.rb b/lib/linters/analytics_event_name_linter.rb index eed859cd3d4..bd4d8566d0b 100644 --- a/lib/linters/analytics_event_name_linter.rb +++ b/lib/linters/analytics_event_name_linter.rb @@ -3,7 +3,7 @@ module RuboCop module Cop module IdentityIdp - class AnalyticsEventNameLinter < RuboCop::Cop::Cop + class AnalyticsEventNameLinter < RuboCop::Cop::Base RESTRICT_ON_SEND = [:track_event].freeze # DO NOT ADD TO THIS LIST OR YOU WILL MAKE A KITTEN CRY! @@ -45,7 +45,6 @@ def on_send(node) return if LEGACY_EVENT_NAMES.include?(Digest::MD5.hexdigest(actual_name.to_s)[0...7]) add_offense( first_argument, - location: :expression, message: "Event name must match the method name, expected `:#{expected_name}`", ) end diff --git a/lib/linters/errors_add_linter.rb b/lib/linters/errors_add_linter.rb index 3c36112fe4d..72447e0af80 100644 --- a/lib/linters/errors_add_linter.rb +++ b/lib/linters/errors_add_linter.rb @@ -14,7 +14,7 @@ module IdentityIdp # #good # errors.add(:iss, 'invalid issuer', type: :invalid_issuer) # - class ErrorsAddLinter < RuboCop::Cop::Cop + class ErrorsAddLinter < RuboCop::Cop::Base MSG = 'Please set a unique key for this error' RESTRICT_ON_SEND = [:add].freeze @@ -29,7 +29,7 @@ def on_send(node) return if type && type.type == :sym options = type if type && type.type == :hash return if options && options.type == :hash && options.keys.map(&:value).include?(:type) - add_offense(node, location: :expression) + add_offense(node) end end end diff --git a/lib/linters/image_size_linter.rb b/lib/linters/image_size_linter.rb index b5f37076489..680e3357629 100644 --- a/lib/linters/image_size_linter.rb +++ b/lib/linters/image_size_linter.rb @@ -15,13 +15,13 @@ module IdentityIdp # # good # image_tag 'example.svg', width: 10, height: 20 # - class ImageSizeLinter < RuboCop::Cop::Cop + class ImageSizeLinter < RuboCop::Cop::Base MSG = 'Assign width and height to images' RESTRICT_ON_SEND = [:image_tag].freeze def on_send(node) - add_offense(node, location: :expression) if !valid?(node) + add_offense(node) if !valid?(node) end private diff --git a/lib/linters/localized_validation_message_linter.rb b/lib/linters/localized_validation_message_linter.rb index 04f791d07fd..54e56dd483f 100644 --- a/lib/linters/localized_validation_message_linter.rb +++ b/lib/linters/localized_validation_message_linter.rb @@ -3,7 +3,7 @@ module RuboCop module Cop module IdentityIdp - class LocalizedValidationMessageLinter < RuboCop::Cop::Cop + class LocalizedValidationMessageLinter < RuboCop::Cop::Base MSG = 'Use proc when translating validation message' RESTRICT_ON_SEND = [ @@ -33,7 +33,7 @@ class LocalizedValidationMessageLinter < RuboCop::Cop::Cop def on_send(node) if translated_validation_message?(node) || translated_validation_helper_message?(node) - add_offense(node, location: :expression) + add_offense(node) end end end diff --git a/lib/linters/mail_later_linter.rb b/lib/linters/mail_later_linter.rb index cb70b536f08..12c891d5df3 100644 --- a/lib/linters/mail_later_linter.rb +++ b/lib/linters/mail_later_linter.rb @@ -16,7 +16,7 @@ module IdentityIdp # UserMailer.with(params).signup_with_your_email(user, email).deliver_now_or_later # ReportMailer.report_mail(data).deliver_now # - class MailLaterLinter < RuboCop::Cop::Cop + class MailLaterLinter < RuboCop::Cop::Base MSG = 'Please send mail using deliver_now_or_later instead' RESTRICT_ON_SEND = [:deliver_now, :deliver_later].freeze @@ -33,7 +33,7 @@ def on_send(node) receiver.receiver.const_name end - add_offense(node, location: :expression) if mailer_name == 'UserMailer' + add_offense(node) if mailer_name == 'UserMailer' end end end diff --git a/lib/linters/redirect_back_linter.rb b/lib/linters/redirect_back_linter.rb index cc756ebd54d..ad2fba37d4c 100644 --- a/lib/linters/redirect_back_linter.rb +++ b/lib/linters/redirect_back_linter.rb @@ -16,7 +16,7 @@ module IdentityIdp # #good # redirect_back fallback_location: '/', allow_other_host: false # - class RedirectBackLinter < RuboCop::Cop::Cop + class RedirectBackLinter < RuboCop::Cop::Base MSG = 'Please set a fallback_location and the allow_other_host parameter to false' RESTRICT_ON_SEND = [:redirect_back].freeze @@ -26,7 +26,7 @@ class RedirectBackLinter < RuboCop::Cop::Cop PATTERN def on_send(node) - add_offense(node, location: :expression) && return if node.arguments.empty? + add_offense(node) && return if node.arguments.empty? sets_fallback_location, sets_allow_other_host_false = false redirect_back_matcher(node) do |arguments| @@ -45,7 +45,7 @@ def on_send(node) return if sets_fallback_location && sets_allow_other_host_false - add_offense(node, location: :expression) + add_offense(node) end end end diff --git a/lib/linters/url_options_linter.rb b/lib/linters/url_options_linter.rb index 0c2303bdab7..3a2a8ba038a 100644 --- a/lib/linters/url_options_linter.rb +++ b/lib/linters/url_options_linter.rb @@ -33,7 +33,7 @@ module IdentityIdp # end # end # - class UrlOptionsLinter < RuboCop::Cop::Cop + class UrlOptionsLinter < RuboCop::Cop::Base MSG = 'Please define url_options when including Rails.application.routes.url_helpers' RESTRICT_ON_SEND = [:include].freeze @@ -47,7 +47,7 @@ def on_send(node) return unless includes_url_helpers?(node) return if defines_url_options?(node) - add_offense(node, location: :expression) + add_offense(node) end private diff --git a/spec/models/backup_code_configuration_spec.rb b/spec/models/backup_code_configuration_spec.rb index 05114d8473d..0558f99deef 100644 --- a/spec/models/backup_code_configuration_spec.rb +++ b/spec/models/backup_code_configuration_spec.rb @@ -140,8 +140,9 @@ def save_and_find(find:, save: 'just-some-not-null-value') bc = BackupCodeConfiguration.new set = BackupCodeConfiguration.selection_presenters([bc]) - expect(set.first). - instance_of? TwoFactorAuthentication::SignInBackupCodeSelectionPresenter.class + expect(set.first).to be_instance_of( + TwoFactorAuthentication::SignInBackupCodeSelectionPresenter, + ) end it 'returns only one selection presenter if multiple backup code configurations' do @@ -149,8 +150,9 @@ def save_and_find(find:, save: 'just-some-not-null-value') bc2 = BackupCodeConfiguration.new set = BackupCodeConfiguration.selection_presenters([bc, bc2]) - expect(set.first). - instance_of? TwoFactorAuthentication::SignInBackupCodeSelectionPresenter.class + expect(set.first).to be_instance_of( + TwoFactorAuthentication::SignInBackupCodeSelectionPresenter, + ) expect(set.size).to eq(1) end end