Style/OperatorMethodCall
incorrectly flags module methods
#11107
Labels
Style/OperatorMethodCall
incorrectly flags module methods
#11107
Style/OperatorMethodCall
incorrectly flags cases where the call is from a module or a class method, rather than the instance method that is normally associated with the operator.E.g.
Sequel.-
produces an object that is used for generating an SQL query, and does not perform the operator, whilefoo - bar
calls the instance methodfoo#-
.Expected behavior
This cop should be considered as unsafe for auto-correction, or should ignore non-instance method cases.
Actual behavior
Sequel.-
was autocorrected toSequel -
, which then produced errors on load as the Ruby syntax is interpreted as invalid.Steps to reproduce the problem
Use a module or class method for an operator, and have the corrector modify this to an invalid syntax.
In our case,
Sequel.-(foo, bar)
was converted toSequel -(foo, bar)
which broke the Ruby interpreter when trying to parse that code.RuboCop version
The text was updated successfully, but these errors were encountered: