-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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/ArgumentsForwarding
enforce anonymous bad autocorrect
#12875
Comments
I have also several patterns where the fixes in 1.66.1 are wrong. The example above is very much like my Block and Lambda case. Note that I was able to indeed use anonymous argument names, contrary to what the "Expected" above reported. Inputclass Brackets
def [](*args, **kwargs)
puts(*args)
puts(**kwargs)
end
def call(*args, **kwargs)
# The fix introduces incorrect parens.
self[*args, **kwargs]
end
end
class Lambda
def foo(*args, **kwargs)
rec = ->(*moreargs, **morekwargs) {
# The fix forgot to rename args and kwargs.
bar(*args, *moreargs, **kwargs, **morekwargs)
}
puts(*args)
puts(**kwargs)
end
end
class Block
def foo(*args, **kwargs)
self.method do
# The fix forgot to rename args and kwargs.
bar(*args, *moreargs, **kwargs, **morekwargs)
end
puts(*args)
puts(**kwargs)
end
end Output (wrong)class Brackets
def [](*, **)
puts(*)
puts(**)
end
def call(*, **)
# The fix introduces incorrect parens.
self[*, **])( end
end
class Lambda
def foo(*, **)
->(*moreargs, **morekwargs) {
# The fix forgot to rename args and kwargs.
bar(*args, *moreargs, **kwargs, **morekwargs)
}
puts(*)
puts(**)
end
end
class Block
def foo(*, **)
self.method do
# The fix forgot to rename args and kwargs.
bar(*args, *moreargs, **kwargs, **morekwargs)
end
puts(*)
puts(**)
end
end Expectedclass Brackets
def [](*, **)
puts(*)
puts(**)
end
def call(*, **)
# The fix introduces incorrect parens.
self[*, **]
end
end
class Lambda
def foo(*, **)
->(*moreargs, **morekwargs) {
# The fix forgot to rename args and kwargs.
bar(*, *moreargs, **, **morekwargs)
}
puts(*)
puts(**)
end
end
class Block
def foo(*, **)
self.method do
# The fix forgot to rename args and kwargs.
bar(*, *moreargs, **, **morekwargs)
end
puts(*)
puts(**)
end
end |
@akimd can you make a new issue for the brackets case? That will require a different solution. |
Sure. I was not sure whether it was preferred to have "fat" issues, or "many" issues :) |
…` when argument is used inside a block.
…` when argument is used inside a block.
The following code:
results in invalid autocorrect output with
Expected behavior
Actual behavior
*args
will no longer be defined.Steps to reproduce the problem
Example code above.
RuboCop version
The text was updated successfully, but these errors were encountered: