Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ Performance/Squeeze:
Performance/StartWith:
Enabled: true

Performance/StringBytesize:
Enabled: true

Performance/StringIdentifierArgument:
Enabled: true

Expand Down Expand Up @@ -1050,6 +1053,12 @@ Rails/WhereRange:
RSpec/LeakyConstantDeclaration:
Enabled: true

RSpec/MissingExpectationTargetMethod:
Enabled: true

RSpec/RedundantPredicateMatcher:
Enabled: true

Security/Eval:
Enabled: true

Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
41 changes: 17 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion app/jobs/account_creation_threat_metrix_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions config/initializers/strong_migrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions lib/linters/analytics_event_name_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/linters/errors_add_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/linters/image_size_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/linters/localized_validation_message_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/linters/mail_later_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/linters/redirect_back_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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|
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/linters/url_options_linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions spec/models/backup_code_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,19 @@ 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
bc = BackupCodeConfiguration.new
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
Expand Down