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

EmptyLinesAroundBody at start of class #771

Closed
lenntt opened this issue Jan 28, 2014 · 5 comments · Fixed by #1399
Closed

EmptyLinesAroundBody at start of class #771

lenntt opened this issue Jan 28, 2014 · 5 comments · Fixed by #1399
Assignees

Comments

@lenntt
Copy link

lenntt commented Jan 28, 2014

Hi,

Though I like the EmptyLinesAroundBody cop checking for white lines before an 'end', there is a situation where I dont like the check at the beginning of a block, namely after a class definition.

It sometimes clashes with the rule 'having white lines around a "private" statement', when e.g. EmptyLinesAroundBody doesnt allow:

class Foo

  private

  def bar
   end
end

Also, more of a personal preference, I like a white line between a class definitions and attr_reader etc..

So my suggestion is: have a special configuration for disabling the cop at the start of a class or module.

@bbatsov
Copy link
Collaborator

bbatsov commented Jan 28, 2014

Sometimes? This code won't trigger an offence:

class Foo
  private

  def bar
  end
end

I'll consider your request, but I find it pretty odd to start a definition with leading blank lines.

@lenntt
Copy link
Author

lenntt commented Jan 28, 2014

I agree it doesnt trigger a rubocop offence, however, the ruby style guide says:

Indent the public, protected, and private methods as much the method definitions they apply to. Leave one blank line above the visibility modifier and one blank line below in order to emphasize that it applies to all methods below it.

@kalabiyau
Copy link
Contributor

we have custom cop for that. It is indeed very specific style, anyway

https://gist.github.com/kalabiyau/57a6767d9ac35604e60a

jonas054 added a commit to jonas054/rubocop that referenced this issue Oct 21, 2014
In order to make it possible to configure where we
want empty lines and where we don't want them, the
EmptyLinesAroundBody cop is removed and replaced
by three new cops, EmptyLinesAroundMethodBody,
EmptyLinesAroundClassBody, and
EmptyLinesAroundModuleBody. The last two can be
configured to require or disallow empty lines
around the body.
@jonas054
Copy link
Collaborator

@SirLenz0rlot I confused two issues and closed this one with my commit, which doesn't implement what you asked for. So I'm reopening. If and when we close this one, it should be a conscious decision.

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 19, 2015

No activity for one year, guess there's little interest in adding this feature. I'll close the ticket.

@bbatsov bbatsov closed this as completed Dec 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants