ruby-style-guide icon indicating copy to clipboard operation
ruby-style-guide copied to clipboard

Add section for empty lines after module inclusion methods

Open lovro-bikic opened this issue 7 months ago • 0 comments

Adds a section for keeping empty lines after module inclusion methods (extend, include and prepend). The term "module inclusion" has been borrowed from Layout/ClassStructure docs. I couldn't find a similar issue or PR (either here or for RuboCop).

Under this style, code such as:

module Foo
  include Bar
  def baz; end
end

wouldn't be acceptable; there would have to be an empty line after include line:

module Foo
  include Bar

  def baz; end
end

This style is suggested — though not made explicit — by Consistent Classes and module_function sections of the guide (Prefer public_send section's example also shows this practice).

This GH search shows examples where module inclusion methods have been followed by an empty line or the keyword end (cca 2M at the time of writing). And this search shows examples where the methods have been followed by a non-empty line (cca 844k results; note that this search includes many false positives, like grouped include lines, so there are even fewer actual examples).

Some codebases where this style is mostly followed:

There's also no RuboCop cop for this style, so, if accepted, a new cop would have to be implemented.

lovro-bikic avatar Mar 29 '25 21:03 lovro-bikic