forked from rubocop/rubocop-minitest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
AssertEmptyLiteral
cop to check for assert_equal
While this cop is correct that we should be using `assert_empty(list)` over `assert([], list)`, it's right for the wrong reasons. That example is bad because it's using `assert` and not `assert_equal`. An empty list/hash is truthy so the assertion will always succeed. That is, `assert([], [1, 2, 3])` will succeed even though at a glance it looks like it shouldn't. I believe that what this cop is intending to check for is `assert_equal([], list)` instead so I've updated the references to `assert` to `assert_equal`. Issue rubocop#117 proposes that we try to detect when `assert` is used where the user likely wanted `assert_equal` so while this cop will no longer register a violation for `assert([], list)`, if that proposal is accepted then a future cop *will* register a violation.
- Loading branch information
Showing
3 changed files
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters