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
Add option to Style/SymbolProc to ignore methods with parameters #9525
Comments
8 tasks
koic
added a commit
to koic/rubocop
that referenced
this issue
Feb 25, 2021
…ymbolProc` ## Summary Fixes rubocop#9525. This PR adds `AllowMethodsWithArguments` option to `Style/SymbolProc`. ### `AllowMethodsWithArguments: false` (default) ```ruby # bad something.do_something(foo) { |o| o.bar } # good something.do_something(foo, &:bar) ``` ### `AllowMethodsWithArguments: true` ```ruby # good something.do_something(foo) { |o| o.bar } ``` If user prefer a style that allows block for method with arguments, the user can set `true` to `AllowMethodsWithArguments`. ## Other Information It may be possible to consider defaulting to `AllowMethodsWithArguments: true`, but at the time of this patch `Style/SymbolProc` cop respect keeping the existing behavior.
bbatsov
pushed a commit
that referenced
this issue
Feb 25, 2021
## Summary Fixes #9525. This PR adds `AllowMethodsWithArguments` option to `Style/SymbolProc`. ### `AllowMethodsWithArguments: false` (default) ```ruby # bad something.do_something(foo) { |o| o.bar } # good something.do_something(foo, &:bar) ``` ### `AllowMethodsWithArguments: true` ```ruby # good something.do_something(foo) { |o| o.bar } ``` If user prefer a style that allows block for method with arguments, the user can set `true` to `AllowMethodsWithArguments`. ## Other Information It may be possible to consider defaulting to `AllowMethodsWithArguments: true`, but at the time of this patch `Style/SymbolProc` cop respect keeping the existing behavior.
This was referenced Mar 6, 2021
Closed
This was referenced Mar 15, 2021
This was referenced Mar 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
No.
Describe the solution you'd like
My application has some code like this:
Rubocop detects offense and suggests change my code to:
But in some scenarios, using symbol as proc isn't the best option for code style because don't follow other block definitions style. I know I have some alternatives like disable
Style/SymbolProc
, add methods to IgnoredMethods option or use# rubocop:disable Style/SymbolProc
for some cases, but I think a option to ignore methods with parameters would be nice.Describe alternatives you've considered
Add option (maybe a EnforcedStyle??) to ignore
Style/SymbolProc
for methods with parameters, or option to only enableStyle/SymbolProc
for methods without parameters.For example:
Additional context
The text was updated successfully, but these errors were encountered: