rubocop / rubocop-minitest

Code style checking for Minitest files.
https://docs.rubocop.org/rubocop-minitest
MIT License
144 stars 44 forks source link

`AssertKindOf`: also replace `is_a?` as well #298

Closed amomchilov closed 10 months ago

amomchilov commented 10 months ago

The Minitest/AssertKindOf would replace this code:

assert(object.kind_of?(Class))

... but not:

assert(object.is_a?(Class))

...even though they are practically the same, since #is_a? is an alias for #kind_of? (not to be confused with #instance_of?).

This PR simply extends Minitest/AssertKindOf to correct both.

I opted to modify the existing cop, rather than introducing a new cop like Minitest/AssertIsA, because it seems really unlikely to me that somebody would like to correct one, but not the other. Perhaps that's just a lack of imagination, let me know if there are any objections.


Before submitting the PR make sure the following are checked:

amomchilov commented 10 months ago
koic commented 10 months ago

I've left two comments. Can you update these and squash this PR's commits into one?

amomchilov commented 10 months ago

@koic Fixed and squashed! Thanks for reviewing

koic commented 10 months ago

Thanks!