View Javadoc
1 package net.sourceforge.pmd.rules; 2 3 import net.sourceforge.pmd.AbstractRule; 4 import net.sourceforge.pmd.RuleContext; 5 import net.sourceforge.pmd.ast.ASTMethodDeclarator; 6 7 public class MethodNamingConventionsRule extends AbstractRule { 8 9 public Object visit(ASTMethodDeclarator node, Object data) { 10 if (Character.isUpperCase(node.getImage().charAt(0))) { 11 RuleContext ctx = (RuleContext)data; 12 ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine(), getMessage())); 13 } 14 15 if (node.getImage().indexOf("_") >= 0) { 16 String msg = "Method names should not contain underscores"; 17 RuleContext ctx = (RuleContext)data; 18 ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine(), msg)); 19 20 } 21 return data; 22 } 23 24 }

This page was automatically generated by Maven