[java] Update rule AvoidThrowingRawExceptionTypes

This commit is contained in:
Andreas Dangel
2022-01-14 17:00:13 +01:00
parent e273ca641f
commit fca93a29c9
4 changed files with 4 additions and 3 deletions

View File

@@ -124,7 +124,7 @@
<rule ref="category/java/design.xml/AvoidRethrowingException"/>
<!-- <rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/> -->
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException"/>
<!-- <rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes"/> -->
<rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes"/>
<rule ref="category/java/design.xml/AvoidUncheckedExceptionsInSignatures"/>
<rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal"/>
<rule ref="category/java/design.xml/CognitiveComplexity" />

View File

@@ -254,7 +254,7 @@ Exception, or Error, use a subclassed exception or error instead.
<property name="xpath">
<value>
<![CDATA[
//ThrowStatement//AllocationExpression
//ThrowStatement//ConstructorCall
/ClassOrInterfaceType[
pmd-java:typeIsExactly('java.lang.Throwable')
or

View File

@@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.design;
import net.sourceforge.pmd.testframework.PmdRuleTst;
@org.junit.Ignore("Rule has not been updated yet")
public class AvoidThrowingRawExceptionTypesTest extends PmdRuleTst {
public static class Throwable extends java.lang.Throwable {
private static final long serialVersionUID = 1798165250043760600L;

View File

@@ -7,6 +7,7 @@
<test-code>
<description>throwing various types</description>
<expected-problems>4</expected-problems>
<expected-linenumbers>3,4,5,6</expected-linenumbers>
<code><![CDATA[
public class Foo {
void bar() {
@@ -57,6 +58,7 @@ public class PmdTest {
<test-code>
<description>False negative when importing another exception</description>
<expected-problems>1</expected-problems>
<expected-linenumbers>6</expected-linenumbers>
<code><![CDATA[
import java.io.IOException;