forked from phoedos/pmd
Applied patch 1551189 - SingularField false + for initialization blocks from Xavier
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4601 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -5,6 +5,7 @@ SummaryHTML Report changes from Brent Fisher - now contains linePrefix to suppor
|
||||
Fixed bug 1570915 - AvoidRethrowingException no longer reports a false positive for certain nested exceptions.
|
||||
Fixed bug 1571324 - UselessStringValueOf no longer reports a false positive for additive expressions.
|
||||
Fixed CSVRenderer - had flipped line and priority columns
|
||||
Applied patch 1551189 - SingularField false + for initialization blocks
|
||||
|
||||
October 4, 2006 - 3.8:
|
||||
New rules:
|
||||
|
@ -34,6 +34,7 @@ public class SingularFieldRuleTest extends SimpleAggregatorTst {
|
||||
new TestDescriptor(TEST17, "failure, variable accessed twice in same method", 1, rule),
|
||||
new TestDescriptor(TEST18, "failure, static", 1, rule),
|
||||
new TestDescriptor(TEST19, "failure, second method re-uses class level name", 1, rule),
|
||||
new TestDescriptor(TEST20, "initialized in static initialization block", 0, rule),
|
||||
});
|
||||
}
|
||||
|
||||
@ -249,4 +250,17 @@ public class SingularFieldRuleTest extends SimpleAggregatorTst {
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
private static final String TEST20 =
|
||||
"public class Foo {" + PMD.EOL +
|
||||
" private static Foo FOO = new Foo();" + PMD.EOL +
|
||||
" private int x;" + PMD.EOL +
|
||||
" static {" + PMD.EOL +
|
||||
" FOO.x = 5; " + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
" int bar(int y) {" + PMD.EOL +
|
||||
" x = y + 5; " + PMD.EOL +
|
||||
" return x;" + PMD.EOL +
|
||||
" }" + PMD.EOL +
|
||||
"}";
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ package net.sourceforge.pmd.rules;
|
||||
import net.sourceforge.pmd.AbstractRule;
|
||||
import net.sourceforge.pmd.ast.ASTConstructorDeclaration;
|
||||
import net.sourceforge.pmd.ast.ASTFieldDeclaration;
|
||||
import net.sourceforge.pmd.ast.ASTInitializer;
|
||||
import net.sourceforge.pmd.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.ast.ASTVariableDeclaratorId;
|
||||
import net.sourceforge.pmd.ast.SimpleNode;
|
||||
@ -35,7 +36,10 @@ public class SingularField extends AbstractRule {
|
||||
if (method == null) {
|
||||
method = (SimpleNode) location.getFirstParentOfType(ASTConstructorDeclaration.class);
|
||||
if (method == null) {
|
||||
continue;
|
||||
method = (SimpleNode) location.getFirstParentOfType(ASTInitializer.class);
|
||||
if (method == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
</subsection>
|
||||
<subsection name="Contributors">
|
||||
<ul>
|
||||
<li>Xavier Le Vourch - Fix to AvoidRethrowingException, fixed bug in EqualsNull, wrote UselessStringValueOf, wrote UnnecessaryWrapperObjectCreation, patch to fix AvoidRethrowingException, patch to fix MissingStaticMethodInNonInstantiatableClass, patch to fix speling in CouplingBetweenObjects message, patch to improve CloneMethodMustImplementCloneable, suggestions on cleaning up casts in grammar, SimplifyBooleanAssertion, patch to fix problem with TestClassWithoutTestCases, patch to fix rule name bugs in migration rulesets</li>
|
||||
<li>Xavier Le Vourch - Fix to AvoidRethrowingException, fixed bug in EqualsNull, wrote UselessStringValueOf, wrote UnnecessaryWrapperObjectCreation, patch to fix AvoidRethrowingException, patch to fix MissingStaticMethodInNonInstantiatableClass, patch to fix speling in CouplingBetweenObjects message, patch to improve CloneMethodMustImplementCloneable, suggestions on cleaning up casts in grammar, SimplifyBooleanAssertion, patch to fix problem with TestClassWithoutTestCases, patch to fix rule name bugs in migration rulesets, fix to SingularField</li>
|
||||
<li>Brent Fisher - SummaryHTML report improvements</li>
|
||||
<li>Jason Bennett - Patches to improve CyclomaticComplexity rule</li>
|
||||
<li>George Thomas - Wrote AvoidRethrowingException rule</li>
|
||||
|
Reference in New Issue
Block a user