This commit is contained in:
Akshat Bahety
2018-05-14 19:45:41 +05:30
committed by Akshat Bahety
parent 863083d1a8
commit 958fd34c0f
2 changed files with 18 additions and 1 deletions

View File

@ -488,6 +488,7 @@ public class DataClass {
<rule name="DoNotExtendJavaLangError"
language="java"
typeResolution="true"
since="4.0"
message="Exceptions should not extend java.lang.Error"
class="net.sourceforge.pmd.lang.rule.XPathRule"
@ -501,7 +502,9 @@ Errors are system exceptions. Do not extend them.
<value>
<![CDATA[
//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
[@Image="Error" or @Image="java.lang.Error"]
[typeof(@Image,'java.lang.Error','Error')]
]]>
</value>
</property>

View File

@ -33,4 +33,18 @@ public class Foo extends FooError {
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
Extends name Error
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import net.sourceforge.pmd.lang.java.rule.design.donotextendjavalangerror.Error;
public class Foo extends Error {
}
]]></code>
</test-code>
</test-data>