Skip to content

Commit

Permalink
Fixes pmd#1021
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatbahety committed May 14, 2018
1 parent 863083d commit 958fd34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pmd-java/src/main/resources/category/java/design.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 958fd34

Please sign in to comment.