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.ASTUnmodifiedClassDeclaration;
06:
07: public class ClassNamingConventionsRule extends AbstractRule {
08:
09: public Object visit(ASTUnmodifiedClassDeclaration node, Object data) {
10:
11: if (Character.isLowerCase(node.getImage().charAt(0))) {
12: RuleContext ctx = (RuleContext) data;
13: ctx.getReport().addRuleViolation(
14: createRuleViolation(ctx, node.getBeginLine(),
15: getMessage()));
16: }
17:
18: if (node.getImage().indexOf("_") >= 0) {
19: RuleContext ctx = (RuleContext) data;
20: ctx
21: .getReport()
22: .addRuleViolation(
23: createRuleViolation(ctx, node
24: .getBeginLine(),
25: "Class names should not contain underscores"));
26:
27: }
28:
29: return data;
30: }
31: }
|