From 069cbb6669afbbdb539a2ad16252845f6b1eefcf Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Thu, 25 Jan 2018 13:06:05 +0700 Subject: [PATCH] CatchMayIgnoreException: added option to disable reporting on "ignore(d)" name used Fixes IDEA-185345 "Catch block may ignore exception" settings considerations --- .../src/com/siyeh/InspectionGadgetsBundle.properties | 1 + .../ig/errorhandling/CatchMayIgnoreExceptionInspection.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties index 6e9e503f10eb..570e51173815 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties @@ -2239,6 +2239,7 @@ inspection.type.may.be.weakened.add.stop.class.selection.popup=Select stop class inspection.catch.ignores.exception.display.name=Catch block may ignore exception inspection.catch.ignores.exception.option.comments=Do not warn when 'catch' block contains a comment inspection.catch.ignores.exception.option.nonempty=Do not warn when 'catch' block is not empty +inspection.catch.ignores.exception.option.ignored.used=Do not warn when exception named 'ignore(d)' is not actually ignored inspection.catch.ignores.exception.used.message='catch' parameter named #ref is used #loc inspection.catch.ignores.exception.empty.message=Empty #ref block #loc inspection.catch.ignores.exception.unused.message=Unused 'catch' parameter #ref #loc diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/CatchMayIgnoreExceptionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/CatchMayIgnoreExceptionInspection.java index a3a67488ea37..e4b6fd4fad5c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/CatchMayIgnoreExceptionInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/errorhandling/CatchMayIgnoreExceptionInspection.java @@ -37,6 +37,7 @@ public class CatchMayIgnoreExceptionInspection extends AbstractBaseJavaLocalInsp public boolean m_ignoreCatchBlocksWithComments = true; public boolean m_ignoreNonEmptyCatchBlock = true; + public boolean m_ignoreUsedIgnoredName = false; @Nullable @Override @@ -45,6 +46,7 @@ public class CatchMayIgnoreExceptionInspection extends AbstractBaseJavaLocalInsp panel.addCheckbox(InspectionGadgetsBundle.message("inspection.catch.ignores.exception.option.comments"), "m_ignoreCatchBlocksWithComments"); panel.addCheckbox(InspectionGadgetsBundle.message("inspection.catch.ignores.exception.option.nonempty"), "m_ignoreNonEmptyCatchBlock"); + panel.addCheckbox(InspectionGadgetsBundle.message("inspection.catch.ignores.exception.option.ignored.used"), "m_ignoreUsedIgnoredName"); return panel; } @@ -69,7 +71,7 @@ public class CatchMayIgnoreExceptionInspection extends AbstractBaseJavaLocalInsp final String parameterName = parameter.getName(); if (parameterName == null) return; if (PsiUtil.isIgnoredName(parameterName)) { - if (VariableAccessUtils.variableIsUsed(parameter, section)) { + if (!m_ignoreUsedIgnoredName && VariableAccessUtils.variableIsUsed(parameter, section)) { holder.registerProblem(identifier, InspectionGadgetsBundle.message("inspection.catch.ignores.exception.used.message")); } return;