Fixing out of dated XPath Query, bug [1874313] Documentation bugs. Thanks to Dave Cronin for the report!

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5756 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Romain Pelisse
2008-02-11 16:44:11 +00:00
parent 4bb7d51339
commit d143732355
2 changed files with 21 additions and 18 deletions

View File

@ -2,6 +2,7 @@
Fixed bug 1843273 - False - on SimplifyBooleanReturns
Fixed bug 1848888 - Fixed false positive in UseEqualsToCompareStrings
Fixed bug 1874313 - Documentation bugs
Fixed bug 1855409 - False + in EmptyMethodInAbstractClassShouldBeAbstract
Fixed other false positives in EmptyMethodInAbstractClassShouldBeAbstract

View File

@ -105,10 +105,12 @@ Writing PMD rules with XPath can be a bit easier than writing rules with Java co
use the Java logging API and we want to find all classes that have more
than one logger. The following expression returns all variable declarations
whose type is 'Logger'. </p>
<source><![CDATA[//VariableDeclarator[../Type/Name[@Image='Logger']]]]></source>
<source><![CDATA[//VariableDeclarator[../Type/ReferenceType/ClassOrInterfaceType[@Image='Log
ger']]]]></source>
<p>Finding a class with more than one logger is quite easy now. This
expression matches the classes we are looking for.</p>
<source><![CDATA[TypeDeclaration[count(//VariableDeclarator[../Type/Name[@Image='Logger']])>1]]]></source>
<source><![CDATA[TypeDeclaration[count(//VariableDeclarator[../Type/ReferenceType/ClassOrInt
erfaceType[@Image='Logger']])>1]]]></source>
<p>But let's refine this expression a little bit more. Consider the
following class:</p>
<source><![CDATA[public class a {
@ -130,7 +132,7 @@ Writing PMD rules with XPath can be a bit easier than writing rules with Java co
<p>With this class we will only be matching one violation, when we
probably would have wanted to produce two violations (one for each class).
The following refined expression matches classes that contain more than one logger.</p>
<source><![CDATA[//ClassBody[count(//VariableDeclarator[../Type/Name[@Image='Logger']])>1]]]></source>
<source><![CDATA[//ClassOrInterfaceBodyDeclaration[count(//VariableDeclarator[../Type/ReferenceType/ClassOrInterfaceType[@Image='Logger']])>1]]]></source>
<p>Let's assume we have a Factory class, that could be always declared final.
We'll search an xpath expression that matches all declarations of Factory
and reports a violation if it is not declared final.