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

Layout/SpaceBeforeFirstArg doesn't alert when randomly aligning with previous line #7675

Closed
DexterTheDragon opened this issue Jan 27, 2020 · 0 comments · Fixed by #7678
Closed
Labels

Comments

@DexterTheDragon
Copy link

Ran in to a situation in our codebase where Layout/SpaceBeforeFirstArg wasn't reporting a line that should have been reported. After some debugging this seems to be a problem with the aligned_with_something? method thinking that 2 unrelated lines are aligned.


Expected behavior

Expected to receive an offense.

Actual behavior

Received no offense.

Steps to reproduce the problem

$ cat foo.rb
foo = Foo.new(arg, option: true)
foo.long_method_123'asdf'
$ rubocop --only Layout/SpaceBeforeFirstArg foo.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

Changing the file so that 'asdf' does not align with option: true causes the offense to then be reported.

$ cat foo.rb
foo = Foo.new(arg, option: true)
foo.long_method_12'asdf'
$ rubocop --only Layout/SpaceBeforeFirstArg foo.rb
Inspecting 1 file
C

Offenses:

foo.rb:2:19: C: Layout/SpaceBeforeFirstArg: Put one space between the method name and the first argument.
foo.long_method_12'asdf'


1 file inspected, 1 offense detected

RuboCop version

$ rubocop -V
0.79.0 (using Parser 2.7.0.2, running on ruby 2.4.5 x86_64-darwin18)
@koic koic added the bug label Jan 28, 2020
koic added a commit to koic/rubocop that referenced this issue Jan 31, 2020
Fixes rubocop#7675.

This PR fixes a false negative for `Layout/SpaceBeforeFirstArg`
when a vertical argument positions are aligned.
bbatsov pushed a commit that referenced this issue Jan 31, 2020
Fixes #7675.

This PR fixes a false negative for `Layout/SpaceBeforeFirstArg`
when a vertical argument positions are aligned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants