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. VerifyOnce
  3. InvocationOnMockGetArguments
  4. InvocationOnMockGetArgumentsWithTypeParameter

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();
   }

VerifyOnce

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

InvocationOnMockGetArguments

SUGGESTION

Simplification

Suppression

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

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

Samples

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

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

InvocationOnMockGetArgumentsWithTypeParameter

SUGGESTION

Simplification

Suppression

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

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

Samples

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

 ImmutableSet<Number> testInvocationOnMockGetArgumentsWithTypeParameter() {
     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-2024 Picnic Technologies BV