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

pmd / pmd / 4476

27 Feb 2025 08:31AM UTC coverage: 77.717% (+0.02%) from 77.694%
4476

push

github

adangel
[apex] New Rule: Avoid Stateful Database Results (#5425)

Merge pull request #5425 from mitchspano:stateful

17395 of 23322 branches covered (74.59%)

Branch coverage included in aggregate %.

22 of 22 new or added lines in 1 file covered. (100.0%)

99 existing lines in 9 files now uncovered.

38180 of 48187 relevant lines covered (79.23%)

0.8 hits per line

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

56.0
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/JExecutableSymbol.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.symbols;
6

7
import java.lang.reflect.Constructor;
8
import java.lang.reflect.Method;
9
import java.lang.reflect.Modifier;
10
import java.util.List;
11

12
import org.checkerframework.checker.nullness.qual.NonNull;
13
import org.checkerframework.checker.nullness.qual.Nullable;
14

15
import net.sourceforge.pmd.lang.java.types.JMethodSig;
16
import net.sourceforge.pmd.lang.java.types.JTypeMirror;
17
import net.sourceforge.pmd.lang.java.types.Substitution;
18

19
/**
20
 * Common supertype for {@linkplain JMethodSymbol method}
21
 * and {@linkplain JConstructorSymbol constructor symbols}.
22
 */
23
public interface JExecutableSymbol extends JTypeParameterOwnerSymbol {
24

25

26
    /**
27
     * Returns the formal parameters this executable declares. These are
28
     * only non-synthetic parameters. For example, a constructor for an
29
     * inner non-static class will not reflect a parameter for the enclosing
30
     * instance.
31
     */
32
    List<JFormalParamSymbol> getFormalParameters();
33

34

35
    default boolean isDefaultMethod() {
36
        // Default methods are public non-abstract instance methods
37
        // declared in an interface.
38
        return this instanceof JMethodSymbol
1!
39
            && (getModifiers() & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) == Modifier.PUBLIC
1✔
40
            && getEnclosingClass().isInterface();
1!
41
    }
42

43

44
    /** Returns true if the last formal parameter is a varargs parameter. */
45
    boolean isVarargs();
46

47

48
    /**
49
     * Returns the number of formal parameters expected. This must be the
50
     * length of {@link #getFormalParameters()} but if it can be implemented
51
     * without creating the formal parameters, it should.
52
     *
53
     * <p>A varargs parameter counts as a single parameter.
54
     */
55
    int getArity();
56

57

58
    /**
59
     * Return the receiver type with all type annotations, when viewed
60
     * under the given substitution. Return null if this method
61
     * {@linkplain #hasReceiver() has no receiver}.
62
     *
63
     * @throws IllegalArgumentException If the argument is not the receiver type of this type.
64
     */
65
    @Nullable JTypeMirror getAnnotatedReceiverType(Substitution subst);
66

67
    /**
68
     * Return true if this method needs to be called on a receiver instance.
69
     * This is not the case if the method is static, or a constructor of an
70
     * outer or static class.
71
     */
72
    default boolean hasReceiver() {
73
        if (isStatic()) {
1!
UNCOV
74
            return false;
×
75
        }
76
        if (this instanceof JConstructorSymbol) {
1!
77
            return !getEnclosingClass().isStatic()
×
UNCOV
78
                && getEnclosingClass().getEnclosingClass() != null;
×
79
        }
80
        return true;
1✔
81
    }
82

83

84
    /**
85
     * Returns the class symbol declaring this method or constructor.
86
     * This is similar to {@link Constructor#getDeclaringClass()}, resp.
87
     * {@link Method#getDeclaringClass()}. Never null.
88
     */
89
    @Override
90
    @NonNull
91
    JClassSymbol getEnclosingClass();
92

93

94
    @Override
95
    default @NonNull String getPackageName() {
96
        return getEnclosingClass().getPackageName();
1✔
97
    }
98

99

100
    /**
101
     * Returns the types of the formal parameters, when viewed under the
102
     * given substitution. The returned list has one item for each formal.
103
     *
104
     * @see #getFormalParameters()
105
     */
106
    List<JTypeMirror> getFormalParameterTypes(Substitution subst);
107

108
    /**
109
     * Returns the types of the thrown exceptions, when viewed under the
110
     * given substitution.
111
     */
112
    List<JTypeMirror> getThrownExceptionTypes(Substitution subst);
113

114
    /**
115
     * Return a method sig corresponding to this symbol.
116
     * The returned signature may contain type parameters
117
     * of this method and of the enclosing classes.
118
     */
119
    default JMethodSig getGenericSignature() {
120
        return getTypeSystem().sigOf(this);
1✔
121
    }
122
}
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