Merge branch 'pr/3735' into 7.0.x

This commit is contained in:
Clément Fournier
2022-01-15 17:11:24 +01:00
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

@ -250,7 +250,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;