This commit is contained in:
Clément Fournier
2018-11-02 09:09:13 +01:00
parent 117e9a4277
commit e1b5717675
2 changed files with 27 additions and 2 deletions

View File

@ -1950,7 +1950,9 @@ public class Foo {
message="Useless qualified this usage in the same class."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#uselessqualifiedthis">
<description>Look for qualified this usages in the same class.</description>
<description>
Reports qualified this usages in the same class.
</description>
<priority>3</priority>
<properties>
<property name="xpath">
@ -1958,7 +1960,7 @@ public class Foo {
<![CDATA[
//PrimaryExpression
[PrimaryPrefix/Name[@Image]]
[PrimarySuffix[@Arguments='false']]
[PrimarySuffix[@Arguments='false' and @ArrayDereference = 'false']]
[not(PrimarySuffix/MemberSelector)]
[ancestor::ClassOrInterfaceBodyDeclaration[1][@AnonymousInnerClass='false']]
/PrimaryPrefix/Name[@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image]

View File

@ -152,4 +152,27 @@ public class ApiExceptionCtrlAdvice {
}
]]></code>
</test-code>
<test-code>
<description>False positive for UselessQualifiedThis #1372</description>
<expected-problems>0</expected-problems>
<code>
<![CDATA[
public class Board {
private int[] Board;
public Board(int[] b) {
for (int i = 0; i < b.length; i++)
Board[i] = b[i];
}
public int size() {
return Board.length;
}
}
]]>
</code>
</test-code>
</test-data>