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

inherit_mode under Naming/MethodParameterName cop is not merging AllowedNames #8584

Closed
bbugh opened this issue Aug 25, 2020 · 2 comments
Closed

Comments

@bbugh
Copy link

bbugh commented Aug 25, 2020

When using inherit_mode under Naming/MethodParameterName, it doesn't seem to work. inherit_mode at the root level works as expected.


Expected behavior

Based on the documentation, this seems like AllowedNames should be merged, and include the original defaults.

Naming/MethodParameterName:
  inherit_mode:
    merge:
      - AllowedNames
  AllowedNames:
    - t

Setting this at the root level works - but then it affects all of the cops.

inherit_mode:
  merge:
    - AllowedNames
    
Naming/MethodParameterName:
  AllowedNames:
    - t

Actual behavior

inherit_mode under the Naming/MethodParameterName cop still overwrites the existing AllowedNames

Steps to reproduce the problem

With the latest Rubocop:

Naming/MethodParameterName:
  inherit_mode:
    merge:
      - AllowedNames
  AllowedNames:
    - t
# This results in an error, but should not
def do_something(id: 'this should work')
end

Result:

Naming/MethodParameterName: Method parameter must be at least 3 characters long.
  def do_something(id: 'this should work')
                   ^^

RuboCop version

Tested with the latest rubocop 0.89.1:

$ [bundle exec] rubocop -V
0.89.1 (using Parser 2.7.1.4, rubocop-ast 0.3.0, running on ruby 2.6.5 x86_64-darwin18)

And the current version we're using (with Naming/UncommunicativeMethodParamName):

$ [bundle exec] rubocop -V
0.76.0 (using Parser 2.6.5.0, running on ruby 2.6.5 x86_64-darwin18)
@bbugh
Copy link
Author

bbugh commented May 26, 2021

@bbatsov Hi 👋 sorry to tag you, I'm sure you're very busy. I don't know who else to ping. I didn't see anything in the CoC or Contributing guidelines about who manages the issues and can be contacted.

This problem bit me at another company since the first report. I am happy to PR this if someone can confirm that it's a bug and not expected to behavior.

@jonas054
Copy link
Collaborator

jonas054 commented Jul 8, 2022

A fix for this problem was made in #9952 and released in rubocop 1.19.0.

@jonas054 jonas054 closed this as completed Jul 8, 2022
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

2 participants