-
-
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
Fixes an issue with empty lines around modifier keyword and beginning of a block #1553
Fixes an issue with empty lines around modifier keyword and beginning of a block #1553
Conversation
8b43f72
to
d4226fe
Compare
Coverage increased (+0.0%) when pulling 8b43f7271742b698b46f860625627e43da7b3689 on volkert:empty-lines-with-blocks-and-modifiers into 7650116 on bbatsov:master. |
d4226fe
to
7650116
Compare
I don't know why the build on travis is failing, it doesn't seem to be related to my change. Am I missing something there? |
Seems like some JRuby bug... |
@@ -61,6 +63,10 @@ def class_def?(line) | |||
%w(class module).any? { |keyword| line.start_with?(keyword) } | |||
end | |||
|
|||
def block_start?(line) | |||
line.match(/ do$/) |
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.
This won't be robust enough, as someone might be using {
for block delim.
19b8ec8
to
86f1e6c
Compare
Coverage increased (+0.32%) when pulling 86f1e6c2773b707cdcec87b53caef40012de3b3a on volkert:empty-lines-with-blocks-and-modifiers into 7fa6456 on bbatsov:master. |
The code seems OK to me now. Just squash the two commits together and we're good to go. |
86f1e6c
to
90f383a
Compare
Done! |
expect(cop.offenses).to be_empty | ||
end | ||
|
||
it 'accepts missing blank line with do and arguments' do |
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.
Guess we should have a spec like this for {}
blocks as well.
90f383a
to
d72e547
Compare
d72e547
to
dcecd86
Compare
Like this? |
👍 Indeed. Thanks for fixing this! |
…ifiers Fixes an issue with empty lines around modifier keyword and beginning of a block
There is no way that the following code is valid for rubocop. It will either complain about the missing empty line above the access modifier (
Style/EmptyLinesAroundAccessModifier
) or the empty line at the beginning of a block (Style/EmptyLinesAroundBlockBody
).This example occured when using rails concerns.
This PR fixes this issue. Please let me know if I can improve my PR, I'm looking forward to contribute!