mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-122796 Call to 'printStackTrace()' should warn about overridden calls as well
This commit is contained in:
+2
-2
@@ -16,6 +16,7 @@
|
||||
package com.siyeh.ig.maturity;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.siyeh.HardcodedMethodConstants;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
@@ -69,8 +70,7 @@ public class ThrowablePrintStackTraceInspectionBase extends BaseInspection {
|
||||
if (containingClass == null) {
|
||||
return;
|
||||
}
|
||||
final String name = containingClass.getQualifiedName();
|
||||
if (!CommonClassNames.JAVA_LANG_THROWABLE.equals(name)) {
|
||||
if (!InheritanceUtil.isInheritor(containingClass, false, CommonClassNames.JAVA_LANG_THROWABLE)) {
|
||||
return;
|
||||
}
|
||||
registerMethodCallError(expression, expression);
|
||||
|
||||
+10
@@ -37,6 +37,16 @@ public class ThrowablePrintStackTraceInspectionTest extends LightInspectionTestC
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testPrintStacktraceOverridden() throws Exception {
|
||||
addEnvironmentClass("public class FException extends Exception {\n" +
|
||||
" @Override\n" +
|
||||
" public void printStackTrace() {\n" +
|
||||
" super.printStackTrace();\n" +
|
||||
" }\n" +
|
||||
"}\n");
|
||||
doStatementTest("new FException()./*Call to 'printStackTrace()' should probably be replaced with more robust logging*/printStackTrace/**/();");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new ThrowablePrintStackTraceInspection();
|
||||
|
||||
Reference in New Issue
Block a user