Skip to content

Commit

Permalink
Perform some code changes found by SonarLint
Browse files Browse the repository at this point in the history
  • Loading branch information
picimako committed Sep 10, 2024
1 parent 8cc6feb commit 00f0845
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ else if (firstArgument instanceof PsiReferenceExpression variableRef) {
if (field.hasAnnotation(ORG_MOCKITO_MOCK)) {
holder.registerProblem(firstArgument, MockitoolsBundle.message("inspection.spying.on.mock.is.not.allowed"));
}
} else if (resolved instanceof PsiLocalVariable localVariable) {
if (MockObject.isAnyKindOfMock(localVariable)) {
holder.registerProblem(firstArgument, MockitoolsBundle.message("inspection.spying.on.mock.is.not.allowed"));
}
} else if (resolved instanceof PsiLocalVariable localVariable && MockObject.isAnyKindOfMock(localVariable)) {
holder.registerProblem(firstArgument, MockitoolsBundle.message("inspection.spying.on.mock.is.not.allowed"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.JavaPsiFacade;
Expand Down Expand Up @@ -108,7 +108,7 @@ else if (TEST_ANNOTATIONS.stream().anyMatch(method::hasAnnotation))

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
introduceMockitoMockingCall(fieldToConvert, method, e.getData(PlatformCoreDataKeys.PSI_FILE));
introduceMockitoMockingCall(fieldToConvert, method, e.getData(CommonDataKeys.PSI_FILE));
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/picimako/mockitools/util/PointersUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package com.picimako.mockitools.util;

import static java.util.stream.Collectors.toList;

import com.intellij.psi.PsiElement;
import com.intellij.psi.SmartPointerManager;
import com.intellij.psi.SmartPsiElementPointer;
Expand All @@ -17,7 +15,7 @@
public final class PointersUtil {

public static <T extends PsiElement> List<SmartPsiElementPointer<T>> toPointers(List<T> calls) {
return calls.stream().map(PointersUtil::toPointer).collect(toList());
return calls.stream().map(PointersUtil::toPointer).toList();
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import static com.intellij.openapi.application.ReadAction.compute;
import static com.siyeh.ig.psiutils.MethodCallUtils.getMethodName;
import static java.util.stream.Collectors.toList;

import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
Expand Down Expand Up @@ -228,7 +227,7 @@ public static List<PsiMethodCallExpression> collectCallsInChainFromLast(@NotNull
current = previousCall;
} else break;
}
return calls.stream().map(PsiMethodCallExpression.class::cast).collect(toList());
return calls.stream().map(PsiMethodCallExpression.class::cast).toList();
}

public static List<PsiMethodCallExpression> collectCallsInChainFromFirst(PsiExpression expression, boolean includeMySelf) {
Expand Down

0 comments on commit 00f0845

Please sign in to comment.