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

pmd / pmd / 130

06 Sep 2025 12:33PM UTC coverage: 78.533% (+0.04%) from 78.498%
130

push

github

oowekyala
Fix #4770: [java] UnusedFormalParameter should ignore public constructor as same as method (#5994)

Merge branch 'issue-4770-UnusedFormalParameter-should-ignore-public-constructor-as-same-as-method'

17953 of 23697 branches covered (75.76%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 2 files covered. (100.0%)

27 existing lines in 6 files now uncovered.

39280 of 49181 relevant lines covered (79.87%)

0.81 hits per line

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

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

5
package net.sourceforge.pmd.lang.java.types;
6

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

9
import java.lang.reflect.Modifier;
10
import java.util.Collections;
11
import java.util.List;
12
import java.util.Objects;
13

14
import org.checkerframework.checker.nullness.qual.NonNull;
15
import org.checkerframework.checker.nullness.qual.Nullable;
16
import org.objectweb.asm.Opcodes;
17

18
import net.sourceforge.pmd.lang.java.symbols.JClassSymbol;
19
import net.sourceforge.pmd.lang.java.symbols.JConstructorSymbol;
20
import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol;
21
import net.sourceforge.pmd.lang.java.symbols.JFieldSymbol;
22
import net.sourceforge.pmd.lang.java.symbols.JMethodSymbol;
23
import net.sourceforge.pmd.lang.java.symbols.JTypeDeclSymbol;
24
import net.sourceforge.pmd.lang.java.symbols.SymbolVisitor;
25
import net.sourceforge.pmd.lang.java.symbols.internal.ImplicitMemberSymbols;
26
import net.sourceforge.pmd.lang.java.symbols.internal.SymbolEquality;
27
import net.sourceforge.pmd.lang.java.symbols.internal.SymbolToStrings;
28

29
/**
30
 * Generic implementation for array symbols, which does not rely on
31
 * reflection.
32
 */
33
class ArraySymbolImpl implements JClassSymbol {
34

35
    // Like Class::getModifiers, we preserve the public/private/protected flag
36
    private static final int COMPONENT_MOD_MASK =
37
        Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_PUBLIC;
38

39
    private final TypeSystem ts;
40
    private final JTypeDeclSymbol component;
41

42
    ArraySymbolImpl(TypeSystem ts, JTypeDeclSymbol component) {
1✔
43
        this.component = Objects.requireNonNull(component, "Array symbol requires component");
1✔
44
        this.ts = Objects.requireNonNull(ts, "Array symbol requires symbol factory");
1✔
45
        if (component instanceof JClassSymbol && ((JClassSymbol) component).isAnonymousClass()) {
1!
46
            throw new IllegalArgumentException("Anonymous classes cannot be array components: " + component);
×
47
        }
48
    }
1✔
49

50
    @Override
51
    public TypeSystem getTypeSystem() {
52
        return ts;
1✔
53
    }
54

55
    @Override
56
    public @NonNull String getBinaryName() {
57
        if (component instanceof JClassSymbol) {
1✔
58
            return ((JClassSymbol) component).getBinaryName() + "[]";
1✔
59
        }
60
        return component.getSimpleName() + "[]";
1✔
61
    }
62

63
    @Override
64
    public String getCanonicalName() {
65
        if (component instanceof JClassSymbol) {
1✔
66
            String compName = ((JClassSymbol) component).getCanonicalName();
1✔
67
            return compName == null ? null : compName + "[]";
1!
68
        }
69
        return component.getSimpleName() + "[]";
1✔
70
    }
71

72
    @Override
73
    public boolean isUnresolved() {
74
        return false;
1✔
75
    }
76

77
    @Override
78
    public @Nullable JExecutableSymbol getEnclosingMethod() {
79
        return null;
×
80
    }
81

82
    @Override
83
    public List<JMethodSymbol> getDeclaredMethods() {
84
        return Collections.singletonList(ImplicitMemberSymbols.arrayClone(this));
1✔
85
    }
86

87
    @Override
88
    public List<JFieldSymbol> getDeclaredFields() {
89
        return Collections.singletonList(ImplicitMemberSymbols.arrayLengthField(this));
1✔
90
    }
91

92
    @Override
93
    public @Nullable JClassSymbol getSuperclass() {
UNCOV
94
        return getTypeSystem().OBJECT.getSymbol();
×
95
    }
96

97
    @Override
98
    public List<JClassSymbol> getSuperInterfaces() {
99
        return listOf(getTypeSystem().CLONEABLE.getSymbol(), getTypeSystem().SERIALIZABLE.getSymbol());
1✔
100
    }
101

102
    @Override
103
    public List<JClassType> getSuperInterfaceTypes(Substitution substitution) {
104
        return listOf(getTypeSystem().CLONEABLE, getTypeSystem().SERIALIZABLE);
×
105
    }
106

107
    @Override
108
    public @Nullable JClassType getSuperclassType(Substitution substitution) {
109
        return getTypeSystem().OBJECT;
×
110
    }
111

112
    @Override
113
    public @NonNull JTypeDeclSymbol getArrayComponent() {
114
        return component;
1✔
115
    }
116

117
    @Override
118
    public <R, P> R acceptVisitor(SymbolVisitor<R, P> visitor, P param) {
119
        return visitor.visitArray(this, component, param);
1✔
120
    }
121

122
    @Override
123
    public boolean equals(Object o) {
124
        return SymbolEquality.equals(this, o);
1✔
125
    }
126

127
    @Override
128
    public int hashCode() {
129
        return SymbolEquality.hash(this);
1✔
130
    }
131

132
    @Override
133
    public boolean isAnnotation() {
134
        return false;
1✔
135
    }
136

137
    @Override
138
    public List<JClassSymbol> getDeclaredClasses() {
139
        return Collections.emptyList();
×
140
    }
141

142
    @Override
143
    public List<JConstructorSymbol> getConstructors() {
144
        return Collections.singletonList(ImplicitMemberSymbols.arrayConstructor(this));
1✔
145
    }
146

147
    @Override
148
    @NonNull
149
    public String getPackageName() {
150
        return getArrayComponent().getPackageName();
1✔
151
    }
152

153
    @Override
154
    @NonNull
155
    public String getSimpleName() {
156
        return getArrayComponent().getSimpleName() + "[]";
1✔
157
    }
158

159
    @Override
160
    public int getModifiers() {
161
        int comp = getArrayComponent().getModifiers() & COMPONENT_MOD_MASK;
1✔
162
        return Modifier.FINAL | Modifier.ABSTRACT | comp;
1✔
163
    }
164

165
    @Override
166
    public List<JTypeVar> getTypeParameters() {
167
        return Collections.emptyList();
1✔
168
    }
169

170
    @Override
171
    @Nullable
172
    public JClassSymbol getEnclosingClass() {
173
        return null;
×
174
    }
175

176
    @Override
177
    public boolean isArray() {
178
        return true;
1✔
179
    }
180

181
    @Override
182
    public boolean isPrimitive() {
183
        return false;
×
184
    }
185

186
    @Override
187
    public boolean isInterface() {
188
        return false;
1✔
189
    }
190

191
    @Override
192
    public boolean isEnum() {
193
        return false;
×
194
    }
195

196
    @Override
197
    public boolean isRecord() {
198
        return false;
×
199
    }
200

201
    @Override
202
    public boolean isLocalClass() {
203
        return false;
×
204
    }
205

206
    @Override
207
    public boolean isAnonymousClass() {
208
        return false;
1✔
209
    }
210

211
    @Override
212
    public String toString() {
213
        return SymbolToStrings.SHARED.toString(this);
1✔
214
    }
215

216
}
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