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

[Fix #157] Add new Minitest/EmptyLineBeforeAssertionMethods cop #163

Conversation

koic
Copy link
Member

@koic koic commented Mar 10, 2022

Fixes #157.

This PR adds new Minitest/EmptyLineBeforeAssertionMethods cop.

This cop enforces empty line before assertion method.

# bad
do_something
assert_equal(expected, actual)

# good
do_something

assert_equal(expected, actual)

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@@ -99,6 +99,11 @@ Minitest/AssertWithExpectedArgument:
Safe: false
VersionAdded: '0.11'

Minitest/EmptyLinesBeforeAssertionMethod:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would EmptyLineBeforeAssertionMethod (no plural) be better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was wondering about the name of this cop. I've renamed it to Minitest/EmptyLineBeforeAssertionMethods.

Copy link
Contributor

@andyw8 andyw8 Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this again, I wonder if talking about line/lines is too specific, and the name should better convey the intention.

This is closely tied to Arrange-Act-Assert or the Four Phase Test.

I can't think of a good name yet, but maybe something along the lines of SeparateAssertionPhase or DistinctAssertions...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andyw8 I was second thoughts about this cop name. But I will name it as Minitest/EmptyLineBeforeAssertionMethods because the RuboCop core has many similar names.
The attractive candidate SeparateAssertionPhase has been included as the cop document description.

@koic koic changed the title [Fix #157] Add new Minitest/EmptyLinesBeforeAssertionMethod cop [Fix #157] Add new Minitest/EmptyLinesBeforeAssertionMethods cop Mar 11, 2022
@koic koic force-pushed the add_new_minitest_empty_line_before_assertion_method_cop branch from e2481fb to 7a9c3d8 Compare March 11, 2022 09:43
@koic koic force-pushed the add_new_minitest_empty_line_before_assertion_method_cop branch from 7a9c3d8 to c0d5f54 Compare October 10, 2022 12:33
@koic koic changed the title [Fix #157] Add new Minitest/EmptyLinesBeforeAssertionMethods cop [Fix #157] Add new Minitest/EmptyLinesBeforeAssertionMethod cop Oct 10, 2022
@koic koic changed the title [Fix #157] Add new Minitest/EmptyLinesBeforeAssertionMethod cop [Fix #157] Add new Minitest/EmptyLineBeforeAssertionMethod cop Oct 10, 2022
@koic koic force-pushed the add_new_minitest_empty_line_before_assertion_method_cop branch from c0d5f54 to a94e790 Compare October 12, 2022 06:22
@koic koic changed the title [Fix #157] Add new Minitest/EmptyLineBeforeAssertionMethod cop [Fix #157] Add new Minitest/EmptyLineBeforeAssertionMethods cop Oct 12, 2022
@koic koic force-pushed the add_new_minitest_empty_line_before_assertion_method_cop branch 2 times, most recently from 5304493 to e541e62 Compare October 12, 2022 07:32
Fixes rubocop#157.

This PR adds new `Minitest/EmptyLineBeforeAssertionMethods` cop.

This cop enforces empty line before assertion method because it separates assertion phase.

```ruby
# bad
do_something
assert_equal(expected, actual)

# good
do_something

assert_equal(expected, actual)
```
@koic koic force-pushed the add_new_minitest_empty_line_before_assertion_method_cop branch from e541e62 to 6d8a9e7 Compare October 13, 2022 03:26
@koic koic merged commit 11f5529 into rubocop:master Oct 15, 2022
@koic koic deleted the add_new_minitest_empty_line_before_assertion_method_cop branch October 15, 2022 15:10
@sandstrom
Copy link

@koic Awesome! 🥇

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.

Newline before assert
3 participants