-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Cop Feature Request: Catch assert expression.nil? and suggest assert_nil instead #140
Comments
IMO, it is not a bad practice to use The cop was introduced because |
Do you know when they were deprecated? I can't see a mention in https://github.com/seattlerb/minitest/blob/master/History.rdoc |
Sorry. My bad. I meant |
I think a good reason to prefer For example, this assert: assert 1.nil? results in this error message:
But if you use assert_nil 1 you get this more informative error message:
Yes, you can go look at the test to figure out what happened, but it's slightly nicer to see the expression that caused the issue right in the error message. |
…bj.nil?)` Fixes rubocop#140. This PR makes `Minitest/AssertNil` and `Minitest/RefuteNil` aware of `assert(obj.nil?)` and `refute(obj.nil?)`.
…e_of_assert_method [Fix #140] Make `AssertNil` and `RefuteNil` aware of `assert(obj.nil?)`
Is your feature request related to a problem? Please describe.
The
AssertNil
andRefuteNil
cops do catch cases like the following, and suggestsassert_nil
instead:But they don't catch cases that use
.nil?
like this:The minitest style guide currently even uses a
.nil?
example for Refute Nil.Describe the solution you'd like
It would be nice if the
AssertNil
andRefuteNil
cops could catch these.nil?
cases too.Describe alternatives you've considered
It's not hard to write a regex for this myself, but having this be part of rubocop-minitest would be more convenient.
Additional context
N/A
The text was updated successfully, but these errors were encountered: