mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Merge pull request #11624 from jcogs33/jcogs33/exclude-paramless-constructors-from-dataflowtargetapi
Java/C#: exclude parameterless constructors from `DataFlowTargetApi`
This commit is contained in:
@@ -358,6 +358,9 @@ class Constructor extends DotNet::Constructor, Callable, Member, Attributable, @
|
||||
if this.isStatic() then result = this.getParameter(i) else result = this.getParameter(i - 1)
|
||||
}
|
||||
|
||||
/** Holds if this is a constructor without parameters. */
|
||||
predicate isParameterless() { this.getNumberOfParameters() = 0 }
|
||||
|
||||
override string getUndecoratedName() { result = ".ctor" }
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ private predicate isRelevantForModels(CS::Callable api) {
|
||||
api.getDeclaringType().getNamespace().getFullName() != "" and
|
||||
not api instanceof CS::ConversionOperator and
|
||||
not api instanceof Util::MainMethod and
|
||||
not api instanceof CS::Destructor
|
||||
not api instanceof CS::Destructor and
|
||||
not api.(CS::Constructor).isParameterless()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -131,4 +131,15 @@ public class CollectionFlow
|
||||
{
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A neutral model should not be created for a parameterless constructor.
|
||||
public class ParameterlessConstructor
|
||||
{
|
||||
public bool IsInitialized;
|
||||
|
||||
public ParameterlessConstructor()
|
||||
{
|
||||
IsInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user