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

Formatting proposal: Ensure empty line between method definitions #461

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

molawson
Copy link
Contributor

We've been using SyntaxTree extensively for formatting in a number of our apps at work, and I recently came across something I was a bit surprised wasn't already part of the formatting rules: ensuring there's a blank line between each method definition.

Before this change, the following code would be unchanged by SyntaxTree:

def foo
end
def bar
end

After, it will be formatted like so:

def foo
end

def bar
end

I think this is a fairly uncontroversial formatting opinion (though I've certainly misjudged these before 😄). It lines up with the RuboCop default for Layout/EmptyLineBetweenDefs, which of course is disable when using the SyntaxTree RuboCop config. I stopped short of doing the same for classes and modules as method definitions seemed the most common to have in succession.

I took a swing at implementing the change, but I'm not terribly confident that this is exactly the right approach. I have run this against a few of our code bases and haven't seen any unintended changes.

Is this something you'd consider tweaking in SyntaxTree? If so, is there anything I can do differently in the implementation to help it fit in with the rest of the project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant