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

Autocorrect for Minitest/EmptyLineBeforeAssertionMethods with trailing comments #190

Closed
movermeyer opened this issue Nov 1, 2022 · 0 comments · Fixed by #192
Closed
Labels
bug Something isn't working

Comments

@movermeyer
Copy link

movermeyer commented Nov 1, 2022

This code:

I18n.with_locale(:dummy) do
  value = I18n.t("name_formatter.display_full_name") # From en
  assert_equal("%{first_name} %{last_name}", value)
end

Gets flagged as a Minitest/EmptyLineBeforeAssertionMethods offense.

Run rubocop -a --only=Minitest/EmptyLineBeforeAssertionMethods to do the correction.

Expected behavior

Expected that a newline would be added before the assert_equal line:

I18n.with_locale(:dummy) do
    value = I18n.t("name_formatter.display_full_name") # From en
+
    assert_equal("%{first_name} %{last_name}", value)
end

Actual behavior

A newline is added after the value = line, but before the comment on the line:

I18n.with_locale(:dummy) do
-   value = I18n.t("name_formatter.display_full_name") # From en
+   value = I18n.t("name_formatter.display_full_name")
+ # From en
    assert_equal("%{first_name} %{last_name}", value)
end

RuboCop version

$ [bundle exec] rubocop -V
1.37.1 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 3.1.2) [arm64-darwin21]
  - rubocop-minitest 0.23.0
  - rubocop-performance 1.15.0
  - rubocop-rake 0.6.0
@movermeyer movermeyer changed the title Autocorrect for Minitest/EmptyLineBeforeAssertionMethods has issues with comments Autocorrect for Minitest/EmptyLineBeforeAssertionMethods with trailing comments Nov 1, 2022
@koic koic added the bug Something isn't working label Nov 1, 2022
koic added a commit to koic/rubocop-minitest that referenced this issue Nov 2, 2022
…eBeforeAssertionMethods`

Fixes rubocop#190.

This PR fixes an incorrect autocorrect for `Minitest/EmptyLineBeforeAssertionMethods`
when using method call with source code comment before assertion method.
@koic koic closed this as completed in #192 Nov 4, 2022
koic added a commit that referenced this issue Nov 4, 2022
…nitest_empty_line_before_assertion_methods

[Fix #190] Fix an incorrect autocorrect for `Minitest/EmptyLineBeforeAssertionMethods`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants