-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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/IndentHeredoc with wrong output #4662
Comments
This cop says this code should be aligned like the following. stdout = <<~END
2017-03-22 09:28:24 sudo python width_and_depth_tests.py
Width test: PASSED
Depth test: FAILED
END The 2 space means 2 space * indentation level. stdout = <<~END # This line is indented by 2 * 2 space
2017-03-22 09:28:24 sudo python width_and_depth_tests.py # This line is indented by 2 * 3 space (+1 level)
Width test: PASSED
Depth test: FAILED
END |
Thanks, i misunderstand it. |
But If i do need a blank in the beginning of EOF iike:
How to fix this cop? |
Hmm, It is a bug of this cop. |
Let's reconsider the message in this case too: |
I think so, this message may make people confused. |
Checking indentation of heredocs would fail if the first line was empty, with a nonsense message: <<~HEREDOC foo HEREDOC # Use 2 spaces for indentation in a heredoc by using `<<~` instead of `<<~`. Indentations were detected as leading contiguous whitespace. In the example above, this would be "\n ", which fails the check due to being 3 characters long. By first splitting lines, we are can safely rely on the leading contiguous whitespace being the indent. Resolves: rubocop#4662 See also: rubocop#4465
Checking indentation of heredocs would fail if the first line was empty, with a nonsense message: <<~HEREDOC foo HEREDOC # Use 2 spaces for indentation in a heredoc by using `<<~` instead of `<<~`. Indentations were detected as leading contiguous whitespace. In the example above, this would be "\n ", which fails the check due to being 3 characters long. By first splitting lines, we are can safely rely on the leading contiguous whitespace being the indent. Resolves: #4662 See also: #4465
My ruby code is as below:
Rubpcop output is:
So I add 2 spaces for 3 lines like below:
Still same output, then i read the doc and it align with
<<~
, then i try and also fail.I think the output is not clear or even wrong.
The text was updated successfully, but these errors were encountered: