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

Style/SymbolProc reports incorrect line for offense #2255

Closed
gotrevor opened this issue Sep 17, 2015 · 0 comments
Closed

Style/SymbolProc reports incorrect line for offense #2255

gotrevor opened this issue Sep 17, 2015 · 0 comments

Comments

@gotrevor
Copy link
Contributor

The file:

[~/scratch/b] $ cat r.rb
[{ b: 1 }, { b: nil }].map { |element| element[:b] }
  .reject { |element| element.nil? }

Latest version of rubocop:

[~/scratch/b] $ rubocop -V
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.6-compliant syntax, but you are running 2.1.5.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
0.34.1 (using Parser 2.2.2.6, running on ruby 2.1.5 x86_64-darwin14.0)

Note that the line with the problem is line 2, not line 1, as reported below:

[~/scratch/b] $ rubocop -D r.rb
...
Inspecting 1 file
C

Offenses:

r.rb:1:1: C: Style/SymbolProc: Pass &:nil? as an argument to reject instead of a block.
[{ b: 1 }, { b: nil }].map { |element| element[:b] }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

Similarly, the fixing, though done properly, reports the wrong line as having changed:

[~/scratch/b] $ rubocop -D r.rb -a
...
Inspecting 1 file
C

Offenses:

r.rb:1:1: C: [Corrected] Style/SymbolProc: Pass &:nil? as an argument to reject instead of a block.
[{ b: 1 }, { b: nil }].map { |element| element[:b] }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense corrected
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