forked from phoedos/pmd
new internal ruleset for pmd specific rules that may not apply to
general purpose Java code. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6473 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -12,6 +12,8 @@
|
||||
<exclude-pattern>.*lang/.*/ast/.*.java</exclude-pattern>
|
||||
<exclude-pattern>.*cppast/.*.java</exclude-pattern>
|
||||
|
||||
<rule ref="rulesets/internal/pmdspecific.xml"/>
|
||||
|
||||
<rule ref="rulesets/basic.xml">
|
||||
<exclude name="CollapsibleIfStatements"/>
|
||||
</rule>
|
||||
|
@ -20,6 +20,8 @@
|
||||
EmptyCatchBlock
|
||||
-->
|
||||
|
||||
<rule ref="rulesets/internal/pmdspecific.xml"/>
|
||||
|
||||
<rule ref="rulesets/basic.xml">
|
||||
<exclude name="CollapsibleIfStatements"/>
|
||||
</rule>
|
||||
|
63
pmd/rulesets/internal/pmdspecific.xml
Normal file
63
pmd/rulesets/internal/pmdspecific.xml
Normal file
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="PMD specific rules"
|
||||
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||
<description>These rules check for problems that are specific to the PMD codebase and may not be applicable to other projects.</description>
|
||||
|
||||
<rule name="UseInstanceOftoCompareClasses"
|
||||
language="java" since="5.0"
|
||||
message="replace o.getClass().equals(MyClass.class) with o instanceof MyClass"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule">
|
||||
<description>replace o.getClass().equals(MyClass.class) with o instanceof MyClass. Make sure MyClass doesn't have descendants</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//PrimaryExpression[
|
||||
(PrimaryPrefix[Name[ends-with(@Image, 'getClass')]] or PrimarySuffix[@Image='getClass'])
|
||||
and
|
||||
PrimarySuffix[Arguments[count(ArgumentList)=0]]
|
||||
and
|
||||
PrimarySuffix[@Image='equals']
|
||||
and
|
||||
PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix
|
||||
/ResultType/Type/ReferenceType/ClassOrInterfaceType
|
||||
]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<rule name="ReversedUseInstanceOftoCompareClasses"
|
||||
language="java" since="5.0"
|
||||
message="replace MyClass.class.equals(o.getClass()) with o instanceof MyClass"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule">
|
||||
<description>replace MyClass.class.equals(o.getClass()) with o instanceof MyClass. Make sure MyClass doesn't have descendants</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//PrimaryExpression[
|
||||
PrimaryPrefix[ResultType/Type/ReferenceType/ClassOrInterfaceType]
|
||||
and
|
||||
PrimarySuffix[@Image='equals']
|
||||
and
|
||||
PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression[
|
||||
PrimaryPrefix[Name[ends-with(@Image, 'getClass')]]
|
||||
and
|
||||
PrimarySuffix[Arguments[count(ArgumentList)=0]]
|
||||
]
|
||||
]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
Reference in New Issue
Block a user