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