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

Infinite Loop Between Minitest/EmptyLineBeforeAssertionMethods and Layout/EmptyLinesAroundClassBody #196

Closed
ryanquanz opened this issue Nov 8, 2022 · 0 comments · Fixed by #197

Comments

@ryanquanz
Copy link
Contributor

Expected behavior

When linting a minitest class whose first test only contains an assertion, Minitest/EmptyLineBeforeAssertionMethods should not try to insert an empty line above the test method as this violates Layout/EmptyLinesAroundClassBody. The following should be valid:

class MyClassTest  < Minitest::Test
  test "::foo works" do
    assert_equal 1, MyClass.foo(1)
  end
end

Actual behavior

Minitest/EmptyLineBeforeAssertionMethods autocorrects to:

class MyClassTest  < Minitest::Test

  test "::identity_function works" do
    assert_equal 1, MyClass.identity_function(1)
  end
end

Steps to reproduce the problem

Try linting the class from expected behaviour.

RuboCop version

1.38.0 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 3.1.2) [arm64-darwin21]
  - rubocop-minitest 0.23.1
  - rubocop-performance 1.15.0
  - rubocop-rails 2.17.2
  - rubocop-sorbet 0.6.11
krishanbhasin-shopify pushed a commit to krishanbhasin-shopify/rubocop-minitest that referenced this issue Nov 9, 2022
Addresses rubocop#196

Fix a false positive when using an assertion method as the first
line within a test block

Co-authored-by: Ryan Quanz <[email protected]>
krishanbhasin-shopify pushed a commit to krishanbhasin-shopify/rubocop-minitest that referenced this issue Nov 9, 2022
…Methods\`

Addresses rubocop#196

Fix a false positive when using an assertion method as the first
line within a test block

Co-authored-by: Ryan Quanz <[email protected]>
krishanbhasin-shopify pushed a commit to krishanbhasin-shopify/rubocop-minitest that referenced this issue Nov 9, 2022
…Methods\`

Addresses rubocop#196

Fix a false positive when using an assertion method as the first
line within a test block

Co-authored-by: Ryan Quanz <[email protected]>
krishanbhasin-shopify pushed a commit to krishanbhasin-shopify/rubocop-minitest that referenced this issue Nov 9, 2022
…Methods\`

Addresses rubocop#196

Fix a false positive when using an assertion method as the first
line within a test block

Co-authored-by: Ryan Quanz <[email protected]>
krishanbhasin-shopify pushed a commit to krishanbhasin-shopify/rubocop-minitest that referenced this issue Nov 9, 2022
…ethods`

Addresses rubocop#196

Fix a false positive when using an assertion method as the first
line within a test block

Co-authored-by: Ryan Quanz <[email protected]>
krishanbhasin-shopify pushed a commit to krishanbhasin-shopify/rubocop-minitest that referenced this issue Nov 9, 2022
…ethods`

Addresses rubocop#196

Fix a false positive when using an assertion method as the first
line within a test block

Co-authored-by: Ryan Quanz <[email protected]>
krishanbhasin-shopify pushed a commit to krishanbhasin-shopify/rubocop-minitest that referenced this issue Nov 11, 2022
…ethods`

Addresses rubocop#196

Fix a false positive when using an assertion method as the first
line within a test block

Co-authored-by: Ryan Quanz <[email protected]>
@koic koic closed this as completed in #197 Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant