refactoring

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@457 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-07-20 11:23:57 +00:00
parent 328b4089d5
commit be1ef15543
2 changed files with 2 additions and 6 deletions

@ -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);
}

@ -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);
}