Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cop idea: RedundantSuperArguments #12309

Closed
Earlopain opened this issue Oct 25, 2023 · 0 comments
Closed

Cop idea: RedundantSuperArguments #12309

Earlopain opened this issue Oct 25, 2023 · 0 comments

Comments

@Earlopain
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Consider the following code:

def input(attribute_name, options = {}, &)
  value = @options[attribute_name]
  options[:value] = value
  super(attribute_name, options, &)
end

Ruby delegates all arguments to super if called without anything. Rubocop should detect this case and autocorrect to a plain super call.

Describe the solution you'd like

Autocorrect to the following if the arguments to super matches the method signature:

def input(attribute_name, options = {}, &)
  value = @options[attribute_name]
  options[:value] = value
  super
end

Additional context

Calling super with parents like super() has special meaning and will not pass any arguments to the inherited method. There should be no autocorrect in that case.

Earlopain added a commit to Earlopain/rubocop that referenced this issue Dec 1, 2023
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 22, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 22, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 22, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 22, 2024
Earlopain added a commit to Earlopain/rubocop that referenced this issue May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant