diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index 8b152b8c8d..e7cc9bf81d 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -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 diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java index 9bf0d97e1d..d498daa4da 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/EmptyCatchBlockRuleTest.java @@ -28,6 +28,5 @@ public class EmptyCatchBlockRuleTest extends RuleTst { public void testEmptyTryAndFinally() throws Throwable { runTest("EmptyCatchBlock5.java", 0, new EmptyCatchBlockRule()); } - } diff --git a/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java b/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java index 67e6d3a9a5..d9cd699b9c 100644 --- a/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java +++ b/pmd/regress/test/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRuleTest.java @@ -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()); + } } diff --git a/pmd/src/net/sourceforge/pmd/PMD.java b/pmd/src/net/sourceforge/pmd/PMD.java index eb10877571..bdf7ae3b53 100644 --- a/pmd/src/net/sourceforge/pmd/PMD.java +++ b/pmd/src/net/sourceforge/pmd/PMD.java @@ -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 */ diff --git a/pmd/src/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRule.java b/pmd/src/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRule.java index 4e1fe48a94..540a514468 100644 --- a/pmd/src/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/IfStmtsMustUseBracesRule.java @@ -34,6 +34,6 @@ public class IfStmtsMustUseBracesRule extends BracesRule { lineNumberOfLastViolation = node.getBeginLine(); } - return null; + return super.visit(node, data); } } diff --git a/pmd/test-data/IfStmtsMustUseBraces2.java b/pmd/test-data/IfStmtsMustUseBraces2.java index 2da6cd0a24..804889874f 100644 --- a/pmd/test-data/IfStmtsMustUseBraces2.java +++ b/pmd/test-data/IfStmtsMustUseBraces2.java @@ -1,4 +1,4 @@ -public class IfStmtsMustUseBraces2 { +public class IfStmtsMustUseBraces3 { public void foo() { if (true) { int x=2; diff --git a/pmd/test-data/IfStmtsMustUseBraces3.java b/pmd/test-data/IfStmtsMustUseBraces3.java new file mode 100644 index 0000000000..559c08e638 --- /dev/null +++ b/pmd/test-data/IfStmtsMustUseBraces3.java @@ -0,0 +1,7 @@ +public class IfStmtsMustUseBraces3 { + public void foo() { + if (true) { + if (true) bar(); + } + } +} \ No newline at end of file diff --git a/pmd/xdocs/credits.xml b/pmd/xdocs/credits.xml index f481996f10..08e76643a5 100644 --- a/pmd/xdocs/credits.xml +++ b/pmd/xdocs/credits.xml @@ -10,6 +10,7 @@