@@ -7,9 +7,6 @@ import Diagnostics
7
7
abstract class Metric extends string {
8
8
bindingset [ this ]
9
9
Metric ( ) { any ( ) }
10
-
11
- /** Gets the value of this metric. */
12
- abstract float getValue ( ) ;
13
10
}
14
11
15
12
/**
@@ -18,6 +15,9 @@ abstract class Metric extends string {
18
15
abstract class ExtractionMetric extends Metric {
19
16
bindingset [ this ]
20
17
ExtractionMetric ( ) { any ( ) }
18
+
19
+ /** Gets the value of this metric. */
20
+ abstract int getValue ( ) ;
21
21
}
22
22
23
23
/**
@@ -54,9 +54,9 @@ class QualityMetric extends Metric {
54
54
base_metric = relative_metric .getBaseline ( ) and this = "Percentage of " + relative_metric
55
55
}
56
56
57
- override float getValue ( ) {
57
+ float getValue ( ) {
58
58
base_metric .getValue ( ) > 0 and
59
- result = 100 * relative_metric .getValue ( ) / base_metric .getValue ( )
59
+ result = 100.0 * relative_metric .getValue ( ) / base_metric .getValue ( )
60
60
}
61
61
}
62
62
@@ -65,19 +65,19 @@ module CppMetrics {
65
65
class CompilationUnits extends BaseMetric {
66
66
CompilationUnits ( ) { this = "compilation units" }
67
67
68
- override float getValue ( ) { result = count ( Compilation c ) }
68
+ override int getValue ( ) { result = count ( Compilation c ) }
69
69
}
70
70
71
71
class SourceFiles extends BaseMetric {
72
72
SourceFiles ( ) { this = "source files" }
73
73
74
- override float getValue ( ) { result = count ( File f | f .fromSource ( ) ) }
74
+ override int getValue ( ) { result = count ( File f | f .fromSource ( ) ) }
75
75
}
76
76
77
77
class SourceFilesWithoutErrors extends SuccessMetric {
78
78
SourceFilesWithoutErrors ( ) { this = "source files without errors" }
79
79
80
- override float getValue ( ) {
80
+ override int getValue ( ) {
81
81
result = count ( File f | f .fromSource ( ) and not exists ( CompilerError e | f = e .getFile ( ) ) )
82
82
}
83
83
@@ -87,7 +87,7 @@ module CppMetrics {
87
87
class CompilationUnitsWithoutErrors extends SuccessMetric {
88
88
CompilationUnitsWithoutErrors ( ) { this = "compilation units without errors" }
89
89
90
- override float getValue ( ) {
90
+ override int getValue ( ) {
91
91
result = count ( Compilation c | not exists ( Diagnostic d | d .getFile ( ) = c .getAFileCompiled ( ) ) )
92
92
}
93
93
@@ -97,35 +97,35 @@ module CppMetrics {
97
97
class Expressions extends BaseMetric {
98
98
Expressions ( ) { this = "expressions" }
99
99
100
- override float getValue ( ) { result = count ( Expr e ) }
100
+ override int getValue ( ) { result = count ( Expr e ) }
101
101
}
102
102
103
103
class SucceededExpressions extends SuccessMetric {
104
104
SucceededExpressions ( ) { this = "non-error expressions" }
105
105
106
- override float getValue ( ) { result = count ( Expr e ) - count ( ErrorExpr e ) }
106
+ override int getValue ( ) { result = count ( Expr e ) - count ( ErrorExpr e ) }
107
107
108
108
override Expressions getBaseline ( ) { any ( ) }
109
109
}
110
110
111
111
class TypedExpressions extends SuccessMetric {
112
112
TypedExpressions ( ) { this = "expressions with a known type" }
113
113
114
- override float getValue ( ) { result = count ( Expr e | not e .getType ( ) instanceof ErroneousType ) }
114
+ override int getValue ( ) { result = count ( Expr e | not e .getType ( ) instanceof ErroneousType ) }
115
115
116
116
override Expressions getBaseline ( ) { any ( ) }
117
117
}
118
118
119
119
class Calls extends BaseMetric {
120
120
Calls ( ) { this = "calls" }
121
121
122
- override float getValue ( ) { result = count ( Call c ) }
122
+ override int getValue ( ) { result = count ( Call c ) }
123
123
}
124
124
125
125
class SucceededCalls extends SuccessMetric {
126
126
SucceededCalls ( ) { this = "calls with a target" }
127
127
128
- override float getValue ( ) {
128
+ override int getValue ( ) {
129
129
result = count ( Call c | not c .getTarget ( ) .getADeclarationEntry ( ) .isImplicit ( ) )
130
130
}
131
131
@@ -135,13 +135,13 @@ module CppMetrics {
135
135
class Variables extends BaseMetric {
136
136
Variables ( ) { this = "variables" }
137
137
138
- override float getValue ( ) { result = count ( Variable v ) }
138
+ override int getValue ( ) { result = count ( Variable v ) }
139
139
}
140
140
141
141
class VariablesKnownType extends SuccessMetric {
142
142
VariablesKnownType ( ) { this = "variables with a known type" }
143
143
144
- override float getValue ( ) {
144
+ override int getValue ( ) {
145
145
result = count ( Variable v | not v .getType ( ) instanceof ErroneousType )
146
146
}
147
147
@@ -151,13 +151,13 @@ module CppMetrics {
151
151
class LinesOfText extends BaseMetric {
152
152
LinesOfText ( ) { this = "lines of text" }
153
153
154
- override float getValue ( ) { result = sum ( File f | | f .getMetrics ( ) .getNumberOfLines ( ) ) }
154
+ override int getValue ( ) { result = sum ( File f | | f .getMetrics ( ) .getNumberOfLines ( ) ) }
155
155
}
156
156
157
157
class LinesOfCode extends BaseMetric {
158
158
LinesOfCode ( ) { this = "lines of code" }
159
159
160
- override float getValue ( ) { result = sum ( File f | | f .getMetrics ( ) .getNumberOfLinesOfCode ( ) ) }
160
+ override int getValue ( ) { result = sum ( File f | | f .getMetrics ( ) .getNumberOfLinesOfCode ( ) ) }
161
161
}
162
162
163
163
private predicate errorLine ( File file , int line ) {
@@ -175,7 +175,7 @@ module CppMetrics {
175
175
class SucceededLines extends SuccessMetric {
176
176
SucceededLines ( ) { this = "lines of code without errors" }
177
177
178
- override float getValue ( ) {
178
+ override int getValue ( ) {
179
179
result =
180
180
sum ( File f | | f .getMetrics ( ) .getNumberOfLinesOfCode ( ) ) -
181
181
count ( File file , int line | errorLine ( file , line ) )
@@ -187,27 +187,27 @@ module CppMetrics {
187
187
class Functions extends BaseMetric {
188
188
Functions ( ) { this = "functions" }
189
189
190
- override float getValue ( ) { result = count ( Function f ) }
190
+ override int getValue ( ) { result = count ( Function f ) }
191
191
}
192
192
193
193
class SucceededFunctions extends SuccessMetric {
194
194
SucceededFunctions ( ) { this = "functions without errors" }
195
195
196
- override float getValue ( ) { result = count ( Function f | not f .hasErrors ( ) ) }
196
+ override int getValue ( ) { result = count ( Function f | not f .hasErrors ( ) ) }
197
197
198
198
override Functions getBaseline ( ) { any ( ) }
199
199
}
200
200
201
201
class Includes extends BaseMetric {
202
202
Includes ( ) { this = "#include directives" }
203
203
204
- override float getValue ( ) { result = count ( Include i ) + count ( CannotOpenFile e ) }
204
+ override int getValue ( ) { result = count ( Include i ) + count ( CannotOpenFile e ) }
205
205
}
206
206
207
207
class SucceededIncludes extends SuccessMetric {
208
208
SucceededIncludes ( ) { this = "successfully resolved #include directives" }
209
209
210
- override float getValue ( ) { result = count ( Include i ) }
210
+ override int getValue ( ) { result = count ( Include i ) }
211
211
212
212
override Includes getBaseline ( ) { any ( ) }
213
213
}
@@ -223,7 +223,7 @@ module CppMetrics {
223
223
this = "Successfully included " + include_text
224
224
}
225
225
226
- override float getValue ( ) { result = count ( Include i | i .getIncludeText ( ) = include_text ) }
226
+ int getValue ( ) { result = count ( Include i | i .getIncludeText ( ) = include_text ) }
227
227
228
228
string getIncludeText ( ) { result = include_text }
229
229
}
@@ -236,28 +236,26 @@ module CppMetrics {
236
236
this = "Failed to include '" + include_text + "'"
237
237
}
238
238
239
- override float getValue ( ) {
240
- result = count ( CannotOpenFile e | e .getIncludedFile ( ) = include_text )
241
- }
239
+ int getValue ( ) { result = count ( CannotOpenFile e | e .getIncludedFile ( ) = include_text ) }
242
240
243
241
string getIncludeText ( ) { result = include_text }
244
242
}
245
243
246
244
class CompilerErrors extends ExtractionMetric {
247
245
CompilerErrors ( ) { this = "compiler errors" }
248
246
249
- override float getValue ( ) { result = count ( CompilerError e ) }
247
+ override int getValue ( ) { result = count ( CompilerError e ) }
250
248
}
251
249
252
250
class ErrorCount extends Metric {
253
251
ErrorCount ( ) { exists ( CompilerError e | e .getMessage ( ) = this ) }
254
252
255
- override float getValue ( ) { result = count ( CompilerError e | e .getMessage ( ) = this ) }
253
+ int getValue ( ) { result = count ( CompilerError e | e .getMessage ( ) = this ) }
256
254
}
257
255
258
256
class SyntaxErrorCount extends ExtractionMetric {
259
257
SyntaxErrorCount ( ) { this = "syntax errors" }
260
258
261
- override float getValue ( ) { result = count ( SyntaxError e ) }
259
+ override int getValue ( ) { result = count ( SyntaxError e ) }
262
260
}
263
261
}
0 commit comments