mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
throwable never thrown: exclude usages as method arguments
This commit is contained in:
+2
@@ -83,6 +83,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection {
|
||||
} else if (parent instanceof PsiReturnStatement) {
|
||||
return;
|
||||
}
|
||||
if (PsiTreeUtil.getParentOfType(parent, PsiCallExpression.class) != null) return;
|
||||
final PsiElement typedParent =
|
||||
PsiTreeUtil.getParentOfType(expression,
|
||||
PsiAssignmentExpression.class,
|
||||
@@ -129,6 +130,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection {
|
||||
} else if (usageParent instanceof PsiReturnStatement) {
|
||||
return;
|
||||
}
|
||||
if (PsiTreeUtil.getParentOfType(usageParent, PsiCallExpression.class) != null) return;
|
||||
}
|
||||
}
|
||||
registerError(expression, expression);
|
||||
|
||||
+13
@@ -1,5 +1,8 @@
|
||||
package com.siyeh.igtest.bugs.throwable_instance_never_thrown;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class ThrowableInstanceNeverThrown {
|
||||
|
||||
void foo() throws Exception {
|
||||
@@ -30,4 +33,14 @@ public class ThrowableInstanceNeverThrown {
|
||||
void leftBehind() throws Throwable {
|
||||
final RuntimeException e = new RuntimeException("throw me");
|
||||
}
|
||||
|
||||
void exceptionIsCollected() {
|
||||
List<IOException> exs = new ArrayList<IOException>();
|
||||
exs.add(new IOException());
|
||||
IOException io2 = new IOException();
|
||||
exs.add(io2);
|
||||
methodCall(io2);
|
||||
}
|
||||
|
||||
void methodCall(IOException e){}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,14 +3,14 @@
|
||||
|
||||
<problem>
|
||||
<file>ThrowableInstanceNeverThrown.java</file>
|
||||
<line>14</line>
|
||||
<line>17</line>
|
||||
<problem_class>Throwable instance not thrown</problem_class>
|
||||
<description>Runtime exception instance <code>new RuntimeException()</code> is not thrown</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ThrowableInstanceNeverThrown.java</file>
|
||||
<line>31</line>
|
||||
<line>34</line>
|
||||
<problem_class>Throwable instance not thrown</problem_class>
|
||||
<description>Runtime exception instance <code>new RuntimeException("throw me")</code> is not thrown</description>
|
||||
</problem>
|
||||
|
||||
Reference in New Issue
Block a user