Skip to content

Commit 5727fda

Browse files
committed
C#: Exclude get-only property accesses from CallTargetStats
1 parent 1b224c1 commit 5727fda

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

csharp/ql/src/Telemetry/DatabaseQuality.qll

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ module ReportStats<StatsSig Stats> {
3232
}
3333
}
3434

35+
private predicate isNoSetterPropertyCallInConstructor(PropertyCall c) {
36+
exists(Property p |
37+
p = c.getProperty() and
38+
not exists(Setter a | a = p.getAnAccessor()) and
39+
c.getEnclosingCallable().(Constructor).getDeclaringType().getASubType*() = p.getDeclaringType()
40+
)
41+
}
42+
3543
module CallTargetStats implements StatsSig {
3644
int getNumberOfOk() { result = count(Call c | exists(c.getTarget())) }
3745

@@ -40,7 +48,8 @@ module CallTargetStats implements StatsSig {
4048
count(Call c |
4149
not exists(c.getTarget()) and
4250
not c instanceof DelegateCall and
43-
not c instanceof DynamicExpr
51+
not c instanceof DynamicExpr and
52+
not isNoSetterPropertyCallInConstructor(c)
4453
)
4554
}
4655

0 commit comments

Comments
 (0)