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/Lambda with unused argument bug #6956
Labels
Comments
koic
added a commit
to koic/rubocop
that referenced
this issue
Apr 23, 2019
…and `Lint/UnusedBlockArgument` Fixes rubocop#6956. This PR prevents auto-correct confliction of `Lint/Lambda` and `Lint/UnusedBlockArgument`. The following is the reproduction procedure. ```ruby # example.rb c = -> event do puts 'Hello world' end ``` ```console % rubocop example.rb -a --only Style/Lambda,Lint/UnusedBlockArgument ``` ## Before A reserved word `lambda` is broken. ```diff % git diff diff --git a/example.rb b/example.rb index 3445c6f..b8e24f4 100644 --- a/example.rb +++ b/example.rb @@ -1,3 +1,3 @@ -c = -> event do +c = lambda_ do |_event| puts 'Hello world' end ``` ## After It will be a valid code. ```diff % git diff diff --git a/example.rb b/example.rb index 3445c6f..9c22b37 100644 --- a/example.rb +++ b/example.rb @@ -1,3 +1,3 @@ -c = -> event do +c = lambda do |_event| puts 'Hello world' end ```
Merged
8 tasks
Thanks for your feedback. I opened a PR #6958. |
bbatsov
pushed a commit
that referenced
this issue
Apr 23, 2019
…nt/UnusedBlockArgument` Fixes #6956. This PR prevents auto-correct confliction of `Lint/Lambda` and `Lint/UnusedBlockArgument`. The following is the reproduction procedure. ```ruby # example.rb c = -> event do puts 'Hello world' end ``` ```console % rubocop example.rb -a --only Style/Lambda,Lint/UnusedBlockArgument ``` ## Before A reserved word `lambda` is broken. ```diff % git diff diff --git a/example.rb b/example.rb index 3445c6f..b8e24f4 100644 --- a/example.rb +++ b/example.rb @@ -1,3 +1,3 @@ -c = -> event do +c = lambda_ do |_event| puts 'Hello world' end ``` ## After It will be a valid code. ```diff % git diff diff --git a/example.rb b/example.rb index 3445c6f..9c22b37 100644 --- a/example.rb +++ b/example.rb @@ -1,3 +1,3 @@ -c = -> event do +c = lambda do |_event| puts 'Hello world' end ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
When using
--auto-correct
with a "stabby lambda" function where arguments are unused results in syntactically incorrect code:Is autocorrected to the following:
Which returns the following error when executed:
Expected behavior
Should not inject
_
arguments into lambda e.g.lambda(_)
this is not allowed in Ruby. The result should be the following code:Actual behavior
Inserts
_
as an argument to lambda function e.g.lambda(_)
Steps to reproduce the problem
rubocop --auto-correct
on the file.RuboCop version
Ruby version
The text was updated successfully, but these errors were encountered: