Details
Description
RSPEC-2701 reports the usage of boolean literals in assertions.
Assert.assertTrue(true); // Noncompliant assertThat(true).isTrue(); // Noncompliant assertEquals(true, something()); // Noncompliant
In practice, the vast majority of issues reported are similar to the third one.
We should extend the rule to support null literal:
Assert.assertNull(null); // Noncompliant Assert.assertNotNull(null); // Noncompliant assertThat(null).isNotNull(); // Noncompliant assertThat(null).isNull(); // Noncompliant assertEquals(null, something()); // Noncompliant
In addition, we could consider improving the issue message for the last case:
Use assertNull instead.
Attachments
Issue Links
- relates to
-
RSPEC-2701 Literal boolean values should not be used in assertions
- Active