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

pmd / pmd / 19

29 May 2025 04:22PM UTC coverage: 77.723% (-0.03%) from 77.757%
19

push

github

adangel
Fix #5621: [java] Fix FPs with UnusedPrivateMethod (#5727)

Merge pull request #5727 from oowekyala:issue5621-unusedprivatemethod

17705 of 23734 branches covered (74.6%)

Branch coverage included in aggregate %.

50 of 52 new or added lines in 9 files covered. (96.15%)

81 existing lines in 6 files now uncovered.

38845 of 49024 relevant lines covered (79.24%)

0.8 hits per line

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

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

5

6
package net.sourceforge.pmd.lang.java.ast;
7

8
import java.util.Objects;
9

10
import org.checkerframework.checker.nullness.qual.NonNull;
11

12
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
13
import net.sourceforge.pmd.lang.document.FileLocation;
14
import net.sourceforge.pmd.lang.java.symbols.JConstructorSymbol;
15

16
/**
17
 * This defines a compact constructor for a {@linkplain ASTRecordDeclaration RecordDeclaration} (JDK 16 feature).
18
 * Compact constructors implicitly declares formal parameters corresponding to the record component list. These can be
19
 * fetched from {@link #getSymbol()}.
20
 *
21
 * <p>Compact record constructors must be declared "public".
22
 *
23
 * <pre class="grammar">
24
 *
25
 * CompactConstructorDeclaration ::=  {@link ASTModifierList Modifiers}
26
 *                                   &lt;IDENTIFIER&gt;
27
 *                                   {@link ASTBlock Block}
28
 *
29
 * </pre>
30
 */
31
// TODO make implicit formal parameter node and implement ASTExecutableDeclaration.
32
// This might help UnusedAssignmentRule / DataflowPass.ReachingDefsVisitor, see also #4603
33
public final class ASTCompactConstructorDeclaration extends AbstractJavaNode implements ASTBodyDeclaration, SymbolDeclaratorNode, ModifierOwner, JavadocCommentOwner, ReturnScopeNode {
34

35
    private JavaccToken identToken;
36

37
    ASTCompactConstructorDeclaration(int id) {
38
        super(id);
1✔
39
    }
1✔
40

41

42
    @Override
43
    public FileLocation getReportLocation() {
UNCOV
44
        return identToken.getReportLocation();
×
45
    }
46

47
    void setIdentToken(JavaccToken identToken) {
48
        this.identToken = identToken;
1✔
49
    }
1✔
50

51
    @Override
52
    public String getImage() {
53
        return identToken.getImage();
1✔
54
    }
55

56
    @Override
57
    protected <P, R> R acceptVisitor(JavaVisitor<? super P, ? extends R> visitor, P data) {
58
        return visitor.visit(this, data);
1✔
59
    }
60

61
    @Override
62
    public @NonNull ASTBlock getBody() {
63
        return Objects.requireNonNull(firstChild(ASTBlock.class));
1✔
64
    }
65

66
    /**
67
     * @deprecated Since 7.14.0. This method just returns `this` and isn't useful.
68
     */
69
    @Deprecated
70
    public ASTCompactConstructorDeclaration getDeclarationNode() {
UNCOV
71
        return this;
×
72
    }
73

74
    @Override
75
    public ASTRecordDeclaration getEnclosingType() {
76
        return (ASTRecordDeclaration) super.getEnclosingType();
1✔
77
    }
78

79
    @Override
80
    public JConstructorSymbol getSymbol() {
81
        return getEnclosingType().getRecordComponents().getSymbol();
1✔
82
    }
83
}
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