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

AssertPredicate cop doesn't account for methods receiving a block #172

Closed
brian-kephart opened this issue May 20, 2022 · 1 comment · Fixed by #173
Closed

AssertPredicate cop doesn't account for methods receiving a block #172

brian-kephart opened this issue May 20, 2022 · 1 comment · Fixed by #173
Labels
bug Something isn't working

Comments

@brian-kephart
Copy link

The AssertPredicate cop does not appear to recognize when a method receives a block argument.


Expected behavior

The AssertPredicate cop should not consider this an offense:

assert [1, 2, 3].any? { some_filter_function _1 }

Actual behavior

Minitest/AssertPredicate: Prefer using assert_predicate([1, 2, 3], :any?).

Also, the autocorrect function discards the block entirely, leaving:

assert_predicate [1, 2, 3], :any?

RuboCop version

1.28.2 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 3.1.2 arm64-darwin21)

  • rubocop-minitest 0.19.1
@brian-kephart
Copy link
Author

I just discovered as well that when disabling the cop with a comment, I get the following violation:

Unnecessary disabling of `Minitest/AssertPredicate` (did you mean `Minitest/AssertMatch`?).Lint/RedundantCopDisableDirective(RuboCop)

@koic koic added the bug Something isn't working label May 21, 2022
koic added a commit to koic/rubocop-minitest that referenced this issue May 23, 2022
Fixes rubocop#172.

This PR fixes a false positive for `Minitest/AssertPredicate` and
`Minitest/RefutePredicate` when using numbered parameters.
@koic koic closed this as completed in #173 May 26, 2022
koic added a commit that referenced this issue May 26, 2022
…ssert_predicate

[Fix #172] Fix a false positive for `Minitest/AssertPredicate`
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
Development

Successfully merging a pull request may close this issue.

2 participants