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

IndentHash with separator style AlignHash #875

Closed
yujinakayama opened this issue Mar 13, 2014 · 1 comment
Closed

IndentHash with separator style AlignHash #875

yujinakayama opened this issue Mar 13, 2014 · 1 comment
Assignees

Comments

@yujinakayama
Copy link
Collaborator

With this AlignHash separator style hash:

      CONVERSION_CORRESPONDENCE = {
                      match_for_should: :match,
                  match_for_should_not: :match_when_negated,
            failure_message_for_should: :failure_message,
        failure_message_for_should_not: :failure_message_when_negated
      }

... IndentHash registers an offense:

lib/transpec/syntax/matcher_definition.rb:12:23: C: IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
                      match_for_should: :match,
                      ^^^^^^^^^^^^^^^^^^^^^^^^

However, the pairs cannot be aligned if the first pair is indented with 2 spaces relative to the left curly line, since there is not enough left space in the failure_message_for_should_not: line. IMO, in this case, the longest key should be the target of IndentHash.

Also autocorrection breaks the code:

      CONVERSION_CORRESPONDENCE = {
        match_for_should: :match,
    match_for_should_not: :match_when_negatedfailure_message_for_should: :failure_mesfailure_message_for_should_not: :failure_message_when_negated
      }
0.19.0 (using Parser 2.1.7, running on ruby 2.1.1 x86_64-darwin13.0)

@jonas054 Can you take a look?

@jonas054 jonas054 self-assigned this Mar 13, 2014
@jonas054
Copy link
Collaborator

@yujinakayama Yes!

bbatsov added a commit that referenced this issue Mar 15, 2014
[Fix #875] Handle separator style hashes in IndentHash
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