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

Add and apply rubocop rules for empty lines #3795

Merged
merged 6 commits into from
Oct 24, 2019
Merged

Conversation

javierm
Copy link
Member

@javierm javierm commented Oct 24, 2019

References

Background

We were very inconsistent regarding empty lines at the beginning/end of a class/module/block.

Objectives

  • Make the code more consistent
  • Add rules so contributors know which criteria to use when writing new code

@javierm javierm added the Linters Rubocop, ERB Lint, ESLint, SCSS-Lint, ... label Oct 24, 2019
@javierm javierm self-assigned this Oct 24, 2019
@javierm javierm added this to Reviewing in Roadmap via automation Oct 24, 2019
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
This comment isn't necessary since Ruby 2.0, where UTF-8 became the
default encoding.

I've found this issue thanks to the EmptyLineAfterMagicComment rubocop
rule.
Unfortunately, there doesn't seem to be a Rubocop rule for this one.
I've found these empty lines thanks to Rufo.
We were using it in most places, but not everywhere.
@javierm
Copy link
Member Author

javierm commented Oct 24, 2019

This pull request only deals with white space; Travis failures are not related to it.

@javierm javierm merged commit 00145d5 into master Oct 24, 2019
Roadmap automation moved this from Reviewing to Release 1.1.0 Oct 24, 2019
@javierm javierm deleted the rubocop_empty_lines branch October 24, 2019 16:41
smarques pushed a commit to venetochevogliamo/consul that referenced this pull request Apr 29, 2020
Add and apply rubocop rules for empty lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linters Rubocop, ERB Lint, ESLint, SCSS-Lint, ...
Projects
No open projects
Roadmap
  
Release 1.1.0
Development

Successfully merging this pull request may close these issues.

None yet

1 participant