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.ASTMethodDeclarator; 9 10 public class MethodNamingConventions extends AbstractRule { 11 12 public Object visit(ASTMethodDeclarator node, Object data) { 13 if (Character.isUpperCase(node.getImage().charAt(0))) { 14 addViolation(data, node); 15 } 16 17 if (node.getImage().indexOf("_") >= 0) { 18 RuleContext ctx = (RuleContext) data; 19 ctx.getReport().addRuleViolation(createRuleViolation(ctx, node, "Method names should not contain underscores")); 20 21 } 22 return data; 23 } 24 25 }