[java] Update rule JumbledIncrementer
This commit is contained in:
@ -232,7 +232,7 @@
|
||||
<rule ref="category/java/errorprone.xml/InvalidLogMessageFormat"/>
|
||||
<rule ref="category/java/errorprone.xml/JUnitSpelling"/>
|
||||
<rule ref="category/java/errorprone.xml/JUnitStaticSuite"/>
|
||||
<!-- <rule ref="category/java/errorprone.xml/JumbledIncrementer"/> -->
|
||||
<rule ref="category/java/errorprone.xml/JumbledIncrementer"/>
|
||||
<!-- <rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass"/> -->
|
||||
<!-- <rule ref="category/java/errorprone.xml/MisplacedNullCheck"/> -->
|
||||
<rule ref="category/java/errorprone.xml/MissingSerialVersionUID"/>
|
||||
|
@ -2108,18 +2108,18 @@ LOGGER.error("param {}", "arg1", new IllegalStateException("arg")); //The except
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#jumbledincrementer">
|
||||
<description>
|
||||
Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
|
||||
Avoid jumbled loop incrementers - it's usually a mistake, and is confusing even if intentional.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value><![CDATA[
|
||||
//ForStatement
|
||||
[
|
||||
ForUpdate/StatementExpressionList/StatementExpression/PostfixExpression/PrimaryExpression/PrimaryPrefix/Name/@Image
|
||||
=
|
||||
ancestor::ForStatement/ForInit//VariableDeclaratorId/@Name
|
||||
]
|
||||
[ForInit//VariableDeclaratorId/@Name != ForUpdate//VariableAccess/@Name]
|
||||
[ForUpdate//VariableAccess[@AccessType = 'WRITE']/@Name
|
||||
=
|
||||
ancestor::ForStatement/ForInit//VariableDeclaratorId/@Name
|
||||
]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
@org.junit.Ignore("Rule has not been updated yet")
|
||||
public class JumbledIncrementerTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -5,8 +5,9 @@
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
|
||||
|
||||
<test-code>
|
||||
<description>1</description>
|
||||
<description>nested loop, wrong incrementer</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>4</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
void foo() {
|
||||
@ -21,7 +22,7 @@ public class Foo {
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>2</description>
|
||||
<description>correct incrementer in nested loop</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
@ -37,7 +38,7 @@ public class Foo {
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>3</description>
|
||||
<description>loops with and without incrementer - all ok</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
@ -63,7 +64,7 @@ public class Foo {
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>using outer loop incrementor as array index is OK</description>
|
||||
<description>using outer loop incrementer as array index is OK</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
@ -78,8 +79,8 @@ public class Foo {
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<!--test-code>
|
||||
<description>1424989, use of variable with same name in inner loop. Wontfix because this is smelly code.</description>
|
||||
<test-code>
|
||||
<description>1424989, use of variable with same name in inner loop</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
/**
|
||||
@ -96,5 +97,5 @@ public class Foo {
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code-->
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user