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

S6073 should not report on method invocation arguments that actually return an argument matcher

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0
    • Component/s: None
    • Labels:

      Description

      S6073 fails to identify argument matchers when one of the arguments is a method invocation and the return type of the method is not explicitly an argument matcher.

      import static java.util.Arrays.asList;
      import static java.util.Collections.emptyList;
      
      import static org.mockito.ArgumentMatchers.argThat;
      import static org.mockito.ArgumentMatchers.eq;
      import static org.mockito.BDDMockito.given;
      
      @Test
      public void dummyTest() {
         given(dummyClass.findAll(eqCollection(1L), eq(17))).willReturn(emptyList()); // Compliant FP
      }
      
      private Collection<Long> eqCollection(Long... items) {
         return argThat( c -> c.size() == items.length() && c.containsAll(asList(items)));
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dorian.burihabwa Dorian Burihabwa
              Reporter:
              dorian.burihabwa Dorian Burihabwa
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: