|
8 | 8 |
|
9 | 9 | import csharp |
10 | 10 | import semmle.code.csharp.commons.Diagnostics |
| 11 | +import DatabaseQuality |
11 | 12 |
|
12 | 13 | predicate compilationInfo(string key, float value) { |
13 | 14 | not key.matches("Compiler diagnostic count for%") and |
@@ -90,68 +91,6 @@ predicate extractionIsStandalone(string key, int value) { |
90 | 91 | key = "Is extracted with build-mode set to 'none'" |
91 | 92 | } |
92 | 93 |
|
93 | | -signature module StatsSig { |
94 | | - int getNumberOfOk(); |
95 | | - |
96 | | - int getNumberOfNotOk(); |
97 | | - |
98 | | - string getOkText(); |
99 | | - |
100 | | - string getNotOkText(); |
101 | | -} |
102 | | - |
103 | | -module ReportStats<StatsSig Stats> { |
104 | | - predicate numberOfOk(string key, int value) { |
105 | | - value = Stats::getNumberOfOk() and |
106 | | - key = "Number of " + Stats::getOkText() |
107 | | - } |
108 | | - |
109 | | - predicate numberOfNotOk(string key, int value) { |
110 | | - value = Stats::getNumberOfNotOk() and |
111 | | - key = "Number of " + Stats::getNotOkText() |
112 | | - } |
113 | | - |
114 | | - predicate percentageOfOk(string key, float value) { |
115 | | - value = Stats::getNumberOfOk() * 100.0 / (Stats::getNumberOfOk() + Stats::getNumberOfNotOk()) and |
116 | | - key = "Percentage of " + Stats::getOkText() |
117 | | - } |
118 | | -} |
119 | | - |
120 | | -module CallTargetStats implements StatsSig { |
121 | | - int getNumberOfOk() { result = count(Call c | exists(c.getTarget())) } |
122 | | - |
123 | | - int getNumberOfNotOk() { |
124 | | - result = |
125 | | - count(Call c | |
126 | | - not exists(c.getTarget()) and |
127 | | - not c instanceof DelegateCall and |
128 | | - not c instanceof DynamicExpr |
129 | | - ) |
130 | | - } |
131 | | - |
132 | | - string getOkText() { result = "calls with call target" } |
133 | | - |
134 | | - string getNotOkText() { result = "calls with missing call target" } |
135 | | -} |
136 | | - |
137 | | -private class SourceExpr extends Expr { |
138 | | - SourceExpr() { this.getFile().fromSource() } |
139 | | -} |
140 | | - |
141 | | -private predicate hasGoodType(Expr e) { |
142 | | - exists(e.getType()) and not e.getType() instanceof UnknownType |
143 | | -} |
144 | | - |
145 | | -module ExprTypeStats implements StatsSig { |
146 | | - int getNumberOfOk() { result = count(SourceExpr e | hasGoodType(e)) } |
147 | | - |
148 | | - int getNumberOfNotOk() { result = count(SourceExpr e | not hasGoodType(e)) } |
149 | | - |
150 | | - string getOkText() { result = "expressions with known type" } |
151 | | - |
152 | | - string getNotOkText() { result = "expressions with unknown type" } |
153 | | -} |
154 | | - |
155 | 94 | module TypeMentionTypeStats implements StatsSig { |
156 | 95 | int getNumberOfOk() { result = count(TypeMention t | not t.getType() instanceof UnknownType) } |
157 | 96 |
|
@@ -182,10 +121,6 @@ module ExprStats implements StatsSig { |
182 | 121 | string getNotOkText() { result = "expressions with unknown kind" } |
183 | 122 | } |
184 | 123 |
|
185 | | -module CallTargetStatsReport = ReportStats<CallTargetStats>; |
186 | | - |
187 | | -module ExprTypeStatsReport = ReportStats<ExprTypeStats>; |
188 | | - |
189 | 124 | module TypeMentionTypeStatsReport = ReportStats<TypeMentionTypeStats>; |
190 | 125 |
|
191 | 126 | module AccessTargetStatsReport = ReportStats<AccessTargetStats>; |
|
0 commit comments