Skip to content

Commit

Permalink
Ensure empty line between method definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
molawson committed May 16, 2024
1 parent 94164b0 commit 0285523
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/syntax_tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9981,6 +9981,11 @@ def format(q)
q.breakable_force
q.breakable_force
q.format(statement)
elsif statement.is_a?(DefNode) && previous.is_a?(DefNode) &&
(statement.location.start_line - line) == 1
q.breakable_force
q.breakable_force
q.format(statement)
elsif statement.location.start_line != line
q.breakable_force
q.format(statement)
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ def foo( # comment
=end
a
end
%
def foo
end
def bar
end
-
def foo
end
def bar
end
11 changes: 11 additions & 0 deletions test/fixtures/defs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@ def foo::foo
-
def foo.foo
end
%
def foo.foo
end
def foo.bar
end
-
def foo.foo
end
def foo.bar
end

0 comments on commit 0285523

Please sign in to comment.