Fixed bug in IfStmtsMustUseBracesRule; thx to Michael Sutherland for the report

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1499 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2003-03-04 15:20:34 +00:00
parent 7679751649
commit 49b351ef27
8 changed files with 18 additions and 7 deletions

View File

@ -2,6 +2,7 @@
Added new rules: ConstructorCallsOverridableMethodRule, AtLeastOneConstructorRule, JUnitAssertionsShouldIncludeMessageRule, DoubleCheckedLockingRule, ExcessivePublicCountRule
The Ant task has been updated; if you set "verbose=true" full stacktraces are printed. Thx to Paul Roebuck for the suggestion.
Moved JUnit rules into their own package - "net.sourceforge.pmd.rules.junit".
Fixed bug 697187 - Problem with nested ifs
February 11, 2003 - 1.03
Added new rules: CyclomaticComplexityRule, AssignmentInOperandRule

View File

@ -28,6 +28,5 @@ public class EmptyCatchBlockRuleTest extends RuleTst {
public void testEmptyTryAndFinally() throws Throwable {
runTest("EmptyCatchBlock5.java", 0, new EmptyCatchBlockRule());
}
}

View File

@ -9,12 +9,15 @@ import net.sourceforge.pmd.rules.IfStmtsMustUseBracesRule;
public class IfStmtsMustUseBracesRuleTest extends RuleTst {
public void test1() throws Throwable {
public void testSimpleBad() throws Throwable {
runTest("IfStmtsMustUseBraces1.java", 1, new IfStmtsMustUseBracesRule());
}
public void test2() throws Throwable {
public void testSimpleOK() throws Throwable {
runTest("IfStmtsMustUseBraces2.java", 0, new IfStmtsMustUseBracesRule());
}
public void testNexted() throws Throwable {
runTest("IfStmtsMustUseBraces3.java", 1, new IfStmtsMustUseBracesRule());
}
}

View File

@ -32,7 +32,7 @@ import java.util.List;
public class PMD {
/**
* @param reader - an InputStream to the Java code to analyse
* @param reader - a Reader to the Java code to analyse
* @param ruleSet - the set of rules to process against the file
* @param ctx - the context in which PMD is operating. This contains the Renderer and whatnot
*/

View File

@ -34,6 +34,6 @@ public class IfStmtsMustUseBracesRule extends BracesRule {
lineNumberOfLastViolation = node.getBeginLine();
}
return null;
return super.visit(node, data);
}
}

View File

@ -1,4 +1,4 @@
public class IfStmtsMustUseBraces2 {
public class IfStmtsMustUseBraces3 {
public void foo() {
if (true) {
int x=2;

View File

@ -0,0 +1,7 @@
public class IfStmtsMustUseBraces3 {
public void foo() {
if (true) {
if (true) bar();
}
}
}

View File

@ -10,6 +10,7 @@
<section name="Credits">
<subsection name="Individuals">
<ul>
<li>Michael Sutherland - bug report</li>
<li>Andrew Glover - ExcessivePublicCountRule, CouplingBetweenObjectsRule, ExcessiveImportsRule, documentation tweaks</li>
<li>Egon Willighagen - pmd-web suggestion</li>
<li>Carl Gilbert - DoubleCheckedLockingRule, ConstructorCallsOverridableMethodRule, bug reports, feature requests, and documentation improvements</li>