|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| package net.sourceforge.pmd.rules.design; |
|
5 |
| |
|
6 |
| import net.sourceforge.pmd.ast.SimpleNode; |
|
7 |
| import net.sourceforge.pmd.rules.AbstractInefficientZeroCheck; |
|
8 |
| import net.sourceforge.pmd.symboltable.NameOccurrence; |
|
9 |
| import net.sourceforge.pmd.util.CollectionUtil; |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| public class UseCollectionIsEmpty extends AbstractInefficientZeroCheck { |
|
18 |
| |
|
19 |
11
| public boolean appliesToClassName(String name){
|
|
20 |
11
| return CollectionUtil.isCollectionType(name, true);
|
|
21 |
| } |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
11
| public boolean isTargetMethod(NameOccurrence occ) {
|
|
31 |
11
| if (occ.getNameForWhichThisIsAQualifier() != null) {
|
|
32 |
11
| if (((SimpleNode) occ.getLocation()).getImage().endsWith(".size")) {
|
|
33 |
7
| return true;
|
|
34 |
| } |
|
35 |
| } |
|
36 |
4
| return false;
|
|
37 |
| } |
|
38 |
| } |