forked from phoedos/pmd
Bug fix: state info in BooleanInstantiation rule needs to be reset for each file
(stress test on jdk src wasn't giving consistent results depending on which thread was processing files as each thread has a different set of Rule objects) git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5596 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -144,6 +144,17 @@ public class Foo {
|
||||
public void Bar() {
|
||||
Boolean b = new Boolean("true");
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Test for failure after rule with custom Boolean, should report failure if rule reset done correctly
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
Boolean b = Boolean.valueOf("true");
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
@ -5,6 +5,7 @@ import net.sourceforge.pmd.ast.ASTAllocationExpression;
|
||||
import net.sourceforge.pmd.ast.ASTArrayDimsAndInits;
|
||||
import net.sourceforge.pmd.ast.ASTBooleanLiteral;
|
||||
import net.sourceforge.pmd.ast.ASTClassOrInterfaceType;
|
||||
import net.sourceforge.pmd.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.ast.ASTImportDeclaration;
|
||||
import net.sourceforge.pmd.ast.ASTLiteral;
|
||||
import net.sourceforge.pmd.ast.ASTName;
|
||||
@ -34,8 +35,11 @@ public class BooleanInstantiation extends AbstractRule {
|
||||
*/
|
||||
private boolean customBoolean;
|
||||
|
||||
public BooleanInstantiation() {
|
||||
public Object visit(ASTCompilationUnit decl,Object data) {
|
||||
// customBoolean needs to be reset for each new file
|
||||
customBoolean = false;
|
||||
|
||||
return super.visit(decl, data);
|
||||
}
|
||||
|
||||
public Object visit(ASTImportDeclaration decl,Object data) {
|
||||
|
Reference in New Issue
Block a user