mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Java: add isParameterless predicate to Constructor class
This commit is contained in:
@@ -638,6 +638,9 @@ class Constructor extends Callable, @constructor {
|
||||
/** Holds if this is a default constructor, not explicitly declared in source code. */
|
||||
predicate isDefaultConstructor() { isDefConstr(this) }
|
||||
|
||||
/** Holds if this is a constructor without parameters. */
|
||||
predicate isParameterless() { this.getNumberOfParameters() = 0 }
|
||||
|
||||
override Constructor getSourceDeclaration() { constrs(this, _, _, _, _, result) }
|
||||
|
||||
override string getSignature() { constrs(this, _, result, _, _, _) }
|
||||
|
||||
@@ -31,16 +31,14 @@ private string containerAsJar(Container container) {
|
||||
if container instanceof JarFile then result = container.getBaseName() else result = "rt.jar"
|
||||
}
|
||||
|
||||
/** Holds if the given callable is a constructor without parameters. */
|
||||
private predicate isParameterlessConstructor(Callable c) {
|
||||
c instanceof Constructor and c.getNumberOfParameters() = 0
|
||||
}
|
||||
|
||||
/** Holds if the given callable is part of a common testing library or framework. */
|
||||
private predicate isTestLibrary(Callable c) { c.getDeclaringType() instanceof TestLibrary }
|
||||
|
||||
/** Holds if the given callable is not worth supporting. */
|
||||
private predicate isUninteresting(Callable c) { isTestLibrary(c) or isParameterlessConstructor(c) }
|
||||
private predicate isUninteresting(Callable c) {
|
||||
isTestLibrary(c) or
|
||||
c.(Constructor).isParameterless()
|
||||
}
|
||||
|
||||
/**
|
||||
* An external API from either the Standard Library or a 3rd party library.
|
||||
|
||||
Reference in New Issue
Block a user