Hi SonarLint & Language team,
Found a false positive on rule S6073 - Mockito argument matchers should be used on all parameters
An issue is raised by this rule when I use an argument matcher defined in another method, example:
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())
}
private Collection<Long> eqCollection(Long... items) {
argThat( c -> c.size() == items.length() && c.containsAll(asList(items)))
}
With the message Add an eq() argument matcher on this parameter
on the line
given(dummyClass.findAll(eqCollection(1L), eq(17))).willReturn(emptyList())
Looks like my method eqCollection
is not recognized as an argumentMatcher
Using:
- SonarLint for IntelliJ version 4.14.2.28348
- Java Code analyzer version 6.12.0.24852
- Java 15.0.2
With
Xavier