KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > rules > MethodNamingConventions


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.ast.ASTMethodDeclarator;
8
9 public class MethodNamingConventions extends AbstractRule {
10
11     public Object JavaDoc visit(ASTMethodDeclarator node, Object JavaDoc data) {
12         
13         String JavaDoc 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 }
25
Popular Tags