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

EndAlignment has problems with newline in LHS #350

Closed
agrimm opened this issue Jul 11, 2013 · 1 comment
Closed

EndAlignment has problems with newline in LHS #350

agrimm opened this issue Jul 11, 2013 · 1 comment

Comments

@agrimm
Copy link
Contributor

agrimm commented Jul 11, 2013

# No offence
a,
b = [1, 2].map {|i| i - 5}
# No offence either
c,
d = [3, 4].map do |i|
      i - 5
    end
# Gets an end alignment offence
e,
f = [5, 6].map do |i|
  i - 5
end


end_alignment_bug.rb:13:1: W: end at 13, 0 is not aligned with [5, 6].map do |i| at 11, 4
end
^^^

In the third snippet, I think it's ok for end to align with the e variable.

However, having e and f on different lines is pretty dodgy, so it's not so much a false positive, as not highlighting the correct problem.

@edzhelyov
Copy link
Collaborator

The code that raise the offence is related to checks for code like:

variable =
  test do |i|
  end

This assumes that if you split the line, then the last line should contain only the block statement, but we don't handle your case :/. This is another case where the block's end needs to be aligned with the start of the line where the block is defined.

Whether e and f should be on the same line or not has to be handled in entirely different Cop, which I think we don't have at the moment.

Anyway, I'll work on fixing cases like the 3rd one.

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

2 participants