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

pmd / pmd / 380

29 Jan 2026 03:55PM UTC coverage: 78.964%. Remained the same
380

push

github

adangel
[doc] ADR 3: Clarify javadoc tags (#6392)

18537 of 24358 branches covered (76.1%)

Branch coverage included in aggregate %.

40391 of 50268 relevant lines covered (80.35%)

0.81 hits per line

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

0.0
/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/impl/UnnecessaryPmdSuppressionRule.java
1
/*
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd.lang.rule.impl;
6

7
import java.util.List;
8
import java.util.Set;
9

10
import net.sourceforge.pmd.annotation.Experimental;
11
import net.sourceforge.pmd.lang.LanguageVersionHandler;
12
import net.sourceforge.pmd.lang.ast.Node;
13
import net.sourceforge.pmd.lang.ast.RootNode;
14
import net.sourceforge.pmd.lang.rule.AbstractRule;
15
import net.sourceforge.pmd.lang.rule.internal.RuleSets;
16
import net.sourceforge.pmd.reporting.InternalApiBridge;
17
import net.sourceforge.pmd.reporting.RuleContext;
18
import net.sourceforge.pmd.reporting.ViolationSuppressor;
19
import net.sourceforge.pmd.reporting.ViolationSuppressor.UnusedSuppressorNode;
20
import net.sourceforge.pmd.util.CollectionUtil;
21

22
/**
23
 * A rule that reports unused suppression annotations and comments.
24
 * This rule class supports any PMD language, but language-specific behavior
25
 * needs to be implemented to avoid false positives for some languages.
26
 * Violations of this rule cannot be suppressed. It is special cased
27
 * by {@link RuleSets} to execute after all other rules, so that whether
28
 * those produce warnings or not is known to this rule.
29
 *
30
 * @since 7.14.0
31
 * @experimental See <a href="https://github.com/pmd/pmd/pull/5609">[core] Add rule to report unnecessary suppression comments/annotations #5609</a>
32
 */
33
@Experimental
×
34
public class UnnecessaryPmdSuppressionRule extends AbstractRule {
×
35

36
    @Override
37
    public void apply(Node rootNode, RuleContext ctx) {
38
        assert rootNode instanceof RootNode;
×
39

40
        LanguageVersionHandler handler = rootNode.getAstInfo().getLanguageProcessor().services();
×
41
        List<ViolationSuppressor> suppressors = CollectionUtil.concatView(
×
42
            handler.getExtraViolationSuppressors(),
×
43
            InternalApiBridge.DEFAULT_SUPPRESSORS
44
        );
45

46
        for (ViolationSuppressor suppressor : suppressors) {
×
47
            Set<UnusedSuppressorNode> unusedSuppressors = suppressor.getUnusedSuppressors((RootNode) rootNode);
×
48
            for (UnusedSuppressorNode unusedSuppressor : unusedSuppressors) {
×
49
                ctx.addViolationNoSuppress(
×
50
                    unusedSuppressor.getLocation(),
×
51
                    rootNode.getAstInfo(),
×
52
                    unusedSuppressor.unusedReason()
×
53
                );
54
            }
×
55
        }
×
56
    }
×
57

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

© 2026 Coveralls, Inc