SonarQube issue with Java rule S6073

  • versions used (SonarQube, Scanner, language analyzer):
    SonarQube 9.1

SonarLint connected to SonarQube does NOT show the issue

  • minimal code sample to reproduce (with analysis parameter, and potential instructions to compile):
    ‘’‘Mockito.verify(Test.this.someInstance).someMethod(Test.this.someCaptor.capture(), eq(someValue));’’’

SonarQube complains about someCaptor.capture() needing an “eq” argument matcher:
“Add an “eq()” argument matcher on this parameter.”
Seems like removing “Test.this” from both the instance and the captor “solves” the issue

Hello @rporta-cc

I stumbled into this old topic and decided to have a closer look.

I did not manage to reproduce the issue on the current version of the Java analyzer.
However, I had to guess what the full code looked like, and came up with:

import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;

import static org.mockito.ArgumentMatchers.eq;

class MyTest {
  private Foo someInstance;
  private ArgumentCaptor<String> someCaptor;

  void nonCompliant() {
    Mockito.verify(MyTest.this.someInstance).f(MyTest.this.someCaptor.capture(), eq("someValue"));

  static class Foo {
    String f(Object a, Object b) {
      return "hi";

If you are still facing the issue, could you confirm that your code looks something like this?

In addition, you might want to check the content of the analysis logs to see if there is nothing related to unresolved imports/types, it might be the cause of this false positive.


Hi @Quentin . I am also seeing this issue.

This is the line of code:

verify(preparer, times(1)).prepare(contextPathCaptor.capture(), any(), pageCaptor.capture())

This is the SQ message:
Add an “eq()” argument matcher on this parameter.
Mockito argument matchers should be used on all parameters.

It’s flagging the issue on pageCaptor.capture().
Rule java:S6073.

The rule says that “Mockito provides argument matchers and argument captors for flexibly stubbing or verifying method calls.” … “However, if argument matchers or captors are used only on some of the parameters, all the parameters need to have matchers as well”.

As you can see I am only using matchers and captures so this shouldn’t be a flagged bug.

Hello @RJones92

I’m afraid I don’t have much to add to my previous post. All the tests I did on my side are working fine.
In order to investigate further, it could be great to give more context:

  • What is the exact location of the issue?
  • Could you provide a minimal reproducer? Something similar to what I posted in my first post.
  • Did you check that you don’t have any warning in the analysis logs? I would expect such FP in a misconfigured project.

As a final word: due to the small imprecision of this rule. we decided to remove it from the default quality profile. It targets mainly beginners with Mockito, if you know what you are doing you probably don’t need it and should feel free to resolve the issue as “false-positive”.