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
Here, if the resource method is called with an argument and foo is falsey, opts is not being replaced or "shadowed" in this method.
Expected behavior
Should pass.
Actual behavior
rubocop test.rb
Inspecting 1 file
W
Offenses:
test.rb:1:14: W: Lint/ShadowedArgument: Argument opts was shadowed by a local variable before it was used.
def resource(opts = nil)
^^^^^^^^^^
1 file inspected, 1 offense detected
Steps to reproduce the problem
See example above.
RuboCop version
0.52.1 (using Parser 2.4.0.2, running on ruby 2.3.1 x86_64-darwin14)
The text was updated successfully, but these errors were encountered:
I confirmed the report, including the fact that both of those conditional lines are required to trigger the offense (neither one is sufficient). This implies the cop tries to avoid false reports when the shadowing is conditional, but this example method is more complicated than it can currently handle.
…ositive
`Lint/ShadowedArgument` doesn't handle the case of shorthand
assignments and treats them as not using their arguments.
This change adds an additional check for shorthand assignments.
The ShadowedArgument cop is triggering where the variable may not be being modified at all, the smallest reproducable example I can get is:
Here, if the
resource
method is called with an argument andfoo
is falsey, opts is not being replaced or "shadowed" in this method.Expected behavior
Should pass.
Actual behavior
Steps to reproduce the problem
See example above.
RuboCop version
0.52.1 (using Parser 2.4.0.2, running on ruby 2.3.1 x86_64-darwin14)
The text was updated successfully, but these errors were encountered: