01 /**
02 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03 */
04 package net.sourceforge.pmd.lang.java.rule.naming;
05
06 import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator;
07 import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
08
09 public class MethodNamingConventionsRule extends AbstractJavaRule {
10
11 public Object visit(ASTMethodDeclarator node, Object data) {
12
13 String methodName = node.getImage();
14
15 if (Character.isUpperCase(methodName.charAt(0))) {
16 addViolationWithMessage(data, node, "Method names should not start with capital letters");
17 }
18 if (methodName.indexOf('_') >= 0) {
19 addViolationWithMessage(data, node, "Method names should not contain underscores");
20 }
21 return data;
22 }
23
24 }
|