From 61231a022335e3b6eb9df44ac213ce2aaf5e5482 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 22 Oct 2020 14:00:17 +0200 Subject: [PATCH] inspections: don't check redundant suppressions from inspections with global part (IDEA-208688) local checks may be more pessimistic and it could lead to false positives GitOrigin-RevId: 131000dee73567951cba939949e7abc267019eaf --- .../quickFix/redundantUncheckedVarargs/beforePublicClass.java | 4 ++++ .../daemon/quickFix/RemoveRedundantSuppressionTest.java | 2 ++ .../codeInsight/daemon/impl/LocalInspectionsPass.java | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantUncheckedVarargs/beforePublicClass.java diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantUncheckedVarargs/beforePublicClass.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantUncheckedVarargs/beforePublicClass.java new file mode 100644 index 000000000000..32442ea362b4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantUncheckedVarargs/beforePublicClass.java @@ -0,0 +1,4 @@ +// "Remove 'WeakerAccess' suppression" "false" +@SuppressWarnings("WeakerAccess") +public class beforePublicClass { +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/RemoveRedundantSuppressionTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/RemoveRedundantSuppressionTest.java index fb0fd9ebf43f..5053fda5e8ab 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/RemoveRedundantSuppressionTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/RemoveRedundantSuppressionTest.java @@ -8,6 +8,7 @@ import com.intellij.codeInspection.RedundantLambdaCodeBlockInspection; import com.intellij.codeInspection.RedundantSuppressInspection; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection; +import com.intellij.codeInspection.visibility.VisibilityInspection; import com.intellij.psi.impl.source.tree.injected.MyTestInjector; import com.siyeh.ig.controlflow.FallthruInSwitchStatementInspection; import com.siyeh.ig.inheritance.RefusedBequestInspection; @@ -33,6 +34,7 @@ public class RemoveRedundantSuppressionTest extends LightQuickFixParameterizedTe new FallthruInSwitchStatementInspection(), new UnusedDeclarationInspection(true), new RedundantLambdaCodeBlockInspection(), + new VisibilityInspection(), new AutoBoxingInspection(), new RefusedBequestInspection()); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index e61d598ff641..72d52a65b69a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -222,7 +222,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass } Set activeTools = new HashSet<>(); for (LocalInspectionToolWrapper tool : toolWrappers) { - if (tool.isUnfair() || !tool.isApplicable(fileLanguage)) { + if (tool.isUnfair() || !tool.isApplicable(fileLanguage) || myProfileWrapper.getInspectionTool(tool.getShortName(), myFile) instanceof GlobalInspectionToolWrapper) { continue; } activeTools.add(tool.getID());