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

pmd / pmd / #3722

pending completion
#3722

push

github actions

adangel
Suppress MissingOverride for Chars::isEmpty (#4291)

67270 of 127658 relevant lines covered (52.7%)

0.53 hits per line

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

53.85
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ArrayMethodSigImpl.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 java.util.Collections.emptyList;
8

9
import java.util.Collections;
10
import java.util.List;
11
import java.util.Objects;
12
import java.util.function.Function;
13

14
import org.checkerframework.checker.nullness.qual.NonNull;
15
import org.checkerframework.checker.nullness.qual.Nullable;
16

17
import net.sourceforge.pmd.lang.java.symbols.JConstructorSymbol;
18
import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol;
19
import net.sourceforge.pmd.lang.java.types.internal.InternalMethodTypeItf;
20

21
// for array clone or array constructor
22
class ArrayMethodSigImpl implements JMethodSig, InternalMethodTypeItf {
23

24

25
    private final JArrayType owner;
26
    // either method or constructor
27
    private final JExecutableSymbol symbol;
28

29
    ArrayMethodSigImpl(JArrayType owner,
30
                       @NonNull JExecutableSymbol symbol) {
1✔
31
        this.owner = owner;
1✔
32
        this.symbol = symbol;
1✔
33
    }
1✔
34

35
    @Override
36
    public TypeSystem getTypeSystem() {
37
        return owner.getTypeSystem();
1✔
38
    }
39

40
    @Override
41
    public JExecutableSymbol getSymbol() {
42
        return symbol;
1✔
43
    }
44

45
    @Override
46
    public JArrayType getDeclaringType() {
47
        return owner;
1✔
48
    }
49

50
    @Override
51
    public JMethodSig getErasure() {
52
        JArrayType erasedOwner = owner.getErasure();
×
53
        return erasedOwner == owner ? this : new ArrayMethodSigImpl(erasedOwner, symbol); // NOPMD CompareObjectsWithEquals
×
54
    }
55

56
    @Override
57
    public JTypeMirror getAnnotatedReceiverType() {
58
        return owner;
×
59
    }
60

61
    @Override
62
    public JTypeMirror getReturnType() {
63
        return owner; // clone or cons
1✔
64
    }
65

66
    @Override
67
    public List<JTypeMirror> getFormalParameters() {
68
        if (getSymbol() instanceof JConstructorSymbol) {
1✔
69
            return Collections.singletonList(owner.getTypeSystem().INT);
1✔
70
        }
71
        return emptyList();
1✔
72
    }
73

74

75
    @Override
76
    public List<JTypeVar> getTypeParameters() {
77
        return emptyList();
1✔
78
    }
79

80
    @Override
81
    public List<JTypeMirror> getThrownExceptions() {
82
        return emptyList();
1✔
83
    }
84

85
    @Override
86
    public InternalMethodTypeItf internalApi() {
87
        return this;
1✔
88
    }
89

90
    @Override
91
    public JMethodSig withReturnType(JTypeMirror returnType) {
92
        if (!returnType.equals(owner)) {
×
93
            throw new UnsupportedOperationException("Something went wrong");
×
94
        }
95
        return this;
×
96
    }
97

98
    @Override
99
    public JMethodSig withTypeParams(@Nullable List<JTypeVar> tparams) {
100
        if (tparams != null && !tparams.isEmpty()) {
×
101
            throw new UnsupportedOperationException("Something went wrong");
×
102
        }
103
        return this;
×
104
    }
105

106
    @Override
107
    public JMethodSig subst(Function<? super SubstVar, ? extends JTypeMirror> fun) {
108
        JArrayType subbed = (JArrayType) TypeOps.subst(owner, fun);
1✔
109
        return new ArrayMethodSigImpl(subbed, getSymbol());
1✔
110
    }
111

112
    @Override
113
    public JMethodSig withOwner(JTypeMirror newOwner) {
114
        if (newOwner instanceof JArrayType) {
×
115
            return new ArrayMethodSigImpl((JArrayType) newOwner, symbol);
×
116
        } else {
117
            throw new IllegalArgumentException(newOwner + " cannot be the owner of " + this);
×
118
        }
119
    }
120

121
    @Override
122
    public JMethodSig markAsAdapted() {
123
        return this;
×
124
    }
125

126
    @Override
127
    public JMethodSig originalMethod() {
128
        return new ArrayMethodSigImpl(owner, symbol);
1✔
129
    }
130

131
    @Override
132
    public JMethodSig adaptedMethod() {
133
        return originalMethod();
1✔
134
    }
135

136
    @Override
137
    public String toString() {
138
        return TypePrettyPrint.prettyPrint(this);
×
139
    }
140

141

142
    @Override
143
    public boolean equals(Object o) {
144
        if (this == o) {
1✔
145
            return true;
×
146
        }
147
        if (!(o instanceof JMethodSig)) {
1✔
148
            return false;
1✔
149
        }
150
        JMethodSig that = (JMethodSig) o;
×
151
        return TypeOps.isSameType(this, that);
×
152
    }
153

154
    @Override
155
    public int hashCode() {
156
        return Objects.hash(getName(), getFormalParameters(), getReturnType());
×
157
    }
158
}
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