Skip to content
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

False positive in Style/TrailingUnderscoreVariable cop #3380

Closed
Drenmi opened this issue Aug 8, 2016 · 0 comments
Closed

False positive in Style/TrailingUnderscoreVariable cop #3380

Drenmi opened this issue Aug 8, 2016 · 0 comments

Comments

@Drenmi
Copy link
Collaborator

Drenmi commented Aug 8, 2016

When this cop encounters destructuring code like:

_, *rest, _ = *arr

it incorrectly marks the trailing _ as an offense, but this is needed to indicate how many tail elements we want to drop when destructuring.


Expected behavior

RuboCop does not register an offense.

Actual behavior

C: Style/TrailingUnderscoreVariable: Do not use trailing _s in parallel assignment. Prefer _, *rest, = *arr.
_, *rest, _ = *arr
          ^^

Steps to reproduce the problem

Run bundle exec rubocop --only Style/TrailingUnderscoreVariable, on:

_, *rest, _ = *arr

RuboCop version

Include the output of rubocop -V:

$ rubocop -V
0.42.0 (using Parser 2.3.1.2, running on ruby 2.3.0 x86_64-darwin15)
Drenmi added a commit to Drenmi/rubocop that referenced this issue Aug 8, 2016
…iable` cop

This cop would report offenses on destructuring code like:

```
_, *rest, _ = *arr
```

This change fixes that.
@bbatsov bbatsov closed this as completed in 78de463 Aug 9, 2016
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
…iable` cop (rubocop#3381)

This cop would report offenses on destructuring code like:

```
_, *rest, _ = *arr
```

This change fixes that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant