1 |
| |
2 |
| |
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 |
3
| public Object visit(ASTMethodDeclarator node, Object data) {
|
12 |
3
| if (Character.isUpperCase(node.getImage().charAt(0))) {
|
13 |
1
| addViolation(data, node);
|
14 |
| } |
15 |
3
| if (node.getImage().indexOf("_") >= 0) {
|
16 |
1
| addViolationWithMessage(data, node, "Method names should not contain underscores");
|
17 |
| } |
18 |
3
| return data;
|
19 |
| } |
20 |
| |
21 |
| } |