-
-
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
Allow configuration of trailing blank lines #490
Conversation
end | ||
end | ||
|
||
def max | ||
cop_config['Max'] || 0 |
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.
You should add the Max
parameter in config/default.yml
. Then you can remove || 0
because all configurations are based on the default so cop_config['Max']
is guaranteed to have a non-nil value.
Not sure such an option makes sense. Why would anyone want to have some trailing blank lines in their source code? |
In our project, a lot of our files end with 1 trailing blank line:
I figured we would allow 1 trailing blank line. I'm leaning toward just cleaning up our files though so I will close this out. |
By common convention (not only for Ruby) source files should end with just a newline. It doesn't make sense for me to start breaking such strongly established practice. |
There's a big difference between "newline at end of file" and "blank line at end of file" (two consecutive newlines). Some editors (e.g. Komodo) automatically add a blank line if one does not exist, as many people do find it easier to read that way. No team that I've been on in the last three decades used a standard requiring no blank lines at the end of files. Granted, Ruby has only been involved in the last ~5 years of that, but springing this new behaviour on people and having every single file report a violation is a bit much. I see the value in warning of multiple blank lines at the ends of files. I see no value whatever in a change that requires that an otherwise-useful new feature (the cop under discussion here) be disabled to avoid requiring touching every single source file in a project. I know cops aren't doctors, but "first, do no harm" really should apply here, too. |
Why was this not merged? How can I turn off this cop? |
The author closed it so it would have to be reopened first in order to be merged. I'm not sold on the idea of a @bbatsov If you agree I can implement that and make a new pull request. @aaronmcadam To disable the cop, just add TrailingBlankLines:
Enabled: false in your |
@jonas054 Yeah thanks I figured that bit out! What I'd like to figure out now is how to stop the autocorrect directive from removing the trailing new line when it runs. |
If you've disabled the cop, there will be no auto-correct action related to that offence. |
@jonas054 ah, my bad, just tried it again and it's ok, must have been something else! Thanks for helping :) |
@jonas054 I'd be happy to work on an |
@daviddavis It's yours then! 😄 |
@daviddavis @jonas054 As I originally said - I'm against such a change, but I can live with it. Let's have an enforced style param with supported values |
@bbatsov I would like to see this too, as there are a few reasons to have a trailing newline in your code. For example:
Couple of discussions here: I hope this doesn't come across as bikeshedding, I just wanted to point out that there are a bunch of practical reasons for it. |
👍 for the |
I'm reopening and assigning myself. |
@jonas054 thanks. I apologize for not getting around to it. |
@daviddavis No problem! |
Nice! 🍻 |
Yay thank you :) |
No description provided.