Add and apply Style/SuperArguments rubocop rule

This rule was added in rubocop 1.64.0.

For clarity, in order to make it obvious that we're modifying the object
we received, we're excluding the Ahoy initializer, whose code was copied
from the Ahoy documentation.

We're also changing the `Types::BaseObject` class so we don't use a
variable with the same name as the parameter and we don't get a false
positive for this rule.
This commit is contained in:
Javi Martín
2024-07-02 18:22:38 +02:00
committed by taitus
parent 46dc4a3163
commit 16315e14d2
5 changed files with 10 additions and 8 deletions

View File

@@ -796,6 +796,11 @@ Style/StringLiterals:
Style/StringLiteralsInInterpolation: Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes EnforcedStyle: double_quotes
Style/SuperArguments:
Enabled: true
Exclude:
- "config/initializers/ahoy.rb"
Style/SymbolProc: Style/SymbolProc:
Enabled: true Enabled: true
AllowedMethods: AllowedMethods:

View File

@@ -19,7 +19,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
if resource.registering_with_oauth if resource.registering_with_oauth
finish_signup_path finish_signup_path
else else
super(resource) super
end end
end end

View File

@@ -1,7 +1,7 @@
module Types module Types
class BaseObject < GraphQL::Schema::Object class BaseObject < GraphQL::Schema::Object
def self.field(*args, **kwargs, &) def self.field(*args, **kwargs, &)
super(*args, **kwargs, &) super
# The old api contained non-camelized fields # The old api contained non-camelized fields
# We want to support these for now, but throw a deprecation warning # We want to support these for now, but throw a deprecation warning
@@ -13,8 +13,7 @@ module Types
if field_name.to_s.include?("_") if field_name.to_s.include?("_")
reason = "Snake case fields are deprecated. Please use #{field_name.to_s.camelize(:lower)}." reason = "Snake case fields are deprecated. Please use #{field_name.to_s.camelize(:lower)}."
kwargs = kwargs.merge({ camelize: false, deprecation_reason: reason }) super(*args, **kwargs.merge({ camelize: false, deprecation_reason: reason }), &)
super(*args, **kwargs, &)
end end
# Make sure associations only return public records # Make sure associations only return public records

View File

@@ -27,7 +27,7 @@ module ActsAsParanoidAliases
def restore(opts = {}) def restore(opts = {})
return false unless hidden? return false unless hidden?
super(opts) super
update_attribute(:confirmed_hide_at, nil) if self.class.column_names.include? "confirmed_hide_at" update_attribute(:confirmed_hide_at, nil) if self.class.column_names.include? "confirmed_hide_at"
after_restore after_restore
end end

View File

@@ -5,8 +5,6 @@ class DeviseMailer < Devise::Mailer
protected protected
def devise_mail(record, action, opts = {}) def devise_mail(record, action, opts = {})
I18n.with_locale record.locale do I18n.with_locale(record.locale) { super }
super(record, action, opts)
end
end end
end end