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

EnforcedStyleAlignWith: start_of_line behaves strangely #6382

Closed
gerrywastaken opened this issue Oct 12, 2018 · 1 comment
Closed

EnforcedStyleAlignWith: start_of_line behaves strangely #6382

gerrywastaken opened this issue Oct 12, 2018 · 1 comment
Labels

Comments

@gerrywastaken
Copy link
Contributor

See the third good example under the start_of_line section in the docs:
https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Layout/EndAlignment

Copied here for posterity:

variable =
  if true
  end

Expected behavior

This passes

variable =
  if true
    :foo
  else
    :bar
  end

Actual behavior

It errors with:

bleh.rb:5:1: C: Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.
    :foo
^^^^
bleh.rb:6:3: C: Layout/ElseAlignment: Align else with variable.
  else
  ^^^^

but this passes:

variable =
  if true
  :foo
else
  :bar
  end

Steps to reproduce the problem

with the following in your config:

Layout/EndAlignment:
  EnforcedStyleAlignWith: start_of_line

run rubocop on a file containing this:

variable =
  if true
    :foo
  else
    :bar
  end

RuboCop version

$ [bundle exec] bundle exec rubocop -V
0.59.2 (using Parser 2.5.1.2, running on ruby 2.5.1 x86_64-darwin16))
@Drenmi Drenmi added the bug label Oct 12, 2018
dischorde added a commit to dischorde/rubocop that referenced this issue Jan 24, 2019
…nment` set to start_of_line.

Add spec for if/else in assignment on newline with end alignment set to start of line

Check line_break_before_keyword? for both variable & start_of_line

Update changelog (fixing Siggy's handle)

Co-Authored-By: Max Helmetag <max.helmetag@procore.com>
Co-Authored-By: Michael Siegfried <michael@procore.com>
Drenmi added a commit that referenced this issue Jan 25, 2019
[Fix #6382] Fix `Layout/IndentationWidth` with `Layout/EndAlignment` …
@Drenmi Drenmi mentioned this issue Feb 10, 2019
@gerrywastaken
Copy link
Contributor Author

I have tested the fix yet, but I just wanted to say thanks for working on it. :)

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

No branches or pull requests

2 participants