@@ -7,9 +7,6 @@ import Diagnostics
77abstract class Metric extends string {
88 bindingset [ this ]
99 Metric ( ) { any ( ) }
10-
11- /** Gets the value of this metric. */
12- abstract float getValue ( ) ;
1310}
1411
1512/**
@@ -18,6 +15,9 @@ abstract class Metric extends string {
1815abstract class ExtractionMetric extends Metric {
1916 bindingset [ this ]
2017 ExtractionMetric ( ) { any ( ) }
18+
19+ /** Gets the value of this metric. */
20+ abstract int getValue ( ) ;
2121}
2222
2323/**
@@ -54,9 +54,9 @@ class QualityMetric extends Metric {
5454 base_metric = relative_metric .getBaseline ( ) and this = "Percentage of " + relative_metric
5555 }
5656
57- override float getValue ( ) {
57+ float getValue ( ) {
5858 base_metric .getValue ( ) > 0 and
59- result = 100 * relative_metric .getValue ( ) / base_metric .getValue ( )
59+ result = 100.0 * relative_metric .getValue ( ) / base_metric .getValue ( )
6060 }
6161}
6262
@@ -65,19 +65,19 @@ module CppMetrics {
6565 class CompilationUnits extends BaseMetric {
6666 CompilationUnits ( ) { this = "compilation units" }
6767
68- override float getValue ( ) { result = count ( Compilation c ) }
68+ override int getValue ( ) { result = count ( Compilation c ) }
6969 }
7070
7171 class SourceFiles extends BaseMetric {
7272 SourceFiles ( ) { this = "source files" }
7373
74- override float getValue ( ) { result = count ( File f | f .fromSource ( ) ) }
74+ override int getValue ( ) { result = count ( File f | f .fromSource ( ) ) }
7575 }
7676
7777 class SourceFilesWithoutErrors extends SuccessMetric {
7878 SourceFilesWithoutErrors ( ) { this = "source files without errors" }
7979
80- override float getValue ( ) {
80+ override int getValue ( ) {
8181 result = count ( File f | f .fromSource ( ) and not exists ( CompilerError e | f = e .getFile ( ) ) )
8282 }
8383
@@ -87,7 +87,7 @@ module CppMetrics {
8787 class CompilationUnitsWithoutErrors extends SuccessMetric {
8888 CompilationUnitsWithoutErrors ( ) { this = "compilation units without errors" }
8989
90- override float getValue ( ) {
90+ override int getValue ( ) {
9191 result = count ( Compilation c | not exists ( Diagnostic d | d .getFile ( ) = c .getAFileCompiled ( ) ) )
9292 }
9393
@@ -97,35 +97,35 @@ module CppMetrics {
9797 class Expressions extends BaseMetric {
9898 Expressions ( ) { this = "expressions" }
9999
100- override float getValue ( ) { result = count ( Expr e ) }
100+ override int getValue ( ) { result = count ( Expr e ) }
101101 }
102102
103103 class SucceededExpressions extends SuccessMetric {
104104 SucceededExpressions ( ) { this = "non-error expressions" }
105105
106- override float getValue ( ) { result = count ( Expr e ) - count ( ErrorExpr e ) }
106+ override int getValue ( ) { result = count ( Expr e ) - count ( ErrorExpr e ) }
107107
108108 override Expressions getBaseline ( ) { any ( ) }
109109 }
110110
111111 class TypedExpressions extends SuccessMetric {
112112 TypedExpressions ( ) { this = "expressions with a known type" }
113113
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 ) }
115115
116116 override Expressions getBaseline ( ) { any ( ) }
117117 }
118118
119119 class Calls extends BaseMetric {
120120 Calls ( ) { this = "calls" }
121121
122- override float getValue ( ) { result = count ( Call c ) }
122+ override int getValue ( ) { result = count ( Call c ) }
123123 }
124124
125125 class SucceededCalls extends SuccessMetric {
126126 SucceededCalls ( ) { this = "calls with a target" }
127127
128- override float getValue ( ) {
128+ override int getValue ( ) {
129129 result = count ( Call c | not c .getTarget ( ) .getADeclarationEntry ( ) .isImplicit ( ) )
130130 }
131131
@@ -135,13 +135,13 @@ module CppMetrics {
135135 class Variables extends BaseMetric {
136136 Variables ( ) { this = "variables" }
137137
138- override float getValue ( ) { result = count ( Variable v ) }
138+ override int getValue ( ) { result = count ( Variable v ) }
139139 }
140140
141141 class VariablesKnownType extends SuccessMetric {
142142 VariablesKnownType ( ) { this = "variables with a known type" }
143143
144- override float getValue ( ) {
144+ override int getValue ( ) {
145145 result = count ( Variable v | not v .getType ( ) instanceof ErroneousType )
146146 }
147147
@@ -151,13 +151,13 @@ module CppMetrics {
151151 class LinesOfText extends BaseMetric {
152152 LinesOfText ( ) { this = "lines of text" }
153153
154- override float getValue ( ) { result = sum ( File f | | f .getMetrics ( ) .getNumberOfLines ( ) ) }
154+ override int getValue ( ) { result = sum ( File f | | f .getMetrics ( ) .getNumberOfLines ( ) ) }
155155 }
156156
157157 class LinesOfCode extends BaseMetric {
158158 LinesOfCode ( ) { this = "lines of code" }
159159
160- override float getValue ( ) { result = sum ( File f | | f .getMetrics ( ) .getNumberOfLinesOfCode ( ) ) }
160+ override int getValue ( ) { result = sum ( File f | | f .getMetrics ( ) .getNumberOfLinesOfCode ( ) ) }
161161 }
162162
163163 private predicate errorLine ( File file , int line ) {
@@ -175,7 +175,7 @@ module CppMetrics {
175175 class SucceededLines extends SuccessMetric {
176176 SucceededLines ( ) { this = "lines of code without errors" }
177177
178- override float getValue ( ) {
178+ override int getValue ( ) {
179179 result =
180180 sum ( File f | | f .getMetrics ( ) .getNumberOfLinesOfCode ( ) ) -
181181 count ( File file , int line | errorLine ( file , line ) )
@@ -187,27 +187,27 @@ module CppMetrics {
187187 class Functions extends BaseMetric {
188188 Functions ( ) { this = "functions" }
189189
190- override float getValue ( ) { result = count ( Function f ) }
190+ override int getValue ( ) { result = count ( Function f ) }
191191 }
192192
193193 class SucceededFunctions extends SuccessMetric {
194194 SucceededFunctions ( ) { this = "functions without errors" }
195195
196- override float getValue ( ) { result = count ( Function f | not f .hasErrors ( ) ) }
196+ override int getValue ( ) { result = count ( Function f | not f .hasErrors ( ) ) }
197197
198198 override Functions getBaseline ( ) { any ( ) }
199199 }
200200
201201 class Includes extends BaseMetric {
202202 Includes ( ) { this = "#include directives" }
203203
204- override float getValue ( ) { result = count ( Include i ) + count ( CannotOpenFile e ) }
204+ override int getValue ( ) { result = count ( Include i ) + count ( CannotOpenFile e ) }
205205 }
206206
207207 class SucceededIncludes extends SuccessMetric {
208208 SucceededIncludes ( ) { this = "successfully resolved #include directives" }
209209
210- override float getValue ( ) { result = count ( Include i ) }
210+ override int getValue ( ) { result = count ( Include i ) }
211211
212212 override Includes getBaseline ( ) { any ( ) }
213213 }
@@ -223,7 +223,7 @@ module CppMetrics {
223223 this = "Successfully included " + include_text
224224 }
225225
226- override float getValue ( ) { result = count ( Include i | i .getIncludeText ( ) = include_text ) }
226+ int getValue ( ) { result = count ( Include i | i .getIncludeText ( ) = include_text ) }
227227
228228 string getIncludeText ( ) { result = include_text }
229229 }
@@ -236,28 +236,26 @@ module CppMetrics {
236236 this = "Failed to include '" + include_text + "'"
237237 }
238238
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 ) }
242240
243241 string getIncludeText ( ) { result = include_text }
244242 }
245243
246244 class CompilerErrors extends ExtractionMetric {
247245 CompilerErrors ( ) { this = "compiler errors" }
248246
249- override float getValue ( ) { result = count ( CompilerError e ) }
247+ override int getValue ( ) { result = count ( CompilerError e ) }
250248 }
251249
252250 class ErrorCount extends Metric {
253251 ErrorCount ( ) { exists ( CompilerError e | e .getMessage ( ) = this ) }
254252
255- override float getValue ( ) { result = count ( CompilerError e | e .getMessage ( ) = this ) }
253+ int getValue ( ) { result = count ( CompilerError e | e .getMessage ( ) = this ) }
256254 }
257255
258256 class SyntaxErrorCount extends ExtractionMetric {
259257 SyntaxErrorCount ( ) { this = "syntax errors" }
260258
261- override float getValue ( ) { result = count ( SyntaxError e ) }
259+ override int getValue ( ) { result = count ( SyntaxError e ) }
262260 }
263261}
0 commit comments