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

Style/MethodCallWithoutArgsParentheses should have an IgnoredMethods setting #4753

Closed
mvz opened this issue Sep 17, 2017 · 5 comments
Closed

Comments

@mvz
Copy link
Contributor

mvz commented Sep 17, 2017

The Style/MethodCallWithArgsParentheses cop allows some methods to be ignored using the IgnoredMethods setting. Oddly, the Style/MethodCallWithoutArgsParentheses cop does not.


Expected behavior

Given the following code

s()

If I add the following to .rubocop.yml:

Style/MethodCallWithoutArgsParentheses:
  IgnoredMethods: ['s']

I expect RuboCop not to report an offense for Style/MethodCallWithoutArgsParentheses.

Actual behavior

RuboCop complains about the parameter and reports an offense for Style/MethodCallWithoutArgsParentheses:

Warning: unrecognized parameter Style/MethodCallWithoutArgsParentheses:IgnoredMethods found in /home/matijs/Projects/ripper_ruby_parser/.rubocop.yml
Inspecting 1 file
C

Offenses:

foo.rb:1:2: C: Do not use parentheses for method calls with no arguments.
s()
 ^

Steps to reproduce the problem

Create a file foo.rb with:

s()

And a file .rubocop.yml with:

Style/MethodCallWithoutArgsParentheses:
  IgnoredMethods: ['s']

Run RuboCop:

rubocop foo.rb

RuboCop version

$ rubocop -V
0.50.0 (using Parser 2.4.0.0, running on ruby 2.4.1 x86_64-linux)
@Drenmi
Copy link
Collaborator

Drenmi commented Sep 17, 2017

Good point. 🙂 It's also a bit unfortunate the author went with IgnoredMethods, because I've been trying to find a good abstraction for Whitelist/Blacklist. 😅

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 18, 2017

Good point. 🙂 It's also a bit unfortunate the author went with IgnoredMethods, because I've been trying to find a good abstraction for Whitelist/Blacklist. 😅

It's not like we can't change this. ;-)

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 18, 2017

There are unfortunately a ton of inconsistencies from the early days of the project.

@Drenmi
Copy link
Collaborator

Drenmi commented Sep 18, 2017

Indeed. Another one I've noticed is the varied use of Unnecessary, Useless, Unneeded. (Probably influenced on how frustrated the author was at the offense at the time of writing. 😛)

@mvz
Copy link
Contributor Author

mvz commented Apr 17, 2018

Works like a charm, thanks!

mvz added a commit to mvz/ripper_ruby_parser that referenced this issue Apr 17, 2018
RuboCop 0.55.0 supports ignoring this cop only for specific methods.

See rubocop/rubocop#4753 for details.

[ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants