Skip to content

Commit 27703c7

Browse files
author
Stephan Brandauer
committed
pull subtypes-logic out into helper predicate, and document it
1 parent 0e5591f commit 27703c7

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

java/ql/src/Telemetry/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ class Endpoint = FrameworkCandidatesImpl::Endpoint;
133133
class FrameworkModeMetadataExtractor extends MetadataExtractor {
134134
FrameworkModeMetadataExtractor() { this = "FrameworkModeMetadataExtractor" }
135135

136+
/**
137+
* By convention, the subtypes property of the MaD declaration should only be
138+
* true when there _can_ exist any subtypes with a different implementation.
139+
*
140+
* It would technically be ok to always use the value 'true', but this would
141+
* break convention.
142+
*/
143+
boolean considerSubtypes(Callable callable) {
144+
if
145+
callable.isStatic() or
146+
callable.getDeclaringType().isStatic() or
147+
callable.isFinal() or
148+
callable.getDeclaringType().isFinal()
149+
then result = false
150+
else result = true
151+
}
152+
136153
override predicate hasMetadata(
137154
Endpoint e, string package, string type, boolean subtypes, string name, string signature,
138155
int input
@@ -141,15 +158,7 @@ class FrameworkModeMetadataExtractor extends MetadataExtractor {
141158
e.asParameter() = callable.getParameter(input) and
142159
package = callable.getDeclaringType().getPackage().getName() and
143160
type = callable.getDeclaringType().getErasure().(RefType).nestedName() and
144-
(
145-
if
146-
callable.isStatic() or
147-
callable.getDeclaringType().isStatic() or
148-
callable.isFinal() or
149-
callable.getDeclaringType().isFinal()
150-
then subtypes = true
151-
else subtypes = false
152-
) and
161+
subtypes = considerSubtypes(callable) and
153162
name = e.toString() and
154163
signature = ExternalFlow::paramsString(callable)
155164
)

0 commit comments

Comments
 (0)