• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pmd / pmd / 23

30 May 2025 04:25PM UTC coverage: 78.377% (-0.2%) from 78.601%
23

push

github

adangel
[core] Add rule to report unnecessary suppression comments/annotations (#5609)

Merge pull request #5609 from oowekyala:new-rule-UnnecessarySuppression

17712 of 23434 branches covered (75.58%)

Branch coverage included in aggregate %.

159 of 328 new or added lines in 22 files covered. (48.48%)

36 existing lines in 4 files now uncovered.

38902 of 48799 relevant lines covered (79.72%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.96
/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexAnnotationSuppressor.java
1
/*
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd.lang.apex;
6

7
import static net.sourceforge.pmd.util.CollectionUtil.listOf;
8

9
import java.util.List;
10

11
import net.sourceforge.pmd.lang.apex.ast.ASTAnnotation;
12
import net.sourceforge.pmd.lang.apex.ast.ASTAnnotationParameter;
13
import net.sourceforge.pmd.lang.apex.ast.ASTModifierNode;
14
import net.sourceforge.pmd.lang.ast.Node;
15
import net.sourceforge.pmd.lang.ast.NodeStream;
16
import net.sourceforge.pmd.reporting.AbstractAnnotationSuppressor;
17
import net.sourceforge.pmd.reporting.ViolationSuppressor;
18

19
/**
20
 * @since 7.14.0
21
 */
22
final class ApexAnnotationSuppressor extends AbstractAnnotationSuppressor<ASTAnnotation> {
23

24
    static final List<ViolationSuppressor> ALL_APEX_SUPPRESSORS = listOf(new ApexAnnotationSuppressor());
1✔
25

26
    private ApexAnnotationSuppressor() {
27
        super(ASTAnnotation.class);
1✔
28
    }
1✔
29

30

31
    @Override
32
    protected NodeStream<ASTAnnotation> getAnnotations(Node node) {
33
        return node.children(ASTModifierNode.class).children(ASTAnnotation.class);
1✔
34
    }
35

36
    @Override
37
    protected boolean walkAnnotation(ASTAnnotation annot, AnnotationWalkCallbacks callbacks) {
38
        if ("SuppressWarnings".equalsIgnoreCase(annot.getName())) {
1✔
39
            for (ASTAnnotationParameter param : annot.children(ASTAnnotationParameter.class)) {
1✔
40
                String image = param.getValue();
1✔
41

42
                if (image != null) {
1!
43
                    for (String part : image.split(",")) {
1✔
44
                        if (callbacks.processNode(param, part)) {
1!
NEW
45
                            return true;
×
46
                        }
47
                    }
48
                }
49
            }
1✔
50
        }
51
        return false;
1✔
52
    }
53

54
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc