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
[Fix #11237] Fix Layout/CommentIndentation
comment aligned with acc…
#11343
Conversation
Can you add a changelog entry?
|
7a24cf9
to
597950f
Compare
This looks good to me. Can you squash your commits into one? |
…ith access modifier indentation when EnforcedStyle is outdent
597950f
to
591472c
Compare
done. thanks for quick review |
Thanks! |
/^\s*(end\b|[)}\]])/.match?(line) | ||
rule = config.for_cop('Layout/AccessModifierIndentation')['EnforcedStyle'] == 'outdent' | ||
access_modifier = 'private|protected|public' | ||
/\A\s*(end\b|[)}\]])/.match?(line) || (rule && /\A\s*(#{access_modifier})\b/.match?(line)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to extract /\A\s*(#{access_modifier})\b/
into a constant or inline access_modifier
into it, because this method call will always generate unnecessary allocations (needs measuring to know the impact).
|
||
context 'when `Layout/AccessModifierIndentation EnforcedStyle: outdent`' do | ||
let(:allow_for_alignment) { true } | ||
let(:indentation_width) { 2 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest removing this line (and from the top of the file) and inlining its value into the call, because it is never changed in the test file.
@@ -292,4 +292,55 @@ def compile_sequence(seq, seq_var) | |||
RUBY | |||
end | |||
end | |||
|
|||
context 'when `Layout/AccessModifierIndentation EnforcedStyle: outdent`' do | |||
let(:allow_for_alignment) { true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is not needed, because you redefine config
in this block (the single place where it was used).
[Fixed #11237]
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.