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

Enhance Layout/EmptyLineBetweenDefs to include macros #11738

Closed
catwomey opened this issue Mar 26, 2023 · 1 comment · Fixed by #11897
Closed

Enhance Layout/EmptyLineBetweenDefs to include macros #11738

catwomey opened this issue Mar 26, 2023 · 1 comment · Fixed by #11897

Comments

@catwomey
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When writing code, I utilize macros that accept blocks and behave like a method def. An example is the rails test macro. Because these macros look like method definitions, I'd like them to follow the rules set in Layout/EmptyLineBetweenDefs.

Describe the solution you'd like

Enhance Layout/EmptyLineBetweenDefs to format configured macros as if they were method definitions. Default configuration would be an empty list

This is how I expect it to work if I were to configure the rule with ['test']

# Bad
test "the truth" do
  assert true
end
test "the false" do
  assert_not false
end

# Good
test "the truth" do
  assert true
end

test "the false" do
  assert_not false
end

Describe alternatives you've considered

I considered writing something specific to the test macro in Rubocop-rails. Similar to how rubocop-rspec is defined. I wanted to see if there was appetite for something a little more generic in the core rubocop rules first.

Additional context

I have some code written here that I've tested against one of my repositories, and if there's interest from the maintainers here I'll open a pull request.

@nobuyo
Copy link
Contributor

nobuyo commented Apr 4, 2023

You might want to open a PR. I'm just a contributor, not a maintainer. But your work looks good to me.
The maintainers most likely give some feedbacks.

catwomey added a commit to catwomey/rubocop that referenced this issue Jun 24, 2023
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 a pull request may close this issue.

2 participants