Details

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

      Description

      S2698 suffers from multiple problems related to issue reporting that we should improve.

      • duplicate issues:
        This code will report one issue for each matches.
        assertThat("ABC")
         .matches("A")
         .matches("B")
         .matches("C");
        
      • the whole assertion is highlighted
        assertThrows(IllegalArgumentException.class,
              () -> //Huge code...)); // Everything is highlighted!!
        

        Can we do better? Only highlight one method call?

      • confusing behavior when the message is misplaced for fest assert (and AssertJ once SONARJAVA-3349¬†will be done)
        This call
        assertThat("").isEqualTo("").as("Message");
        will highlight
        assertThat("").isEqualTo("")
        claiming that a message is missing, it is not trivial to understand that it is actually misplaced.
        RSPEC-5833 will report that "as()" will not be applied, but this rule could still report that it is misplaced (or simply say to add a message before the assertion). In addition, highlighting should be on the assertion method name. (isEqualTo() in this case)
      • FP when a generic assertion is not an assertion predicate:
        org.assertj.core.api.Assertions.assertThat("").usingComparator(null).as("a").isEqualTo(222);
        

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                quentin.jaquier Quentin Jaquier
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: