01: package org.acm.seguin.pmd.rules;
02:
03: import org.acm.seguin.pmd.AbstractRule;
04: import org.acm.seguin.pmd.RuleContext;
05: import net.sourceforge.jrefactory.ast.ASTMethodDeclarator;
06:
07: public class MethodNamingConventionsRule extends AbstractRule {
08:
09: public Object visit(ASTMethodDeclarator node, Object data) {
10: if (Character.isUpperCase(node.getImage().charAt(0))) {
11: RuleContext ctx = (RuleContext) data;
12: ctx.getReport().addRuleViolation(
13: createRuleViolation(ctx, node.getBeginLine(),
14: getMessage()));
15: }
16:
17: if (node.getImage().indexOf("_") >= 0) {
18: String msg = "Method names should not contain underscores";
19: RuleContext ctx = (RuleContext) data;
20: ctx.getReport().addRuleViolation(
21: createRuleViolation(ctx, node.getBeginLine(), msg));
22:
23: }
24: return data;
25: }
26:
27: }
|