From be1ef155436ae41f3c44013aea79e44c74f89900 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Sat, 20 Jul 2002 11:23:57 +0000 Subject: [PATCH] refactoring git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@457 51baf565-9d33-0410-a72c-fc3788e3496d --- .../net/sourceforge/pmd/rules/ForLoopsMustUseBracesRule.java | 4 +--- .../sourceforge/pmd/rules/WhileLoopsMustUseBracesRule.java | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRule.java b/pmd/src/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRule.java index 74a26609e9..a2174bb614 100644 --- a/pmd/src/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/ForLoopsMustUseBracesRule.java @@ -13,15 +13,13 @@ import net.sourceforge.pmd.ast.ASTBlock; import net.sourceforge.pmd.ast.ASTForStatement; public class ForLoopsMustUseBracesRule extends AbstractRule { - private int lineNumberOfLastViolation; public Object visit(ASTForStatement node, Object data) { RuleContext ctx = (RuleContext)data; SimpleNode loopBody = (SimpleNode)node.jjtGetChild(3); - if (!hasBlockAsFirstChild(loopBody) && (node.getBeginLine() != this.lineNumberOfLastViolation)) { + if (!hasBlockAsFirstChild(loopBody)) { ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine())); - lineNumberOfLastViolation = node.getBeginLine(); } return super.visit(node,data); } diff --git a/pmd/src/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRule.java b/pmd/src/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRule.java index 78a9b0f2e7..c3bdadd248 100644 --- a/pmd/src/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/WhileLoopsMustUseBracesRule.java @@ -13,15 +13,13 @@ import net.sourceforge.pmd.ast.ASTBlock; import net.sourceforge.pmd.ast.ASTWhileStatement; public class WhileLoopsMustUseBracesRule extends AbstractRule { - private int lineNumberOfLastViolation; public Object visit(ASTWhileStatement node, Object data) { RuleContext ctx = (RuleContext)data; SimpleNode firstStmt = (SimpleNode)node.jjtGetChild(1); - if (!hasBlockAsFirstChild(firstStmt) && (node.getBeginLine() != this.lineNumberOfLastViolation)) { + if (!hasBlockAsFirstChild(firstStmt)) { ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine())); - lineNumberOfLastViolation = node.getBeginLine(); } return super.visit(node,data); }