-
-
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
[Fix #255] Add new Minitest/AssertOperator
and Minitest/RefuteOperator
cops
#260
[Fix #255] Add new Minitest/AssertOperator
and Minitest/RefuteOperator
cops
#260
Conversation
…uteOperator` cops Fixes rubocop#255. This PR adds new `Minitest/AssertOperator` and `Minitest/RefuteOperator` cops. ## `Minitest/AssertOperator` cop This cop enforces the use of `assert_operator(expected, :<, actual)` over `assert(expected < actual)`. ```ruby # bad assert(expected < actual) # good assert_operator(expected, :<, actual) ``` ## `Minitest/RefuteOperator` cop This cop enforces the use of `refute_operator(expected, :<, actual)` over `refute(expected < actual)`. ```ruby # bad refute(expected < actual) # good refute_operator(expected, :<, actual) ```
@koic: Is it intentional that this triggers for hash access too? I understand the benefits for math operators like in these examples and in the style guide, but these suggestions for hashes seem less idiomatic to me:
Since I didn't see this type of thing called out in the style guide, I just wasn't sure if this new behavior was intentional or not. Thanks! |
I've released 0.32.2 with that change. Thank you! |
This is awesome thanks so much @koic for adding this! I just ran this across our codebase and discovered an autocorrect which I found interesting: refute(something == something_else) corrected to: refute_operator(something, :==, something_else) , which is expected, of course. However, I'm surprised the refute_equal(something, something_else) Is that a missing feature of Thanks again |
Follow up rubocop#260 (comment) This PR makes `Minitest/RefuteEqual` aware of `refute(expected == actual)`.
Thank you for the feedback. I've opened #265. After this I'll open a PR that will make some more adjustments. |
Follow up rubocop#260 (comment) This PR makes `Minitest/RefuteEqual` aware of `refute(expected == actual)`.
Fixes #255.
This PR adds new
Minitest/AssertOperator
andMinitest/RefuteOperator
cops.Minitest/AssertOperator
copThis cop enforces the use of
assert_operator(expected, :<, actual)
overassert(expected < actual)
.Minitest/RefuteOperator
copThis cop enforces the use of
refute_operator(expected, :<, actual)
overrefute(expected < actual)
.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.