Skip to content
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

Modify rule S5841: Fix typo in AssertJ "doesNotContain" #4385

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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