[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/InvalidLogMessageFormat"/>
|
||||||
<rule ref="category/java/errorprone.xml/JUnitSpelling"/>
|
<rule ref="category/java/errorprone.xml/JUnitSpelling"/>
|
||||||
<rule ref="category/java/errorprone.xml/JUnitStaticSuite"/>
|
<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/MethodWithSameNameAsEnclosingClass"/> -->
|
||||||
<!-- <rule ref="category/java/errorprone.xml/MisplacedNullCheck"/> -->
|
<!-- <rule ref="category/java/errorprone.xml/MisplacedNullCheck"/> -->
|
||||||
<rule ref="category/java/errorprone.xml/MissingSerialVersionUID"/>
|
<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"
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#jumbledincrementer">
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#jumbledincrementer">
|
||||||
<description>
|
<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>
|
</description>
|
||||||
<priority>3</priority>
|
<priority>3</priority>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="xpath">
|
<property name="xpath">
|
||||||
<value><![CDATA[
|
<value><![CDATA[
|
||||||
//ForStatement
|
//ForStatement
|
||||||
[
|
[ForInit//VariableDeclaratorId/@Name != ForUpdate//VariableAccess/@Name]
|
||||||
ForUpdate/StatementExpressionList/StatementExpression/PostfixExpression/PrimaryExpression/PrimaryPrefix/Name/@Image
|
[ForUpdate//VariableAccess[@AccessType = 'WRITE']/@Name
|
||||||
=
|
=
|
||||||
ancestor::ForStatement/ForInit//VariableDeclaratorId/@Name
|
ancestor::ForStatement/ForInit//VariableDeclaratorId/@Name
|
||||||
]
|
]
|
||||||
]]>
|
]]>
|
||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
|
@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone;
|
|||||||
|
|
||||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||||
|
|
||||||
@org.junit.Ignore("Rule has not been updated yet")
|
|
||||||
public class JumbledIncrementerTest extends PmdRuleTst {
|
public class JumbledIncrementerTest extends PmdRuleTst {
|
||||||
// no additional unit tests
|
// 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">
|
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
|
||||||
|
|
||||||
<test-code>
|
<test-code>
|
||||||
<description>1</description>
|
<description>nested loop, wrong incrementer</description>
|
||||||
<expected-problems>1</expected-problems>
|
<expected-problems>1</expected-problems>
|
||||||
|
<expected-linenumbers>4</expected-linenumbers>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
public class Foo {
|
public class Foo {
|
||||||
void foo() {
|
void foo() {
|
||||||
@ -21,7 +22,7 @@ public class Foo {
|
|||||||
</test-code>
|
</test-code>
|
||||||
|
|
||||||
<test-code>
|
<test-code>
|
||||||
<description>2</description>
|
<description>correct incrementer in nested loop</description>
|
||||||
<expected-problems>0</expected-problems>
|
<expected-problems>0</expected-problems>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
public class Foo {
|
public class Foo {
|
||||||
@ -37,7 +38,7 @@ public class Foo {
|
|||||||
</test-code>
|
</test-code>
|
||||||
|
|
||||||
<test-code>
|
<test-code>
|
||||||
<description>3</description>
|
<description>loops with and without incrementer - all ok</description>
|
||||||
<expected-problems>0</expected-problems>
|
<expected-problems>0</expected-problems>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
public class Foo {
|
public class Foo {
|
||||||
@ -63,7 +64,7 @@ public class Foo {
|
|||||||
</test-code>
|
</test-code>
|
||||||
|
|
||||||
<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>
|
<expected-problems>0</expected-problems>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
public class Foo {
|
public class Foo {
|
||||||
@ -78,8 +79,8 @@ public class Foo {
|
|||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
|
||||||
<!--test-code>
|
<test-code>
|
||||||
<description>1424989, use of variable with same name in inner loop. Wontfix because this is smelly code.</description>
|
<description>1424989, use of variable with same name in inner loop</description>
|
||||||
<expected-problems>0</expected-problems>
|
<expected-problems>0</expected-problems>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
/**
|
/**
|
||||||
@ -96,5 +97,5 @@ public class Foo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code-->
|
</test-code>
|
||||||
</test-data>
|
</test-data>
|
||||||
|
Reference in New Issue
Block a user