Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4
    • Component/s: Rules

      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

            Activity

              People

              • Assignee:
                sebastian.hungerecker Sebastian Hungerecker
                Reporter:
                quentin.jaquier Quentin Jaquier
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: