Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3402

Rule S5853: Consecutive AssertJ "assertThat" statement should be chained

    Details

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

      Description

      Implements RSPEC-5853.

      In order to avoid false positive, we have to make sure that:

      • Two assertThat are consecutive:
        // Compliant
        assertThat(someList).hasSize(3);
        doSomethingModifyingSomeList();
        assertThat(someList).contains("something");
        
      • some method might not be relevant (extract, filter, usecomparator)
        // Compliant
        assertThat(X).usingComparator(...).containsAnyOf(...);
        assertThat(X).containsAnyOf(...);
        

        One solution could be to report only when there is one method call after the assertThat.

        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: