|
8 | 8 |
|
9 | 9 | import java |
10 | 10 | import semmle.code.java.Diagnostics |
| 11 | +import DatabaseQuality |
11 | 12 |
|
12 | 13 | extensible predicate extractorInformationSkipKey(string key); |
13 | 14 |
|
@@ -85,65 +86,6 @@ predicate extractorTotalDiagnostics(string key, int value) { |
85 | 86 | ) |
86 | 87 | } |
87 | 88 |
|
88 | | -signature module StatsSig { |
89 | | - int getNumberOfOk(); |
90 | | - |
91 | | - int getNumberOfNotOk(); |
92 | | - |
93 | | - string getOkText(); |
94 | | - |
95 | | - string getNotOkText(); |
96 | | -} |
97 | | - |
98 | | -module ReportStats<StatsSig Stats> { |
99 | | - predicate numberOfOk(string key, int value) { |
100 | | - value = Stats::getNumberOfOk() and |
101 | | - key = "Number of " + Stats::getOkText() |
102 | | - } |
103 | | - |
104 | | - predicate numberOfNotOk(string key, int value) { |
105 | | - value = Stats::getNumberOfNotOk() and |
106 | | - key = "Number of " + Stats::getNotOkText() |
107 | | - } |
108 | | - |
109 | | - predicate percentageOfOk(string key, float value) { |
110 | | - value = Stats::getNumberOfOk() * 100.0 / (Stats::getNumberOfOk() + Stats::getNumberOfNotOk()) and |
111 | | - key = "Percentage of " + Stats::getOkText() |
112 | | - } |
113 | | -} |
114 | | - |
115 | | -module CallTargetStats implements StatsSig { |
116 | | - int getNumberOfOk() { result = count(Call c | exists(c.getCallee())) } |
117 | | - |
118 | | - int getNumberOfNotOk() { result = count(Call c | not exists(c.getCallee())) } |
119 | | - |
120 | | - string getOkText() { result = "calls with call target" } |
121 | | - |
122 | | - string getNotOkText() { result = "calls with missing call target" } |
123 | | -} |
124 | | - |
125 | | -private class SourceExpr extends Expr { |
126 | | - SourceExpr() { this.getFile().isSourceFile() } |
127 | | -} |
128 | | - |
129 | | -private predicate hasGoodType(Expr e) { |
130 | | - exists(e.getType()) and not e.getType() instanceof ErrorType |
131 | | -} |
132 | | - |
133 | | -module ExprTypeStats implements StatsSig { |
134 | | - int getNumberOfOk() { result = count(SourceExpr e | hasGoodType(e)) } |
135 | | - |
136 | | - int getNumberOfNotOk() { result = count(SourceExpr e | not hasGoodType(e)) } |
137 | | - |
138 | | - string getOkText() { result = "expressions with known type" } |
139 | | - |
140 | | - string getNotOkText() { result = "expressions with unknown type" } |
141 | | -} |
142 | | - |
143 | | -module CallTargetStatsReport = ReportStats<CallTargetStats>; |
144 | | - |
145 | | -module ExprTypeStatsReport = ReportStats<ExprTypeStats>; |
146 | | - |
147 | 89 | from string key, int value |
148 | 90 | where |
149 | 91 | not exists(string pattern | extractorInformationSkipKey(pattern) and key.matches(pattern)) and |
|
0 commit comments