1 /***
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package net.sourceforge.pmd.rules;
5
6 import net.sourceforge.pmd.AbstractRule;
7 import net.sourceforge.pmd.RuleContext;
8 import net.sourceforge.pmd.ast.ASTUnmodifiedClassDeclaration;
9
10 public class ClassNamingConventionsRule extends AbstractRule {
11
12 public Object visit(ASTUnmodifiedClassDeclaration node, Object data) {
13
14 if (Character.isLowerCase(node.getImage().charAt(0))) {
15 RuleContext ctx = (RuleContext)data;
16 ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine(), getMessage()));
17 }
18
19 if (node.getImage().indexOf("_") >= 0) {
20 RuleContext ctx = (RuleContext)data;
21 ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine(), "Class names should not contain underscores"));
22
23 }
24
25 return data;
26 }
27 }
This page was automatically generated by Maven