Skip to content

Commit 16d8e8e

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: exclude parameterless constructors from DataFlowTargetApi
1 parent 636d5e3 commit 16d8e8e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

java/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,20 @@ private predicate isJdkInternal(J::CompilationUnit cu) {
5252
cu.getPackage().getName() = ""
5353
}
5454

55+
/** Holds if the given API is a constructor without parameters. */
56+
private predicate isParameterlessConstructor(J::Callable api) {
57+
api instanceof J::Constructor and api.getNumberOfParameters() = 0
58+
}
59+
5560
/**
5661
* Holds if it is relevant to generate models for `api`.
5762
*/
5863
private predicate isRelevantForModels(J::Callable api) {
5964
not isInTestFile(api.getCompilationUnit().getFile()) and
6065
not isJdkInternal(api.getCompilationUnit()) and
6166
not api instanceof J::MainMethod and
62-
not api instanceof J::StaticInitializer
67+
not api instanceof J::StaticInitializer and
68+
not isParameterlessConstructor(api)
6369
}
6470

6571
/**

0 commit comments

Comments
 (0)