You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found a couple of examples in rails, a couple of examples in rubocop, a lot of examples in gitlab codebase.
Describe the solution you'd like
So I propose to detect such cases (with Enumerable methods) and correct them. The simplest correction (without dealing with number of arguments for each specific Enumerable method) is to replace something like this
array.map(&method(:do_something))
with something like this
array.map{ |*args| do_something(*args)}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Related link - https://github.com/JuanitoFatas/fast-ruby#normal-way-to-apply-method-vs-method-code
&method(...)
construction can be used in many places, e.x. as a callback, passed with other arguments, like here https://github.com/rails/rails/blob/2ad2425fd3b3a58e937f97b1fa05306c4d3166ae/activesupport/lib/active_support/evented_file_update_checker.rb#L103So we cannot do anything in this case.
But
&method
construction is mostly used (as I have seen) withEnumerable
methods, like https://github.com/rails/rails/blob/2ad2425fd3b3a58e937f97b1fa05306c4d3166ae/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb#L133I have found a couple of examples in
rails
, a couple of examples inrubocop
, a lot of examples ingitlab
codebase.Describe the solution you'd like
So I propose to detect such cases (with
Enumerable
methods) and correct them. The simplest correction (without dealing with number of arguments for each specific Enumerable method) is to replace something like thiswith something like this
The text was updated successfully, but these errors were encountered: