Skip to content

Commit

Permalink
Update RuboCop guidelies: prefer alias_method (#10716)
Browse files Browse the repository at this point in the history
**Why**: alias_method has more predictable behavior compared
to alias

changelog: Internal, Source code, Update RuboCop lint rules
  • Loading branch information
zachmargolis authored May 29, 2024
1 parent a93e7dc commit 4de7ec2
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,10 @@ Security/YAMLLoad:
Enabled: true
SafeAutoCorrect: false

Style/Alias:
Enabled: true
EnforcedStyle: prefer_alias_method

Style/AndOr:
Description: Use &&/|| instead of and/or.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
Expand Down
2 changes: 1 addition & 1 deletion app/services/encryption/user_access_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def unlock(encryption_key_arg)
def unlocked?
cek.present?
end
alias built? unlocked?
alias_method :built?, :unlocked?

def encryption_key
Base64.strict_encode64(masked_ciphertext)
Expand Down
2 changes: 1 addition & 1 deletion app/services/proofing/aamva/hmac_secret.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class HmacSecret

attr_reader :client_secret, :server_secret, :psha1

alias secret client_secret
alias_method :secret, :client_secret

def initialize(encoded_client_secret, encoded_server_secret)
@client_secret = Base64.decode64(encoded_client_secret)
Expand Down
2 changes: 1 addition & 1 deletion app/services/x509/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def initialize(raw: nil, norm: nil)
end

delegate :blank?, :present?, :to_s, :to_date, :==, :eql?, to: :raw
alias to_str to_s
alias_method :to_str, :to_s
end
end
4 changes: 2 additions & 2 deletions config/initializers/rack_timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def call_with_excludes(env)
end
end

alias call_without_excludes call
alias call call_with_excludes
alias_method :call_without_excludes, :call
alias_method :call, :call_with_excludes
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/aws/ses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def deliver(mail)
response
end

alias deliver! deliver
alias_method :deliver!, :deliver

private

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/concerns/remember_device_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
include(RememberDeviceConcern)

attr_reader :sp, :raw_session, :request, :current_user
alias :sp_from_sp_session :sp
alias :sp_session :raw_session
alias_method :sp_from_sp_session, :sp
alias_method :sp_session, :raw_session

def initialize(sp, raw_session, request, current_user)
@sp = sp
Expand Down
4 changes: 2 additions & 2 deletions spec/support/features/idv_step_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def complete_idv_steps_with_phone_before_confirmation_step(user = user_with_2fa)
complete_enter_password_step(user)
end

alias complete_idv_steps_before_enter_password_step
complete_idv_steps_with_phone_before_enter_password_step
alias_method :complete_idv_steps_before_enter_password_step,
:complete_idv_steps_with_phone_before_enter_password_step

def complete_idv_steps_with_gpo_before_enter_password_step(user = user_with_2fa)
complete_idv_steps_before_gpo_step(user)
Expand Down

0 comments on commit 4de7ec2

Please sign in to comment.