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

Autocorrect align end to if is misaligned #3114

Closed
guyisra opened this issue May 6, 2016 · 2 comments · Fixed by #3117
Closed

Autocorrect align end to if is misaligned #3114

guyisra opened this issue May 6, 2016 · 2 comments · Fixed by #3117

Comments

@guyisra
Copy link

guyisra commented May 6, 2016

running rubocop on this file with auto-correct

a = if x == 1
      "A"
    elsif x == 2
      "B"
    else
      nil
    end

results in

a = if x == 1
      "A"
    elsif x == 2
      "B"
        end

Running it again will not align the end

test.rb:5:9: W: end at 5, 8 is not aligned with if at 1, 4.
        end
        ^^^
@jonas054
Copy link
Collaborator

jonas054 commented May 8, 2016

Style/EmptyElse messes up the indentation of end. Then Lint/EndAlignment doesn't fix it, because auto-correct is disabled by default for that cop (see for example #2719). I think this should be fixed in Style/EmptyElse.

@rrosenblum
Copy link
Contributor

I agree with @jonas054, this should be fixed in Style/EmptyElse. I think I know what the issue is, and this should be easy to fix. I will try to find some time to knock this out.

rrosenblum added a commit to rrosenblum/rubocop that referenced this issue May 10, 2016
bbatsov added a commit that referenced this issue May 10, 2016
[Fix #3114] Fix alignment of end in EmptyElse
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
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

Successfully merging a pull request may close this issue.

3 participants