Skip to content

Commit

Permalink
Fix typo in AssertJ "doesNotContain"
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye committed Oct 9, 2024
1 parent 2f262c1 commit 2fac5ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rules/S5841/java/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "AssertJ assertions \"allMatch\" and \"doesNotContains\" should also test for emptiness",
"title": "AssertJ assertions \"allMatch\" and \"doesNotContain\" should also test for emptiness",
"type": "BUG",
"code": {
"impacts": {
Expand Down
4 changes: 2 additions & 2 deletions rules/S5841/java/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
== Why is this an issue?

AssertJ assertions ``++allMatch++`` and ``++doesNotContains++`` on an empty list always returns true whatever the content of the predicate. Despite being correct, you should make explicit if you expect an empty list or not, by adding ``++isEmpty()++``/``++isNotEmpty()++`` in addition to calling the assertion, or by testing the list's content further. It will justify the useless predicate to improve clarity or increase the reliability of the test.
AssertJ assertions ``++allMatch++`` and ``++doesNotContain++`` on an empty list always returns true whatever the content of the predicate. Despite being correct, you should make explicit if you expect an empty list or not, by adding ``++isEmpty()++``/``++isNotEmpty()++`` in addition to calling the assertion, or by testing the list's content further. It will justify the useless predicate to improve clarity or increase the reliability of the test.


This rule raises an issue when any of the methods listed are used without asserting that the list is empty or not and without testing the content.
Expand Down Expand Up @@ -58,7 +58,7 @@ Test the emptiness of the list before calling this assertion predicate.

=== Highlighting

* Primary: allMatch/doesNotContains
* Primary: allMatch/doesNotContain
* Secondary: tested list


Expand Down

0 comments on commit 2fac5ec

Please sign in to comment.