MockitoRules

SUGGESTION

Simplification

View source code on GitHub

Suppression

Disable all rules by adding -XepOpt:Refaster:NamePattern=^(?!MockitoRules\$).* as compiler argument.

Table of contents
  1. Never
  2. Verify
  3. InvocationOnMockGetArgument
  4. InvocationOnMockGetArgumentObject

Never

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("Never") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!MockitoRules\$Never).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 VerificationMode testNever() {
-  return times(0);
+  return never();
 }

Verify

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("Verify") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!MockitoRules\$Verify).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 Object testVerify() {
-  return verify(mock(Object.class), times(1));
+  return verify(mock(Object.class));
 }

InvocationOnMockGetArgument

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("InvocationOnMockGetArgument") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!MockitoRules\$InvocationOnMockGetArgument).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 Object testInvocationOnMockGetArgument() {
-  return ((InvocationOnMock) null).getArguments()[0];
+  return ((InvocationOnMock) null).getArgument(0);
 }

InvocationOnMockGetArgumentObject

SUGGESTION

Simplification

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("InvocationOnMockGetArgumentObject") to the enclosing element.

Disable this rule by adding -XepOpt:Refaster:NamePattern=^(?!MockitoRules\$InvocationOnMockGetArgumentObject).* as compiler argument.

Samples

Shows the difference in example code before and after the Refaster rule is applied.

 ImmutableSet<Number> testInvocationOnMockGetArgumentObject() {
   return ImmutableSet.of(
-      ((InvocationOnMock) null).getArgument(0, Integer.class),
-      (Double) ((InvocationOnMock) null).getArgument(1));
+      ((InvocationOnMock) null).<Integer>getArgument(0),
+      ((InvocationOnMock) null).<Double>getArgument(1));
 }

Copyright © 2017-2026 Picnic Technologies BV