001 /*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2013 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
019 */
020 package org.sonar.api.measures;
021
022 import com.google.common.annotations.Beta;
023 import com.google.common.collect.Lists;
024 import org.sonar.api.resources.Scopes;
025 import org.sonar.api.utils.SonarException;
026
027 import java.lang.reflect.Field;
028 import java.util.List;
029
030 /**
031 * @since 1.10
032 */
033 public final class CoreMetrics {
034
035 private CoreMetrics() {
036 // only static stuff
037 }
038
039 // the following fields are not final to avoid compile-time constants used by plugins
040 public static String DOMAIN_SIZE = "Size";
041 public static String DOMAIN_TESTS = "Tests";
042 public static String DOMAIN_INTEGRATION_TESTS = "Tests (Integration)";
043 public static String DOMAIN_OVERALL_TESTS = "Tests (Overall)";
044 public static String DOMAIN_COMPLEXITY = "Complexity";
045 public static String DOMAIN_DOCUMENTATION = "Documentation";
046 public static String DOMAIN_SCM = "SCM";
047
048 /**
049 * @deprecated in 3.6. Replaced by concept of issues.
050 */
051 @Deprecated
052 public static String DOMAIN_REVIEWS = "Reviews";
053 public static String DOMAIN_ISSUES = "Issues";
054 public static String DOMAIN_GENERAL = "General";
055 public static String DOMAIN_DUPLICATION = "Duplication";
056 public static String DOMAIN_DESIGN = "Design";
057
058 /**
059 * @since 4.0
060 */
061 public static String DOMAIN_TECHNICAL_DEBT = "Technical Debt";
062
063 public static final String LINES_KEY = "lines";
064 public static final Metric LINES = new Metric.Builder(LINES_KEY, "Lines", Metric.ValueType.INT)
065 .setDescription("Lines")
066 .setDirection(Metric.DIRECTION_WORST)
067 .setQualitative(false)
068 .setDomain(DOMAIN_SIZE)
069 .setFormula(new SumChildValuesFormula(false))
070 .create();
071
072 public static final String GENERATED_LINES_KEY = "generated_lines";
073 public static final Metric GENERATED_LINES = new Metric.Builder(GENERATED_LINES_KEY, "Generated Lines", Metric.ValueType.INT)
074 .setDescription("Number of generated lines")
075 .setDirection(Metric.DIRECTION_WORST)
076 .setQualitative(false)
077 .setDomain(DOMAIN_SIZE)
078 .setBestValue(0.0)
079 .setOptimizedBestValue(true)
080 .setFormula(new SumChildValuesFormula(false))
081 .create();
082
083 public static final String NCLOC_KEY = "ncloc";
084 public static final Metric NCLOC = new Metric.Builder(NCLOC_KEY, "Lines of code", Metric.ValueType.INT)
085 .setDescription("Non Commenting Lines of Code")
086 .setDirection(Metric.DIRECTION_WORST)
087 .setQualitative(false)
088 .setDomain(DOMAIN_SIZE)
089 .setFormula(new SumChildValuesFormula(false))
090 .create();
091
092 public static final String GENERATED_NCLOC_KEY = "generated_ncloc";
093 public static final Metric GENERATED_NCLOC = new Metric.Builder(GENERATED_NCLOC_KEY, "Generated lines of code", Metric.ValueType.INT)
094 .setDescription("Generated non Commenting Lines of Code")
095 .setDirection(Metric.DIRECTION_WORST)
096 .setQualitative(false)
097 .setDomain(DOMAIN_SIZE)
098 .setBestValue(0.0)
099 .setOptimizedBestValue(true)
100 .setFormula(new SumChildValuesFormula(false))
101 .create();
102
103 public static final String CLASSES_KEY = "classes";
104 public static final Metric CLASSES = new Metric.Builder(CLASSES_KEY, "Classes", Metric.ValueType.INT)
105 .setDescription("Classes")
106 .setDirection(Metric.DIRECTION_WORST)
107 .setQualitative(false)
108 .setDomain(DOMAIN_SIZE)
109 .setFormula(new SumChildValuesFormula(false))
110 .create();
111
112 public static final String FILES_KEY = "files";
113 public static final Metric FILES = new Metric.Builder(FILES_KEY, "Files", Metric.ValueType.INT)
114 .setDescription("Number of files")
115 .setDirection(Metric.DIRECTION_WORST)
116 .setQualitative(false)
117 .setDomain(DOMAIN_SIZE)
118 .create();
119
120 public static final String DIRECTORIES_KEY = "directories";
121 public static final Metric DIRECTORIES = new Metric.Builder(DIRECTORIES_KEY, "Directories", Metric.ValueType.INT)
122 .setDescription("Directories")
123 .setDirection(Metric.DIRECTION_WORST)
124 .setQualitative(false)
125 .setDomain(DOMAIN_SIZE)
126 .create();
127
128 public static final String PACKAGES_KEY = "packages";
129 public static final Metric PACKAGES = new Metric.Builder(PACKAGES_KEY, "Packages", Metric.ValueType.INT)
130 .setDescription("Packages")
131 .setDirection(Metric.DIRECTION_WORST)
132 .setQualitative(false)
133 .setDomain(DOMAIN_SIZE)
134 .setFormula(new SumChildValuesFormula(false))
135 .create();
136
137 public static final String FUNCTIONS_KEY = "functions";
138 public static final Metric FUNCTIONS = new Metric.Builder(FUNCTIONS_KEY, "Functions", Metric.ValueType.INT)
139 .setDescription("Functions")
140 .setDirection(Metric.DIRECTION_WORST)
141 .setQualitative(false)
142 .setDomain(DOMAIN_SIZE)
143 .setFormula(new SumChildValuesFormula(false))
144 .create();
145
146 public static final String ACCESSORS_KEY = "accessors";
147 public static final Metric ACCESSORS = new Metric.Builder(ACCESSORS_KEY, "Accessors", Metric.ValueType.INT)
148 .setDescription("Accessors")
149 .setDirection(Metric.DIRECTION_WORST)
150 .setQualitative(false)
151 .setDomain(DOMAIN_SIZE)
152 .setFormula(new SumChildValuesFormula(false))
153 .create();
154
155 public static final String STATEMENTS_KEY = "statements";
156 public static final Metric STATEMENTS = new Metric.Builder(STATEMENTS_KEY, "Statements", Metric.ValueType.INT)
157 .setDescription("Number of statements")
158 .setDirection(Metric.DIRECTION_WORST)
159 .setQualitative(false)
160 .setDomain(DOMAIN_SIZE)
161 .setFormula(new SumChildValuesFormula(false))
162 .create();
163
164 public static final String PUBLIC_API_KEY = "public_api";
165 public static final Metric PUBLIC_API = new Metric.Builder(PUBLIC_API_KEY, "Public API", Metric.ValueType.INT)
166 .setDescription("Public API")
167 .setDirection(Metric.DIRECTION_WORST)
168 .setQualitative(false)
169 .setDomain(DOMAIN_SIZE)
170 .setFormula(new SumChildValuesFormula(false))
171 .create();
172
173 /**
174 * @since 3.0
175 */
176 public static final String PROJECTS_KEY = "projects";
177
178 /**
179 * @since 3.0
180 */
181 public static final Metric PROJECTS = new Metric.Builder(PROJECTS_KEY, "Projects", Metric.ValueType.INT)
182 .setDescription("Number of projects")
183 .setDirection(Metric.DIRECTION_WORST)
184 .setQualitative(false)
185 .setDomain(DOMAIN_SIZE)
186 .create();
187
188 // --------------------------------------------------------------------------------------------------------------------
189 //
190 // DOCUMENTATION
191 //
192 // --------------------------------------------------------------------------------------------------------------------
193
194 public static final String COMMENT_LINES_KEY = "comment_lines";
195 public static final Metric COMMENT_LINES = new Metric.Builder(COMMENT_LINES_KEY, "Comment lines", Metric.ValueType.INT)
196 .setDescription("Number of comment lines")
197 .setDirection(Metric.DIRECTION_BETTER)
198 .setQualitative(false)
199 .setDomain(DOMAIN_DOCUMENTATION)
200 .setFormula(new SumChildValuesFormula(false))
201 .create();
202
203 public static final String COMMENT_LINES_DENSITY_KEY = "comment_lines_density";
204 public static final Metric COMMENT_LINES_DENSITY = new Metric.Builder(COMMENT_LINES_DENSITY_KEY, "Comments (%)", Metric.ValueType.PERCENT)
205 .setDescription("Comments balanced by ncloc + comment lines")
206 .setDirection(Metric.DIRECTION_BETTER)
207 .setQualitative(true)
208 .setDomain(DOMAIN_DOCUMENTATION)
209 .create();
210
211 /**
212 * @deprecated since 3.3 - see SONAR-3768
213 */
214 @Deprecated
215 public static final String COMMENT_BLANK_LINES_KEY = "comment_blank_lines";
216
217 /**
218 * @deprecated since 3.3 - see SONAR-3768
219 */
220 @Deprecated
221 public static final Metric COMMENT_BLANK_LINES = new Metric.Builder(COMMENT_BLANK_LINES_KEY, "Blank comments", Metric.ValueType.INT)
222 .setDescription("Comments that do not contain comments")
223 .setDirection(Metric.DIRECTION_WORST)
224 .setQualitative(false)
225 .setDomain(DOMAIN_DOCUMENTATION)
226 .setFormula(new SumChildValuesFormula(false))
227 .setBestValue(0.0)
228 .setOptimizedBestValue(true)
229 .create();
230
231 public static final String PUBLIC_DOCUMENTED_API_DENSITY_KEY = "public_documented_api_density";
232 public static final Metric PUBLIC_DOCUMENTED_API_DENSITY = new Metric.Builder(PUBLIC_DOCUMENTED_API_DENSITY_KEY, "Public documented API (%)", Metric.ValueType.PERCENT)
233 .setDescription("Public documented classes and functions balanced by ncloc")
234 .setDirection(Metric.DIRECTION_BETTER)
235 .setQualitative(true)
236 .setDomain(DOMAIN_DOCUMENTATION)
237 .setWorstValue(0.0)
238 .setBestValue(100.0)
239 .setOptimizedBestValue(true)
240 .create();
241
242 public static final String PUBLIC_UNDOCUMENTED_API_KEY = "public_undocumented_api";
243 public static final Metric PUBLIC_UNDOCUMENTED_API = new Metric.Builder(PUBLIC_UNDOCUMENTED_API_KEY, "Public undocumented API", Metric.ValueType.INT)
244 .setDescription("Public undocumented classes, functions and variables")
245 .setDirection(Metric.DIRECTION_WORST)
246 .setQualitative(true)
247 .setDomain(DOMAIN_DOCUMENTATION)
248 .setBestValue(0.0)
249 .setDirection(Metric.DIRECTION_WORST)
250 .setOptimizedBestValue(true)
251 .setFormula(new SumChildValuesFormula(false))
252 .create();
253
254 public static final String COMMENTED_OUT_CODE_LINES_KEY = "commented_out_code_lines";
255 public static final Metric COMMENTED_OUT_CODE_LINES = new Metric.Builder(COMMENTED_OUT_CODE_LINES_KEY, "Commented-out LOC", Metric.ValueType.INT)
256 .setDescription("Commented lines of code")
257 .setDirection(Metric.DIRECTION_WORST)
258 .setQualitative(true)
259 .setDomain(DOMAIN_DOCUMENTATION)
260 .setFormula(new SumChildValuesFormula(false))
261 .setBestValue(0.0)
262 .setOptimizedBestValue(true)
263 .create();
264
265 // --------------------------------------------------------------------------------------------------------------------
266 //
267 // COMPLEXITY
268 //
269 // --------------------------------------------------------------------------------------------------------------------
270
271 public static final String COMPLEXITY_KEY = "complexity";
272 public static final Metric COMPLEXITY = new Metric.Builder(COMPLEXITY_KEY, "Complexity", Metric.ValueType.INT)
273 .setDescription("Cyclomatic complexity")
274 .setDirection(Metric.DIRECTION_WORST)
275 .setQualitative(false)
276 .setDomain(DOMAIN_COMPLEXITY)
277 .setFormula(new SumChildValuesFormula(false))
278 .create();
279
280 public static final String FILE_COMPLEXITY_KEY = "file_complexity";
281 public static final Metric FILE_COMPLEXITY = new Metric.Builder(FILE_COMPLEXITY_KEY, "Complexity /file", Metric.ValueType.FLOAT)
282 .setDescription("Complexity average by file")
283 .setDirection(Metric.DIRECTION_WORST)
284 .setQualitative(true)
285 .setDomain(DOMAIN_COMPLEXITY)
286 .setFormula(AverageFormula.create(CoreMetrics.COMPLEXITY, CoreMetrics.FILES))
287 .create();
288
289 /**
290 * @since 3.6
291 */
292 public static final String COMPLEXITY_IN_CLASSES_KEY = "complexity_in_classes";
293
294 /**
295 * @since 3.6
296 */
297 public static final Metric COMPLEXITY_IN_CLASSES = new Metric.Builder(COMPLEXITY_IN_CLASSES_KEY, "Complexity in classes", Metric.ValueType.INT)
298 .setDescription("Cyclomatic complexity in classes")
299 .setDirection(Metric.DIRECTION_WORST)
300 .setQualitative(false)
301 .setDomain(DOMAIN_COMPLEXITY)
302 .setFormula(new SumChildValuesFormula(false))
303 .setDeleteHistoricalData(true)
304 .create();
305
306 public static final String CLASS_COMPLEXITY_KEY = "class_complexity";
307
308 /**
309 * Information about the cyclomatic complexity per class, calculated by divided the complexity in classes by the number of classes.
310 * If the complexity in classes is not available, the complexity of the file is used.
311 */
312 public static final Metric CLASS_COMPLEXITY = new Metric.Builder(CLASS_COMPLEXITY_KEY, "Complexity /class", Metric.ValueType.FLOAT)
313 .setDescription("Complexity average by class")
314 .setDirection(Metric.DIRECTION_WORST)
315 .setQualitative(true)
316 .setDomain(DOMAIN_COMPLEXITY)
317 .setFormula(AverageFormula.create(CoreMetrics.COMPLEXITY_IN_CLASSES, CoreMetrics.CLASSES).setFallbackForMainMetric(CoreMetrics.COMPLEXITY))
318 .create();
319
320 /**
321 * @since 3.6
322 */
323 public static final String COMPLEXITY_IN_FUNCTIONS_KEY = "complexity_in_functions";
324
325 /**
326 * @since 3.6
327 */
328 public static final Metric COMPLEXITY_IN_FUNCTIONS = new Metric.Builder(COMPLEXITY_IN_FUNCTIONS_KEY, "Complexity in functions", Metric.ValueType.INT)
329 .setDescription("Cyclomatic complexity in functions")
330 .setDirection(Metric.DIRECTION_WORST)
331 .setQualitative(false)
332 .setDomain(DOMAIN_COMPLEXITY)
333 .setFormula(new SumChildValuesFormula(false))
334 .setDeleteHistoricalData(true)
335 .create();
336
337 public static final String FUNCTION_COMPLEXITY_KEY = "function_complexity";
338
339 /**
340 * Information about the cyclomatic complexity per function, calculated by divided the complexity in functions by the number of functions.
341 * If the complexity in functions is not available, the complexity of the file is used.
342 */
343 public static final Metric FUNCTION_COMPLEXITY = new Metric.Builder(FUNCTION_COMPLEXITY_KEY, "Complexity /function", Metric.ValueType.FLOAT)
344 .setDescription("Complexity average by function")
345 .setDirection(Metric.DIRECTION_WORST)
346 .setQualitative(true)
347 .setDomain(DOMAIN_COMPLEXITY)
348 .setFormula(AverageFormula.create(CoreMetrics.COMPLEXITY_IN_FUNCTIONS, CoreMetrics.FUNCTIONS).setFallbackForMainMetric(CoreMetrics.COMPLEXITY))
349 .create();
350
351 /**
352 * @deprecated in 3.0 - see SONAR-3289
353 */
354 @Deprecated
355 public static final String CLASS_COMPLEXITY_DISTRIBUTION_KEY = "class_complexity_distribution";
356
357 /**
358 * @deprecated in 3.0 - see SONAR-3289
359 */
360 @Deprecated
361 public static final Metric CLASS_COMPLEXITY_DISTRIBUTION = new Metric.Builder(CLASS_COMPLEXITY_DISTRIBUTION_KEY, "Classes distribution /complexity", Metric.ValueType.DISTRIB)
362 .setDescription("Classes distribution /complexity")
363 .setDirection(Metric.DIRECTION_NONE)
364 .setQualitative(true)
365 .setDomain(DOMAIN_COMPLEXITY)
366 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
367 .create();
368
369 public static final String FUNCTION_COMPLEXITY_DISTRIBUTION_KEY = "function_complexity_distribution";
370 public static final Metric FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Functions distribution /complexity",
371 Metric.ValueType.DISTRIB)
372 .setDescription("Functions distribution /complexity")
373 .setDirection(Metric.DIRECTION_NONE)
374 .setQualitative(true)
375 .setDomain(DOMAIN_COMPLEXITY)
376 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
377 .create();
378
379 public static final String FILE_COMPLEXITY_DISTRIBUTION_KEY = "file_complexity_distribution";
380 public static final Metric FILE_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FILE_COMPLEXITY_DISTRIBUTION_KEY, "Files distribution /complexity", Metric.ValueType.DISTRIB)
381 .setDescription("Files distribution /complexity")
382 .setDirection(Metric.DIRECTION_NONE)
383 .setQualitative(true)
384 .setDomain(DOMAIN_COMPLEXITY)
385 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
386 .create();
387
388 // --------------------------------------------------------------------------------------------------------------------
389 //
390 // UNIT TESTS
391 //
392 // --------------------------------------------------------------------------------------------------------------------
393
394 public static final String TESTS_KEY = "tests";
395
396 /**
397 * Value of measure for this metric can be saved from Sensor, taking into account following rules:
398 * <ul>
399 * <li>If tool (like Maven Surefire Plugin) has not been activated to run unit tests, then Sensor should not save anything. For example there is no such tool for COBOL.</li>
400 * <li>If tool has been activated, but there was no unit tests to run, then zero value should be saved for project.</li>
401 * <li>Non-zero value should be saved for resources representing tests. And Sonar provides default Decorator, which will decorate parent resources.</li>
402 * <li>Should include {@link #TEST_FAILURES} and {@link #TEST_ERRORS}, but should not include {@link #SKIPPED_TESTS}.</li>
403 * </ul>
404 */
405 public static final Metric TESTS = new Metric.Builder(TESTS_KEY, "Unit tests", Metric.ValueType.INT)
406 .setDescription("Number of unit tests")
407 .setDirection(Metric.DIRECTION_WORST)
408 .setQualitative(false)
409 .setDomain(DOMAIN_TESTS)
410 .create();
411
412 public static final String TEST_EXECUTION_TIME_KEY = "test_execution_time";
413 public static final Metric TEST_EXECUTION_TIME = new Metric.Builder(TEST_EXECUTION_TIME_KEY, "Unit tests duration", Metric.ValueType.MILLISEC)
414 .setDescription("Execution duration of unit tests")
415 .setDirection(Metric.DIRECTION_WORST)
416 .setQualitative(false)
417 .setDomain(DOMAIN_TESTS)
418 .create();
419
420 public static final String TEST_ERRORS_KEY = "test_errors";
421 public static final Metric TEST_ERRORS = new Metric.Builder(TEST_ERRORS_KEY, "Unit test errors", Metric.ValueType.INT)
422 .setDescription("Number of unit test errors")
423 .setDirection(Metric.DIRECTION_WORST)
424 .setQualitative(true)
425 .setDomain(DOMAIN_TESTS)
426 .setBestValue(0.0)
427 .setOptimizedBestValue(true)
428 .create();
429
430 public static final String SKIPPED_TESTS_KEY = "skipped_tests";
431 public static final Metric SKIPPED_TESTS = new Metric.Builder(SKIPPED_TESTS_KEY, "Skipped unit tests", Metric.ValueType.INT)
432 .setDescription("Number of skipped unit tests")
433 .setDirection(Metric.DIRECTION_WORST)
434 .setQualitative(true)
435 .setDomain(DOMAIN_TESTS)
436 .setBestValue(0.0)
437 .setOptimizedBestValue(true)
438 .create();
439
440 public static final String TEST_FAILURES_KEY = "test_failures";
441 public static final Metric TEST_FAILURES = new Metric.Builder(TEST_FAILURES_KEY, "Unit test failures", Metric.ValueType.INT)
442 .setDescription("Number of unit test failures")
443 .setDirection(Metric.DIRECTION_WORST)
444 .setQualitative(true)
445 .setDomain(DOMAIN_TESTS)
446 .setBestValue(0.0)
447 .setOptimizedBestValue(true)
448 .create();
449
450 public static final String TEST_SUCCESS_DENSITY_KEY = "test_success_density";
451 public static final Metric TEST_SUCCESS_DENSITY = new Metric.Builder(TEST_SUCCESS_DENSITY_KEY, "Unit test success (%)", Metric.ValueType.PERCENT)
452 .setDescription("Density of successful unit tests")
453 .setDirection(Metric.DIRECTION_BETTER)
454 .setQualitative(true)
455 .setDomain(DOMAIN_TESTS)
456 .setWorstValue(0.0)
457 .setBestValue(100.0)
458 .setOptimizedBestValue(true)
459 .create();
460
461 public static final String TEST_DATA_KEY = "test_data";
462 public static final Metric TEST_DATA = new Metric.Builder(TEST_DATA_KEY, "Unit tests details", Metric.ValueType.DATA)
463 .setDescription("Unit tests details")
464 .setDirection(Metric.DIRECTION_WORST)
465 .setDomain(DOMAIN_TESTS)
466 .create();
467
468 public static final String COVERAGE_KEY = "coverage";
469 public static final Metric COVERAGE = new Metric.Builder(COVERAGE_KEY, "Coverage", Metric.ValueType.PERCENT)
470 .setDescription("Coverage by unit tests")
471 .setDirection(Metric.DIRECTION_BETTER)
472 .setQualitative(true)
473 .setDomain(DOMAIN_TESTS)
474 .setWorstValue(0.0)
475 .setBestValue(100.0)
476 .create();
477
478 public static final String NEW_COVERAGE_KEY = "new_coverage";
479 public static final Metric NEW_COVERAGE = new Metric.Builder(NEW_COVERAGE_KEY, "Coverage on new code", Metric.ValueType.PERCENT)
480 .setDescription("Coverage of new/changed code")
481 .setDirection(Metric.DIRECTION_BETTER)
482 .setQualitative(true)
483 .setDomain(DOMAIN_TESTS)
484 .setWorstValue(0.0)
485 .setBestValue(100.0)
486 .setDeleteHistoricalData(true)
487 .create();
488
489 public static final String LINES_TO_COVER_KEY = "lines_to_cover";
490
491 /**
492 * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
493 */
494 public static final Metric LINES_TO_COVER = new Metric.Builder(LINES_TO_COVER_KEY, "Lines to cover", Metric.ValueType.INT)
495 .setDescription("Lines to cover")
496 .setDirection(Metric.DIRECTION_BETTER)
497 .setQualitative(false)
498 .setDomain(DOMAIN_TESTS)
499 .setFormula(new SumChildValuesFormula(false))
500 .create();
501
502 public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover";
503 public static final Metric NEW_LINES_TO_COVER = new Metric.Builder(NEW_LINES_TO_COVER_KEY, "Lines to cover on new code", Metric.ValueType.INT)
504 .setDescription("Lines to cover on new code")
505 .setDirection(Metric.DIRECTION_WORST)
506 .setQualitative(false)
507 .setDomain(DOMAIN_TESTS)
508 .setFormula(new SumChildValuesFormula(false))
509 .setDeleteHistoricalData(true)
510 .create();
511
512 public static final String UNCOVERED_LINES_KEY = "uncovered_lines";
513
514 /**
515 * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
516 */
517 public static final Metric UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, "Uncovered lines", Metric.ValueType.INT)
518 .setDescription("Uncovered lines")
519 .setDirection(Metric.DIRECTION_WORST)
520 .setDomain(DOMAIN_TESTS)
521 .setFormula(new SumChildValuesFormula(false))
522 .setBestValue(0.0)
523 .create();
524
525 public static final String NEW_UNCOVERED_LINES_KEY = "new_uncovered_lines";
526 public static final Metric NEW_UNCOVERED_LINES = new Metric.Builder(NEW_UNCOVERED_LINES_KEY, "Uncovered lines on new code", Metric.ValueType.INT)
527 .setDescription("Uncovered lines on new code")
528 .setDirection(Metric.DIRECTION_WORST)
529 .setDomain(DOMAIN_TESTS)
530 .setFormula(new SumChildValuesFormula(false))
531 .setBestValue(0.0)
532 .setDeleteHistoricalData(true)
533 .create();
534
535 public static final String LINE_COVERAGE_KEY = "line_coverage";
536 public static final Metric LINE_COVERAGE = new Metric.Builder(LINE_COVERAGE_KEY, "Line coverage", Metric.ValueType.PERCENT)
537 .setDescription("Line coverage")
538 .setDirection(Metric.DIRECTION_BETTER)
539 .setQualitative(true)
540 .setDomain(DOMAIN_TESTS)
541 .setWorstValue(0.0)
542 .setBestValue(100.0)
543 .create();
544
545 public static final String NEW_LINE_COVERAGE_KEY = "new_line_coverage";
546 public static final Metric NEW_LINE_COVERAGE = new Metric.Builder(NEW_LINE_COVERAGE_KEY, "Line coverage on new code", Metric.ValueType.PERCENT)
547 .setDescription("Line coverage of added/changed code")
548 .setDirection(Metric.DIRECTION_BETTER)
549 .setQualitative(true)
550 .setWorstValue(0.0)
551 .setBestValue(100.0)
552 .setDomain(DOMAIN_TESTS)
553 .setDeleteHistoricalData(true)
554 .create();
555
556 public static final String COVERAGE_LINE_HITS_DATA_KEY = "coverage_line_hits_data";
557
558 /**
559 * Key-value pairs, where key - is a number of line, and value - is a number of hits for this line.
560 * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
561 */
562 public static final Metric COVERAGE_LINE_HITS_DATA = new Metric.Builder(COVERAGE_LINE_HITS_DATA_KEY, "Coverage hits by line", Metric.ValueType.DATA)
563 .setDomain(DOMAIN_TESTS)
564 .setDeleteHistoricalData(true)
565 .create();
566
567 public static final String CONDITIONS_TO_COVER_KEY = "conditions_to_cover";
568
569 /**
570 * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
571 */
572 public static final Metric CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, "Branches to cover", Metric.ValueType.INT)
573 .setDescription("Branches to cover")
574 .setDomain(DOMAIN_TESTS)
575 .setFormula(new SumChildValuesFormula(false))
576 .setHidden(true)
577 .create();
578
579 public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover";
580 public static final Metric NEW_CONDITIONS_TO_COVER = new Metric.Builder(NEW_CONDITIONS_TO_COVER_KEY, "Branches to cover on new code", Metric.ValueType.INT)
581 .setDescription("Branches to cover on new code")
582 .setDomain(DOMAIN_TESTS)
583 .setFormula(new SumChildValuesFormula(false))
584 .setDeleteHistoricalData(true)
585 .setHidden(true)
586 .create();
587
588 public static final String UNCOVERED_CONDITIONS_KEY = "uncovered_conditions";
589
590 /**
591 * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
592 */
593 public static final Metric UNCOVERED_CONDITIONS = new Metric.Builder(UNCOVERED_CONDITIONS_KEY, "Uncovered branches", Metric.ValueType.INT)
594 .setDescription("Uncovered branches")
595 .setDirection(Metric.DIRECTION_WORST)
596 .setDomain(DOMAIN_TESTS)
597 .setFormula(new SumChildValuesFormula(false))
598 .setBestValue(0.0)
599 .create();
600
601 public static final String NEW_UNCOVERED_CONDITIONS_KEY = "new_uncovered_conditions";
602 public static final Metric NEW_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_UNCOVERED_CONDITIONS_KEY, "Uncovered branches on new code", Metric.ValueType.INT)
603 .setDescription("Uncovered branches on new code")
604 .setDirection(Metric.DIRECTION_WORST)
605 .setDomain(DOMAIN_TESTS)
606 .setFormula(new SumChildValuesFormula(false))
607 .setBestValue(0.0)
608 .setDeleteHistoricalData(true)
609 .create();
610
611 public static final String BRANCH_COVERAGE_KEY = "branch_coverage";
612 public static final Metric BRANCH_COVERAGE = new Metric.Builder(BRANCH_COVERAGE_KEY, "Branch coverage", Metric.ValueType.PERCENT)
613 .setDescription("Branch coverage")
614 .setDirection(Metric.DIRECTION_BETTER)
615 .setQualitative(true)
616 .setDomain(DOMAIN_TESTS)
617 .setWorstValue(0.0)
618 .setBestValue(100.0)
619 .create();
620
621 public static final String NEW_BRANCH_COVERAGE_KEY = "new_branch_coverage";
622 public static final Metric NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, "Branch coverage on new code", Metric.ValueType.PERCENT)
623 .setDescription("Branch coverage of new/changed code")
624 .setDirection(Metric.DIRECTION_BETTER)
625 .setQualitative(true)
626 .setDomain(DOMAIN_TESTS)
627 .setWorstValue(0.0)
628 .setBestValue(100.0)
629 .setDeleteHistoricalData(true)
630 .create();
631
632 /**
633 * @deprecated in 2.7. Replaced by {@link #CONDITIONS_BY_LINE_KEY} and {@link #COVERED_CONDITIONS_BY_LINE_KEY}
634 */
635 @Deprecated
636 public static final String BRANCH_COVERAGE_HITS_DATA_KEY = "branch_coverage_hits_data";
637
638 /**
639 * @deprecated in 2.7. Replaced by metrics {@link #CONDITIONS_BY_LINE} and {@link #COVERED_CONDITIONS_BY_LINE}
640 */
641 @Deprecated
642 public static final Metric BRANCH_COVERAGE_HITS_DATA = new Metric.Builder(BRANCH_COVERAGE_HITS_DATA_KEY, "Branch coverage hits", Metric.ValueType.DATA)
643 .setDomain(DOMAIN_TESTS)
644 .setDeleteHistoricalData(true)
645 .create();
646
647 public static final String CONDITIONS_BY_LINE_KEY = "conditions_by_line";
648
649 /**
650 * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
651 *
652 * @since 2.7
653 */
654 public static final Metric CONDITIONS_BY_LINE = new Metric.Builder(CONDITIONS_BY_LINE_KEY, "Conditions by line", Metric.ValueType.DATA)
655 .setDomain(DOMAIN_TESTS)
656 .setDeleteHistoricalData(true)
657 .create();
658
659 public static final String COVERED_CONDITIONS_BY_LINE_KEY = "covered_conditions_by_line";
660
661 /**
662 * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
663 *
664 * @since 2.7
665 */
666 public static final Metric COVERED_CONDITIONS_BY_LINE = new Metric.Builder(COVERED_CONDITIONS_BY_LINE_KEY, "Covered conditions by line", Metric.ValueType.DATA)
667 .setDomain(DOMAIN_TESTS)
668 .setDeleteHistoricalData(true)
669 .create();
670
671 // --------------------------------------------------------------------------------------------------------------------
672 //
673 // INTEGRATION TESTS
674 //
675 // --------------------------------------------------------------------------------------------------------------------
676
677 /**
678 * @since 2.12
679 */
680 public static final String IT_COVERAGE_KEY = "it_coverage";
681
682 /**
683 * @since 2.12
684 */
685 public static final Metric IT_COVERAGE = new Metric.Builder(IT_COVERAGE_KEY, "IT coverage", Metric.ValueType.PERCENT)
686 .setDescription("Coverage by integration tests")
687 .setDirection(Metric.DIRECTION_BETTER)
688 .setQualitative(true)
689 .setDomain(DOMAIN_INTEGRATION_TESTS)
690 .setWorstValue(0.0)
691 .setBestValue(100.0)
692 .create();
693
694 /**
695 * @since 2.12
696 */
697 public static final String NEW_IT_COVERAGE_KEY = "new_it_coverage";
698
699 /**
700 * @since 2.12
701 */
702 public static final Metric NEW_IT_COVERAGE = new Metric.Builder(NEW_IT_COVERAGE_KEY, "Coverage by IT on new code", Metric.ValueType.PERCENT)
703 .setDescription("Integration Tests Coverage of new/changed code")
704 .setDirection(Metric.DIRECTION_BETTER)
705 .setQualitative(true)
706 .setDomain(DOMAIN_INTEGRATION_TESTS)
707 .setWorstValue(0.0)
708 .setBestValue(100.0)
709 .setDeleteHistoricalData(true)
710 .create();
711
712 /**
713 * @since 2.12
714 */
715 public static final String IT_LINES_TO_COVER_KEY = "it_lines_to_cover";
716
717 /**
718 * @since 2.12
719 */
720 public static final Metric IT_LINES_TO_COVER = new Metric.Builder(IT_LINES_TO_COVER_KEY, "IT lines to cover", Metric.ValueType.INT)
721 .setDescription("Lines to cover by Integration Tests")
722 .setDirection(Metric.DIRECTION_BETTER)
723 .setDomain(DOMAIN_INTEGRATION_TESTS)
724 .setQualitative(false)
725 .setFormula(new SumChildValuesFormula(false))
726 .setHidden(true)
727 .setDeleteHistoricalData(true)
728 .create();
729
730 /**
731 * @since 2.12
732 */
733 public static final String NEW_IT_LINES_TO_COVER_KEY = "new_it_lines_to_cover";
734
735 /**
736 * @since 2.12
737 */
738 public static final Metric NEW_IT_LINES_TO_COVER = new Metric.Builder(NEW_IT_LINES_TO_COVER_KEY, "Lines to cover by IT on new code", Metric.ValueType.INT)
739 .setDescription("Lines to cover by Integration Tests on new code")
740 .setDirection(Metric.DIRECTION_WORST)
741 .setQualitative(false)
742 .setDomain(DOMAIN_INTEGRATION_TESTS)
743 .setFormula(new SumChildValuesFormula(false))
744 .setDeleteHistoricalData(true)
745 .create();
746
747 /**
748 * @since 2.12
749 */
750 public static final String IT_UNCOVERED_LINES_KEY = "it_uncovered_lines";
751
752 /**
753 * @since 2.12
754 */
755 public static final Metric IT_UNCOVERED_LINES = new Metric.Builder(IT_UNCOVERED_LINES_KEY, "IT uncovered lines", Metric.ValueType.INT)
756 .setDescription("IT uncovered lines")
757 .setDirection(Metric.DIRECTION_WORST)
758 .setQualitative(false)
759 .setDomain(DOMAIN_INTEGRATION_TESTS)
760 .setFormula(new SumChildValuesFormula(false))
761 .create();
762
763 /**
764 * @since 2.12
765 */
766 public static final String NEW_IT_UNCOVERED_LINES_KEY = "new_it_uncovered_lines";
767
768 /**
769 * @since 2.12
770 */
771 public static final Metric NEW_IT_UNCOVERED_LINES = new Metric.Builder(NEW_IT_UNCOVERED_LINES_KEY, "Uncovered lines by IT on new code", Metric.ValueType.INT)
772 .setDescription("Uncovered lines by IT on new code")
773 .setDirection(Metric.DIRECTION_WORST)
774 .setDomain(DOMAIN_INTEGRATION_TESTS)
775 .setFormula(new SumChildValuesFormula(false))
776 .setBestValue(0.0)
777 .setDeleteHistoricalData(true)
778 .create();
779
780 /**
781 * @since 2.12
782 */
783 public static final String IT_LINE_COVERAGE_KEY = "it_line_coverage";
784
785 /**
786 * @since 2.12
787 */
788 public static final Metric IT_LINE_COVERAGE = new Metric.Builder(IT_LINE_COVERAGE_KEY, "IT line coverage", Metric.ValueType.PERCENT)
789 .setDescription("IT line coverage")
790 .setDirection(Metric.DIRECTION_BETTER)
791 .setQualitative(true)
792 .setDomain(DOMAIN_INTEGRATION_TESTS)
793 .create();
794
795 /**
796 * @since 2.12
797 */
798 public static final String NEW_IT_LINE_COVERAGE_KEY = "new_it_line_coverage";
799
800 /**
801 * @since 2.12
802 */
803 public static final Metric NEW_IT_LINE_COVERAGE = new Metric.Builder(NEW_IT_LINE_COVERAGE_KEY, "Line coverage by IT on new code", Metric.ValueType.PERCENT)
804 .setDescription("Line Coverage by Integration Tests of added/changed code")
805 .setDirection(Metric.DIRECTION_BETTER)
806 .setQualitative(true)
807 .setWorstValue(0.0)
808 .setBestValue(100.0)
809 .setDomain(DOMAIN_INTEGRATION_TESTS)
810 .setDeleteHistoricalData(true)
811 .create();
812
813 /**
814 * @since 2.12
815 */
816 public static final String IT_COVERAGE_LINE_HITS_DATA_KEY = "it_coverage_line_hits_data";
817
818 /**
819 * @since 2.12
820 */
821 public static final Metric IT_COVERAGE_LINE_HITS_DATA = new Metric.Builder(IT_COVERAGE_LINE_HITS_DATA_KEY, "IT coverage hits data", Metric.ValueType.DATA)
822 .setDescription("Integration Tests Code coverage line hits data")
823 .setDirection(Metric.DIRECTION_NONE)
824 .setQualitative(false)
825 .setDomain(DOMAIN_INTEGRATION_TESTS)
826 .setDeleteHistoricalData(true)
827 .create();
828
829 /**
830 * @since 2.12
831 */
832 public static final String IT_CONDITIONS_TO_COVER_KEY = "it_conditions_to_cover";
833
834 /**
835 * @since 2.12
836 */
837 public static final Metric IT_CONDITIONS_TO_COVER = new Metric.Builder(IT_CONDITIONS_TO_COVER_KEY, "IT branches to cover", Metric.ValueType.INT)
838 .setDescription("Integration Tests conditions to cover")
839 .setDirection(Metric.DIRECTION_BETTER)
840 .setQualitative(false)
841 .setDomain(DOMAIN_INTEGRATION_TESTS)
842 .setFormula(new SumChildValuesFormula(false))
843 .setHidden(true)
844 .create();
845
846 /**
847 * @since 2.12
848 */
849 public static final String NEW_IT_CONDITIONS_TO_COVER_KEY = "new_it_conditions_to_cover";
850
851 /**
852 * @since 2.12
853 */
854 public static final Metric NEW_IT_CONDITIONS_TO_COVER = new Metric.Builder(NEW_IT_CONDITIONS_TO_COVER_KEY, "Branches to cover by IT on new code", Metric.ValueType.INT)
855 .setDescription("Branches to cover by Integration Tests on new code")
856 .setDomain(DOMAIN_INTEGRATION_TESTS)
857 .setFormula(new SumChildValuesFormula(false))
858 .setDeleteHistoricalData(true)
859 .setHidden(true)
860 .create();
861
862 /**
863 * @since 2.12
864 */
865 public static final String IT_UNCOVERED_CONDITIONS_KEY = "it_uncovered_conditions";
866
867 /**
868 * @since 2.12
869 */
870 public static final Metric IT_UNCOVERED_CONDITIONS = new Metric.Builder(IT_UNCOVERED_CONDITIONS_KEY, "IT uncovered branches", Metric.ValueType.INT)
871 .setDescription("Integration Tests uncovered conditions")
872 .setDirection(Metric.DIRECTION_WORST)
873 .setDomain(DOMAIN_INTEGRATION_TESTS)
874 .setFormula(new SumChildValuesFormula(false))
875 .create();
876
877 /**
878 * @since 2.12
879 */
880 public static final String NEW_IT_UNCOVERED_CONDITIONS_KEY = "new_it_uncovered_conditions";
881
882 /**
883 * @since 2.12
884 */
885 public static final Metric NEW_IT_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_IT_UNCOVERED_CONDITIONS_KEY, "Uncovered branches by IT on new code", Metric.ValueType.INT)
886 .setDescription("Uncovered branches by Integration Tests on new code")
887 .setDirection(Metric.DIRECTION_WORST)
888 .setDomain(DOMAIN_INTEGRATION_TESTS)
889 .setFormula(new SumChildValuesFormula(false))
890 .setBestValue(0.0)
891 .setDeleteHistoricalData(true)
892 .create();
893
894 /**
895 * @since 2.12
896 */
897 public static final String IT_BRANCH_COVERAGE_KEY = "it_branch_coverage";
898
899 /**
900 * @since 2.12
901 */
902 public static final Metric IT_BRANCH_COVERAGE = new Metric.Builder(IT_BRANCH_COVERAGE_KEY, "IT branch coverage", Metric.ValueType.PERCENT)
903 .setDescription("IT Branch coverage")
904 .setDirection(Metric.DIRECTION_BETTER)
905 .setQualitative(true)
906 .setDomain(DOMAIN_INTEGRATION_TESTS)
907 .setWorstValue(0.0)
908 .setBestValue(100.0)
909 .create();
910
911 /**
912 * @since 2.12
913 */
914 public static final String NEW_IT_BRANCH_COVERAGE_KEY = "new_it_branch_coverage";
915
916 /**
917 * @since 2.12
918 */
919 public static final Metric NEW_IT_BRANCH_COVERAGE = new Metric.Builder(NEW_IT_BRANCH_COVERAGE_KEY, "Branch coverage by IT on new code", Metric.ValueType.PERCENT)
920 .setDescription("Branch coverage by Integration Tests of new/changed code")
921 .setDirection(Metric.DIRECTION_BETTER)
922 .setQualitative(true)
923 .setDomain(DOMAIN_INTEGRATION_TESTS)
924 .setWorstValue(0.0)
925 .setBestValue(100.0)
926 .setDeleteHistoricalData(true)
927 .create();
928
929 /**
930 * @since 2.12
931 */
932 public static final String IT_CONDITIONS_BY_LINE_KEY = "it_conditions_by_line";
933
934 /**
935 * @since 2.12
936 */
937 public static final Metric IT_CONDITIONS_BY_LINE = new Metric.Builder(IT_CONDITIONS_BY_LINE_KEY, "IT branches by line", Metric.ValueType.DATA)
938 .setDomain(DOMAIN_INTEGRATION_TESTS)
939 .setDeleteHistoricalData(true)
940 .create();
941
942 /**
943 * @since 2.12
944 */
945 public static final String IT_COVERED_CONDITIONS_BY_LINE_KEY = "it_covered_conditions_by_line";
946
947 /**
948 * @since 2.12
949 */
950 public static final Metric IT_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(IT_COVERED_CONDITIONS_BY_LINE_KEY, "IT covered branches by line", Metric.ValueType.DATA)
951 .setDomain(DOMAIN_INTEGRATION_TESTS)
952 .setDeleteHistoricalData(true)
953 .create();
954
955 // --------------------------------------------------------------------------------------------------------------------
956 //
957 // OVERALL TESTS
958 //
959 // --------------------------------------------------------------------------------------------------------------------
960
961 /**
962 * @since 3.3
963 */
964 public static final String OVERALL_COVERAGE_KEY = "overall_coverage";
965
966 /**
967 * @since 3.3
968 */
969 public static final Metric OVERALL_COVERAGE = new Metric.Builder(OVERALL_COVERAGE_KEY, "Overall coverage", Metric.ValueType.PERCENT)
970 .setDescription("Overall test coverage")
971 .setDirection(Metric.DIRECTION_BETTER)
972 .setQualitative(true)
973 .setDomain(DOMAIN_OVERALL_TESTS)
974 .setWorstValue(0.0)
975 .setBestValue(100.0)
976 .create();
977
978 /**
979 * @since 3.3
980 */
981 public static final String NEW_OVERALL_COVERAGE_KEY = "new_overall_coverage";
982
983 /**
984 * @since 3.3
985 */
986 public static final Metric NEW_OVERALL_COVERAGE = new Metric.Builder(NEW_OVERALL_COVERAGE_KEY, "Overall coverage on new code", Metric.ValueType.PERCENT)
987 .setDescription("Overall coverage of new/changed code")
988 .setDirection(Metric.DIRECTION_BETTER)
989 .setQualitative(true)
990 .setDomain(DOMAIN_OVERALL_TESTS)
991 .setWorstValue(0.0)
992 .setBestValue(100.0)
993 .setDeleteHistoricalData(true)
994 .create();
995
996 /**
997 * @since 3.3
998 */
999 public static final String OVERALL_LINES_TO_COVER_KEY = "overall_lines_to_cover";
1000
1001 /**
1002 * @since 3.3
1003 */
1004 public static final Metric OVERALL_LINES_TO_COVER = new Metric.Builder(OVERALL_LINES_TO_COVER_KEY, "Overall lines to cover", Metric.ValueType.INT)
1005 .setDescription("Overall lines to cover by all tests")
1006 .setDirection(Metric.DIRECTION_BETTER)
1007 .setDomain(DOMAIN_OVERALL_TESTS)
1008 .setQualitative(false)
1009 .setFormula(new SumChildValuesFormula(false))
1010 .setHidden(true)
1011 .setDeleteHistoricalData(true)
1012 .create();
1013
1014 /**
1015 * @since 3.3
1016 */
1017 public static final String NEW_OVERALL_LINES_TO_COVER_KEY = "new_overall_lines_to_cover";
1018
1019 /**
1020 * @since 3.3
1021 */
1022 public static final Metric NEW_OVERALL_LINES_TO_COVER = new Metric.Builder(NEW_OVERALL_LINES_TO_COVER_KEY, "Overall lines to cover on new code", Metric.ValueType.INT)
1023 .setDescription("New lines to cover by all tests")
1024 .setDirection(Metric.DIRECTION_WORST)
1025 .setQualitative(false)
1026 .setDomain(DOMAIN_OVERALL_TESTS)
1027 .setFormula(new SumChildValuesFormula(false))
1028 .setDeleteHistoricalData(true)
1029 .create();
1030
1031 /**
1032 * @since 3.3
1033 */
1034 public static final String OVERALL_UNCOVERED_LINES_KEY = "overall_uncovered_lines";
1035
1036 /**
1037 * @since 3.3
1038 */
1039 public static final Metric OVERALL_UNCOVERED_LINES = new Metric.Builder(OVERALL_UNCOVERED_LINES_KEY, "Overall uncovered lines", Metric.ValueType.INT)
1040 .setDescription("Uncovered lines by all tests")
1041 .setDirection(Metric.DIRECTION_WORST)
1042 .setQualitative(false)
1043 .setDomain(DOMAIN_OVERALL_TESTS)
1044 .setFormula(new SumChildValuesFormula(false))
1045 .create();
1046
1047 /**
1048 * @since 3.3
1049 */
1050 public static final String NEW_OVERALL_UNCOVERED_LINES_KEY = "new_overall_uncovered_lines";
1051
1052 /**
1053 * @since 3.3
1054 */
1055 public static final Metric NEW_OVERALL_UNCOVERED_LINES = new Metric.Builder(NEW_OVERALL_UNCOVERED_LINES_KEY, "Overall uncovered lines on new code", Metric.ValueType.INT)
1056 .setDescription("New lines that are not covered by any tests")
1057 .setDirection(Metric.DIRECTION_WORST)
1058 .setDomain(DOMAIN_OVERALL_TESTS)
1059 .setFormula(new SumChildValuesFormula(false))
1060 .setBestValue(0.0)
1061 .setDeleteHistoricalData(true)
1062 .create();
1063
1064 /**
1065 * @since 3.3
1066 */
1067 public static final String OVERALL_LINE_COVERAGE_KEY = "overall_line_coverage";
1068
1069 /**
1070 * @since 3.3
1071 */
1072 public static final Metric OVERALL_LINE_COVERAGE = new Metric.Builder(OVERALL_LINE_COVERAGE_KEY, "Overall line coverage", Metric.ValueType.PERCENT)
1073 .setDescription("Line coverage by all tests")
1074 .setDirection(Metric.DIRECTION_BETTER)
1075 .setQualitative(true)
1076 .setDomain(DOMAIN_OVERALL_TESTS)
1077 .create();
1078
1079 /**
1080 * @since 3.3
1081 */
1082 public static final String NEW_OVERALL_LINE_COVERAGE_KEY = "new_overall_line_coverage";
1083
1084 /**
1085 * @since 3.3
1086 */
1087 public static final Metric NEW_OVERALL_LINE_COVERAGE = new Metric.Builder(NEW_OVERALL_LINE_COVERAGE_KEY, "Overall line coverage on new code", Metric.ValueType.PERCENT)
1088 .setDescription("Line coverage of added/changed code by all tests")
1089 .setDirection(Metric.DIRECTION_BETTER)
1090 .setQualitative(true)
1091 .setWorstValue(0.0)
1092 .setBestValue(100.0)
1093 .setDomain(DOMAIN_OVERALL_TESTS)
1094 .setDeleteHistoricalData(true)
1095 .create();
1096
1097 /**
1098 * @since 3.3
1099 */
1100 public static final String OVERALL_COVERAGE_LINE_HITS_DATA_KEY = "overall_coverage_line_hits_data";
1101
1102 /**
1103 * @since 3.3
1104 */
1105 public static final Metric OVERALL_COVERAGE_LINE_HITS_DATA = new Metric.Builder(OVERALL_COVERAGE_LINE_HITS_DATA_KEY, "Overall coverage hits by line", Metric.ValueType.DATA)
1106 .setDescription("Coverage hits by all tests and by line")
1107 .setDirection(Metric.DIRECTION_NONE)
1108 .setQualitative(false)
1109 .setDomain(DOMAIN_OVERALL_TESTS)
1110 .setDeleteHistoricalData(true)
1111 .create();
1112
1113 /**
1114 * @since 3.3
1115 */
1116 public static final String OVERALL_CONDITIONS_TO_COVER_KEY = "overall_conditions_to_cover";
1117
1118 /**
1119 * @since 3.3
1120 */
1121 public static final Metric OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(OVERALL_CONDITIONS_TO_COVER_KEY, "Overall branches to cover", Metric.ValueType.INT)
1122 .setDescription("Branches to cover by all tests")
1123 .setDirection(Metric.DIRECTION_BETTER)
1124 .setQualitative(false)
1125 .setDomain(DOMAIN_OVERALL_TESTS)
1126 .setFormula(new SumChildValuesFormula(false))
1127 .setHidden(true)
1128 .create();
1129
1130 /**
1131 * @since 3.3
1132 */
1133 public static final String NEW_OVERALL_CONDITIONS_TO_COVER_KEY = "new_overall_conditions_to_cover";
1134
1135 /**
1136 * @since 3.3
1137 */
1138 public static final Metric NEW_OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(NEW_OVERALL_CONDITIONS_TO_COVER_KEY, "Overall branches to cover on new code",
1139 Metric.ValueType.INT)
1140 .setDescription("New branches to cover by all tests")
1141 .setDomain(DOMAIN_OVERALL_TESTS)
1142 .setFormula(new SumChildValuesFormula(false))
1143 .setDeleteHistoricalData(true)
1144 .setHidden(true)
1145 .create();
1146
1147 /**
1148 * @since 3.3
1149 */
1150 public static final String OVERALL_UNCOVERED_CONDITIONS_KEY = "overall_uncovered_conditions";
1151
1152 /**
1153 * @since 3.3
1154 */
1155 public static final Metric OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall uncovered branches", Metric.ValueType.INT)
1156 .setDescription("Uncovered branches by all tests")
1157 .setDirection(Metric.DIRECTION_WORST)
1158 .setDomain(DOMAIN_OVERALL_TESTS)
1159 .setFormula(new SumChildValuesFormula(false))
1160 .create();
1161
1162 /**
1163 * @since 3.3
1164 */
1165 public static final String NEW_OVERALL_UNCOVERED_CONDITIONS_KEY = "new_overall_uncovered_conditions";
1166
1167 /**
1168 * @since 3.3
1169 */
1170 public static final Metric NEW_OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall uncovered branches on new code",
1171 Metric.ValueType.INT)
1172 .setDescription("New branches that are not covered by any test")
1173 .setDirection(Metric.DIRECTION_WORST)
1174 .setDomain(DOMAIN_OVERALL_TESTS)
1175 .setFormula(new SumChildValuesFormula(false))
1176 .setBestValue(0.0)
1177 .setDeleteHistoricalData(true)
1178 .create();
1179
1180 /**
1181 * @since 3.3
1182 */
1183 public static final String OVERALL_BRANCH_COVERAGE_KEY = "overall_branch_coverage";
1184
1185 /**
1186 * @since 3.3
1187 */
1188 public static final Metric OVERALL_BRANCH_COVERAGE = new Metric.Builder(OVERALL_BRANCH_COVERAGE_KEY, "Overall branch coverage", Metric.ValueType.PERCENT)
1189 .setDescription("Branch coverage by all tests")
1190 .setDirection(Metric.DIRECTION_BETTER)
1191 .setQualitative(true)
1192 .setDomain(DOMAIN_OVERALL_TESTS)
1193 .setWorstValue(0.0)
1194 .setBestValue(100.0)
1195 .create();
1196
1197 /**
1198 * @since 3.3
1199 */
1200 public static final String NEW_OVERALL_BRANCH_COVERAGE_KEY = "new_overall_branch_coverage";
1201
1202 /**
1203 * @since 3.3
1204 */
1205 public static final Metric NEW_OVERALL_BRANCH_COVERAGE = new Metric.Builder(NEW_OVERALL_BRANCH_COVERAGE_KEY, "Overall branch coverage on new code", Metric.ValueType.PERCENT)
1206 .setDescription("Branch coverage of new/changed code by all tests")
1207 .setDirection(Metric.DIRECTION_BETTER)
1208 .setQualitative(true)
1209 .setDomain(DOMAIN_OVERALL_TESTS)
1210 .setWorstValue(0.0)
1211 .setBestValue(100.0)
1212 .setDeleteHistoricalData(true)
1213 .create();
1214
1215 /**
1216 * @since 3.3
1217 */
1218 public static final String OVERALL_CONDITIONS_BY_LINE_KEY = "overall_conditions_by_line";
1219
1220 /**
1221 * @since 3.3
1222 */
1223 public static final Metric OVERALL_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_CONDITIONS_BY_LINE_KEY, "Overall branches by line", Metric.ValueType.DATA)
1224 .setDescription("Overall branches by all tests and by line")
1225 .setDomain(DOMAIN_OVERALL_TESTS)
1226 .setDeleteHistoricalData(true)
1227 .create();
1228
1229 /**
1230 * @since 3.3
1231 */
1232 public static final String OVERALL_COVERED_CONDITIONS_BY_LINE_KEY = "overall_covered_conditions_by_line";
1233
1234 /**
1235 * @since 3.3
1236 */
1237 public static final Metric OVERALL_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_COVERED_CONDITIONS_BY_LINE_KEY, "Overall covered branches by line",
1238 Metric.ValueType.DATA)
1239 .setDescription("Overall covered branches by all tests and by line")
1240 .setDomain(DOMAIN_OVERALL_TESTS)
1241 .setDeleteHistoricalData(true)
1242 .create();
1243
1244 // --------------------------------------------------------------------------------------------------------------------
1245 //
1246 // DUPLICATIONS
1247 //
1248 // --------------------------------------------------------------------------------------------------------------------
1249
1250 public static final String DUPLICATED_LINES_KEY = "duplicated_lines";
1251 public static final Metric DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated lines", Metric.ValueType.INT)
1252 .setDescription("Duplicated lines")
1253 .setDirection(Metric.DIRECTION_WORST)
1254 .setQualitative(true)
1255 .setDomain(DOMAIN_DUPLICATION)
1256 .setBestValue(0.0)
1257 .setOptimizedBestValue(true)
1258 .create();
1259
1260 public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks";
1261 public static final Metric DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated blocks", Metric.ValueType.INT)
1262 .setDescription("Duplicated blocks")
1263 .setDirection(Metric.DIRECTION_WORST)
1264 .setQualitative(true)
1265 .setDomain(DOMAIN_DUPLICATION)
1266 .setBestValue(0.0)
1267 .setOptimizedBestValue(true)
1268 .create();
1269
1270 public static final String DUPLICATED_FILES_KEY = "duplicated_files";
1271
1272 /**
1273 * For files: if it contains duplicates, then 1, otherwise 0.
1274 * For other resources: amount of files under this resource with duplicates.
1275 */
1276 public static final Metric DUPLICATED_FILES = new Metric.Builder(DUPLICATED_FILES_KEY, "Duplicated files", Metric.ValueType.INT)
1277 .setDescription("Duplicated files")
1278 .setDirection(Metric.DIRECTION_WORST)
1279 .setQualitative(true)
1280 .setDomain(DOMAIN_DUPLICATION)
1281 .setBestValue(0.0)
1282 .setOptimizedBestValue(true)
1283 .create();
1284
1285 public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density";
1286 public static final Metric DUPLICATED_LINES_DENSITY = new Metric.Builder(DUPLICATED_LINES_DENSITY_KEY, "Duplicated lines (%)", Metric.ValueType.PERCENT)
1287 .setDescription("Duplicated lines balanced by statements")
1288 .setDirection(Metric.DIRECTION_WORST)
1289 .setQualitative(true)
1290 .setDomain(DOMAIN_DUPLICATION)
1291 .setWorstValue(50.0)
1292 .setBestValue(0.0)
1293 .setOptimizedBestValue(true)
1294 .create();
1295
1296 public static final String DUPLICATIONS_DATA_KEY = "duplications_data";
1297
1298 /**
1299 * Information about duplications, which is represented as an XML string.
1300 * <p>
1301 * Here is the format (since Sonar 2.12):
1302 * <pre>
1303 * <duplications>
1304 * <!-- Multiple groups: -->
1305 * <g>
1306 * <!-- Multiple blocks: -->
1307 * <b r="[resource key]" s="[first line]" l="[number of lines]" />
1308 * ...
1309 * </g>
1310 * ...
1311 * </duplications>
1312 * </pre>
1313 * </p>
1314 */
1315 public static final Metric DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplications details", Metric.ValueType.DATA)
1316 .setDescription("Duplications details")
1317 .setDirection(Metric.DIRECTION_NONE)
1318 .setQualitative(false)
1319 .setDomain(DOMAIN_DUPLICATION)
1320 .setDeleteHistoricalData(true)
1321 .create();
1322
1323 // --------------------------------------------------------------------------------------------------------------------
1324 //
1325 // CODING RULES
1326 //
1327 // --------------------------------------------------------------------------------------------------------------------
1328
1329 /**
1330 * @deprecated since 4.0. See SONAR-4755
1331 */
1332 @Deprecated
1333 public static final String WEIGHTED_VIOLATIONS_KEY = "weighted_violations";
1334
1335 /**
1336 * @deprecated since 4.0. See SONAR-4755
1337 */
1338 @Deprecated
1339 public static final Metric WEIGHTED_VIOLATIONS = new Metric.Builder(WEIGHTED_VIOLATIONS_KEY, "Weighted issues", Metric.ValueType.INT)
1340 .setDescription("Weighted Issues")
1341 .setDirection(Metric.DIRECTION_WORST)
1342 .setQualitative(true)
1343 .setDomain(DOMAIN_ISSUES)
1344 .setBestValue(0.0)
1345 .setOptimizedBestValue(true)
1346 .create();
1347
1348 /**
1349 * @deprecated since 4.0. See SONAR-4755
1350 */
1351 @Deprecated
1352 public static final String VIOLATIONS_DENSITY_KEY = "violations_density";
1353
1354 /**
1355 * @deprecated since 4.0. See SONAR-4755
1356 */
1357 @Deprecated
1358 public static final Metric VIOLATIONS_DENSITY = new Metric.Builder(VIOLATIONS_DENSITY_KEY, "Rules compliance", Metric.ValueType.PERCENT)
1359 .setDescription("Rules compliance")
1360 .setDirection(Metric.DIRECTION_BETTER)
1361 .setQualitative(true)
1362 .setDomain(DOMAIN_ISSUES)
1363 .create();
1364
1365 public static final String VIOLATIONS_KEY = "violations";
1366 public static final Metric VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT)
1367 .setDescription("Issues")
1368 .setDirection(Metric.DIRECTION_WORST)
1369 .setQualitative(true)
1370 .setDomain(DOMAIN_ISSUES)
1371 .setBestValue(0.0)
1372 .setOptimizedBestValue(true)
1373 .create();
1374
1375 public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations";
1376 public static final Metric BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker issues", Metric.ValueType.INT)
1377 .setDescription("Blocker issues")
1378 .setDirection(Metric.DIRECTION_WORST)
1379 .setQualitative(true)
1380 .setDomain(DOMAIN_ISSUES)
1381 .setBestValue(0.0)
1382 .setOptimizedBestValue(true)
1383 .create();
1384
1385 public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations";
1386 public static final Metric CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical issues", Metric.ValueType.INT)
1387 .setDescription("Critical issues")
1388 .setDirection(Metric.DIRECTION_WORST)
1389 .setQualitative(true)
1390 .setDomain(DOMAIN_ISSUES)
1391 .setBestValue(0.0)
1392 .setOptimizedBestValue(true)
1393 .create();
1394
1395 public static final String MAJOR_VIOLATIONS_KEY = "major_violations";
1396 public static final Metric MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major issues", Metric.ValueType.INT)
1397 .setDescription("Major issues")
1398 .setDirection(Metric.DIRECTION_WORST)
1399 .setQualitative(true)
1400 .setDomain(DOMAIN_ISSUES)
1401 .setBestValue(0.0)
1402 .setOptimizedBestValue(true)
1403 .create();
1404
1405 public static final String MINOR_VIOLATIONS_KEY = "minor_violations";
1406 public static final Metric MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor issues", Metric.ValueType.INT)
1407 .setDescription("Minor issues")
1408 .setDirection(Metric.DIRECTION_WORST)
1409 .setQualitative(true)
1410 .setDomain(DOMAIN_ISSUES)
1411 .setBestValue(0.0)
1412 .setOptimizedBestValue(true)
1413 .create();
1414
1415 public static final String INFO_VIOLATIONS_KEY = "info_violations";
1416 public static final Metric INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info issues", Metric.ValueType.INT)
1417 .setDescription("Info issues")
1418 .setDirection(Metric.DIRECTION_WORST)
1419 .setQualitative(true)
1420 .setDomain(DOMAIN_ISSUES)
1421 .setBestValue(0.0)
1422 .setOptimizedBestValue(true)
1423 .create();
1424
1425 public static final String NEW_VIOLATIONS_KEY = "new_violations";
1426 public static final Metric NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New issues", Metric.ValueType.INT)
1427 .setDescription("New Issues")
1428 .setDirection(Metric.DIRECTION_WORST)
1429 .setQualitative(true)
1430 .setDomain(DOMAIN_ISSUES)
1431 .setBestValue(0.0)
1432 .setOptimizedBestValue(true)
1433 .setDeleteHistoricalData(true)
1434 .create();
1435
1436 public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations";
1437 public static final Metric NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker issues", Metric.ValueType.INT)
1438 .setDescription("New Blocker issues")
1439 .setDirection(Metric.DIRECTION_WORST)
1440 .setQualitative(true)
1441 .setDomain(DOMAIN_ISSUES)
1442 .setBestValue(0.0)
1443 .setOptimizedBestValue(true)
1444 .setDeleteHistoricalData(true)
1445 .create();
1446
1447 public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations";
1448 public static final Metric NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical issues", Metric.ValueType.INT)
1449 .setDescription("New Critical issues")
1450 .setDirection(Metric.DIRECTION_WORST)
1451 .setQualitative(true)
1452 .setDomain(DOMAIN_ISSUES)
1453 .setBestValue(0.0)
1454 .setOptimizedBestValue(true)
1455 .setDeleteHistoricalData(true)
1456 .create();
1457
1458 public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations";
1459 public static final Metric NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major issues", Metric.ValueType.INT)
1460 .setDescription("New Major issues")
1461 .setDirection(Metric.DIRECTION_WORST)
1462 .setQualitative(true)
1463 .setDomain(DOMAIN_ISSUES)
1464 .setBestValue(0.0)
1465 .setOptimizedBestValue(true)
1466 .setDeleteHistoricalData(true)
1467 .create();
1468
1469 public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations";
1470 public static final Metric NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor issues", Metric.ValueType.INT)
1471 .setDescription("New Minor issues")
1472 .setDirection(Metric.DIRECTION_WORST)
1473 .setQualitative(true)
1474 .setDomain(DOMAIN_ISSUES)
1475 .setBestValue(0.0)
1476 .setOptimizedBestValue(true)
1477 .setDeleteHistoricalData(true)
1478 .create();
1479
1480 public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations";
1481 public static final Metric NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info issues", Metric.ValueType.INT)
1482 .setDescription("New Info issues")
1483 .setDirection(Metric.DIRECTION_WORST)
1484 .setQualitative(true)
1485 .setDomain(DOMAIN_ISSUES)
1486 .setBestValue(0.0)
1487 .setOptimizedBestValue(true)
1488 .setDeleteHistoricalData(true)
1489 .create();
1490
1491 /**
1492 * @since 3.6
1493 */
1494 public static final String FALSE_POSITIVE_ISSUES_KEY = "false_positive_issues";
1495
1496 /**
1497 * @since 3.6
1498 */
1499 public static final Metric FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False positive issues", Metric.ValueType.INT)
1500 .setDescription("False positive issues")
1501 .setDirection(Metric.DIRECTION_WORST)
1502 .setDomain(DOMAIN_ISSUES)
1503 .setBestValue(0.0)
1504 .setOptimizedBestValue(true)
1505 .create();
1506
1507 /**
1508 * @since 3.6
1509 */
1510 public static final String OPEN_ISSUES_KEY = "open_issues";
1511
1512 /**
1513 * @since 3.6
1514 */
1515 public static final Metric OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open issues", Metric.ValueType.INT)
1516 .setDescription("Open issues")
1517 .setDirection(Metric.DIRECTION_WORST)
1518 .setDomain(DOMAIN_ISSUES)
1519 .setBestValue(0.0)
1520 .setOptimizedBestValue(true)
1521 .create();
1522
1523 /**
1524 * @since 3.6
1525 */
1526 public static final String REOPENED_ISSUES_KEY = "reopened_issues";
1527
1528 /**
1529 * @since 3.6
1530 */
1531 public static final Metric REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened issues", Metric.ValueType.INT)
1532 .setDescription("Reopened issues")
1533 .setDirection(Metric.DIRECTION_WORST)
1534 .setQualitative(true)
1535 .setDomain(DOMAIN_ISSUES)
1536 .setBestValue(0.0)
1537 .setOptimizedBestValue(true)
1538 .create();
1539
1540 /**
1541 * @since 3.6
1542 */
1543 public static final String CONFIRMED_ISSUES_KEY = "confirmed_issues";
1544
1545 /**
1546 * @since 3.6
1547 */
1548 public static final Metric CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed issues", Metric.ValueType.INT)
1549 .setDescription("Confirmed issues")
1550 .setDirection(Metric.DIRECTION_WORST)
1551 .setQualitative(true)
1552 .setDomain(DOMAIN_ISSUES)
1553 .setBestValue(0.0)
1554 .setOptimizedBestValue(true)
1555 .create();
1556
1557 // --------------------------------------------------------------------------------------------------------------------
1558 //
1559 // DESIGN
1560 //
1561 // --------------------------------------------------------------------------------------------------------------------
1562
1563 /**
1564 * @deprecated since 3.7.1
1565 */
1566 @Deprecated
1567 public static final String ABSTRACTNESS_KEY = "abstractness";
1568 /**
1569 * @deprecated since 3.7.1
1570 */
1571 @Deprecated
1572 public static final Metric ABSTRACTNESS = new Metric.Builder(ABSTRACTNESS_KEY, "Abstractness", Metric.ValueType.PERCENT)
1573 .setDescription("Abstractness")
1574 .setDirection(Metric.DIRECTION_NONE)
1575 .setQualitative(false)
1576 .setDomain(DOMAIN_DESIGN)
1577 .setHidden(true)
1578 .create();
1579
1580 /**
1581 * @deprecated since 3.7.1
1582 */
1583 @Deprecated
1584 public static final String INSTABILITY_KEY = "instability";
1585 /**
1586 * @deprecated since 3.7.1
1587 */
1588 @Deprecated
1589 public static final Metric INSTABILITY = new Metric.Builder(INSTABILITY_KEY, "Instability", Metric.ValueType.PERCENT)
1590 .setDescription("Instability")
1591 .setDirection(Metric.DIRECTION_NONE)
1592 .setQualitative(false)
1593 .setDomain(DOMAIN_DESIGN)
1594 .setHidden(true)
1595 .create();
1596
1597 /**
1598 * @deprecated since 3.7.1
1599 */
1600 @Deprecated
1601 public static final String DISTANCE_KEY = "distance";
1602 /**
1603 * @deprecated since 3.7.1
1604 */
1605 @Deprecated
1606 public static final Metric DISTANCE = new Metric.Builder(DISTANCE_KEY, "Distance", Metric.ValueType.FLOAT)
1607 .setDescription("Distance")
1608 .setDirection(Metric.DIRECTION_NONE)
1609 .setQualitative(false)
1610 .setDomain(DOMAIN_DESIGN)
1611 .setHidden(true)
1612 .create();
1613
1614 /**
1615 * @deprecated since 4.0. See SONAR-4643
1616 */
1617 @Deprecated
1618 public static final String DEPTH_IN_TREE_KEY = "dit";
1619 /**
1620 * @deprecated since 4.0. See SONAR-4643
1621 */
1622 @Deprecated
1623 public static final Metric DEPTH_IN_TREE = new Metric.Builder(DEPTH_IN_TREE_KEY, "Depth in Tree", Metric.ValueType.INT)
1624 .setDescription("Depth in Inheritance Tree")
1625 .setDirection(Metric.DIRECTION_NONE)
1626 .setQualitative(false)
1627 .setDomain(DOMAIN_DESIGN)
1628 .setHidden(true)
1629 .create();
1630
1631 /**
1632 * @deprecated since 4.0. See SONAR-4643
1633 */
1634 @Deprecated
1635 public static final String NUMBER_OF_CHILDREN_KEY = "noc";
1636 /**
1637 * @deprecated since 4.0. See SONAR-4643
1638 */
1639 @Deprecated
1640 public static final Metric NUMBER_OF_CHILDREN = new Metric.Builder(NUMBER_OF_CHILDREN_KEY, "Number of Children", Metric.ValueType.INT)
1641 .setDescription("Number of Children")
1642 .setDirection(Metric.DIRECTION_NONE)
1643 .setQualitative(false)
1644 .setDomain(DOMAIN_DESIGN)
1645 .setHidden(true)
1646 .create();
1647
1648 public static final String RFC_KEY = "rfc";
1649 public static final Metric RFC = new Metric.Builder(RFC_KEY, "RFC", Metric.ValueType.INT)
1650 .setDescription("Response for Class")
1651 .setDirection(Metric.DIRECTION_WORST)
1652 .setQualitative(false)
1653 .setDomain(DOMAIN_DESIGN)
1654 .setFormula(new WeightedMeanAggregationFormula(CoreMetrics.FILES, false))
1655 .create();
1656
1657 public static final String RFC_DISTRIBUTION_KEY = "rfc_distribution";
1658 public static final Metric RFC_DISTRIBUTION = new Metric.Builder(RFC_DISTRIBUTION_KEY, "Class distribution /RFC", Metric.ValueType.DISTRIB)
1659 .setDescription("Class distribution /RFC")
1660 .setDirection(Metric.DIRECTION_NONE)
1661 .setQualitative(true)
1662 .setDomain(DOMAIN_DESIGN)
1663 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
1664 .create();
1665
1666 /**
1667 * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1668 */
1669 @Deprecated
1670 public static final String LCOM4_KEY = "lcom4";
1671
1672 /**
1673 * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1674 */
1675 @Deprecated
1676 public static final Metric LCOM4 = new Metric.Builder(LCOM4_KEY, "LCOM4", Metric.ValueType.FLOAT)
1677 .setDescription("Lack of Cohesion of Functions")
1678 .setDirection(Metric.DIRECTION_WORST)
1679 .setQualitative(true)
1680 .setDomain(DOMAIN_DESIGN)
1681 .setBestValue(1.0)
1682 .create();
1683
1684 /**
1685 * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1686 */
1687 @Deprecated
1688 public static final String LCOM4_BLOCKS_KEY = "lcom4_blocks";
1689
1690 /**
1691 * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1692 */
1693 @Deprecated
1694 public static final Metric LCOM4_BLOCKS = new Metric.Builder(LCOM4_BLOCKS_KEY, "LCOM4 blocks", Metric.ValueType.DATA)
1695 .setDescription("LCOM4 blocks")
1696 .setDirection(Metric.DIRECTION_NONE)
1697 .setQualitative(false)
1698 .setDomain(DOMAIN_DESIGN)
1699 .setHidden(true)
1700 .setDeleteHistoricalData(true)
1701 .create();
1702
1703 /**
1704 * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1705 */
1706 @Deprecated
1707 public static final String LCOM4_DISTRIBUTION_KEY = "lcom4_distribution";
1708
1709 /**
1710 * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1711 */
1712 @Deprecated
1713 public static final Metric LCOM4_DISTRIBUTION = new Metric.Builder(LCOM4_DISTRIBUTION_KEY, "Class distribution /LCOM4", Metric.ValueType.DISTRIB)
1714 .setDescription("Class distribution /LCOM4")
1715 .setDirection(Metric.DIRECTION_NONE)
1716 .setQualitative(true)
1717 .setDomain(DOMAIN_DESIGN)
1718 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
1719 .create();
1720
1721 /**
1722 * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1723 */
1724 @Deprecated
1725 public static final String SUSPECT_LCOM4_DENSITY_KEY = "suspect_lcom4_density";
1726
1727 /**
1728 * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1729 */
1730 @Deprecated
1731 public static final Metric SUSPECT_LCOM4_DENSITY = new Metric.Builder(SUSPECT_LCOM4_DENSITY_KEY, "Suspect LCOM4 density", Metric.ValueType.PERCENT)
1732 .setDescription("Density of classes having LCOM4>1")
1733 .setDirection(Metric.DIRECTION_WORST)
1734 .setQualitative(true)
1735 .setDomain(DOMAIN_DESIGN)
1736 .create();
1737
1738 /**
1739 * @deprecated since 3.7.1
1740 */
1741 @Deprecated
1742 public static final String AFFERENT_COUPLINGS_KEY = "ca";
1743 /**
1744 * @deprecated since 3.7.1
1745 */
1746 @Deprecated
1747 public static final Metric AFFERENT_COUPLINGS = new Metric.Builder(AFFERENT_COUPLINGS_KEY, "Afferent couplings", Metric.ValueType.INT)
1748 .setDescription("Afferent couplings")
1749 .setDirection(Metric.DIRECTION_WORST)
1750 .setQualitative(false)
1751 .setDomain(DOMAIN_DESIGN)
1752 .create();
1753
1754 /**
1755 * @deprecated since 3.7.1
1756 */
1757 @Deprecated
1758 public static final String EFFERENT_COUPLINGS_KEY = "ce";
1759 /**
1760 * @deprecated since 3.7.1
1761 */
1762 @Deprecated
1763 public static final Metric EFFERENT_COUPLINGS = new Metric.Builder(EFFERENT_COUPLINGS_KEY, "Efferent couplings", Metric.ValueType.INT)
1764 .setDescription("Efferent couplings")
1765 .setDirection(Metric.DIRECTION_WORST)
1766 .setQualitative(false)
1767 .setDomain(DOMAIN_DESIGN)
1768 .create();
1769
1770 public static final String DEPENDENCY_MATRIX_KEY = "dsm";
1771 public static final Metric DEPENDENCY_MATRIX = new Metric.Builder(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", Metric.ValueType.DATA)
1772 .setDescription("Dependency Matrix")
1773 .setDirection(Metric.DIRECTION_NONE)
1774 .setQualitative(false)
1775 .setDomain(DOMAIN_DESIGN)
1776 .setDeleteHistoricalData(true)
1777 .create();
1778
1779 public static final String PACKAGE_CYCLES_KEY = "package_cycles";
1780 public static final Metric PACKAGE_CYCLES = new Metric.Builder(PACKAGE_CYCLES_KEY, "Package cycles", Metric.ValueType.INT)
1781 .setDescription("Package cycles")
1782 .setDirection(Metric.DIRECTION_WORST)
1783 .setQualitative(true)
1784 .setDomain(DOMAIN_DESIGN)
1785 .setBestValue(0.0)
1786 .setFormula(new SumChildValuesFormula(false))
1787 .create();
1788
1789 public static final String PACKAGE_TANGLE_INDEX_KEY = "package_tangle_index";
1790 public static final Metric PACKAGE_TANGLE_INDEX = new Metric.Builder(PACKAGE_TANGLE_INDEX_KEY, "Package tangle index", Metric.ValueType.PERCENT)
1791 .setDescription("Package tangle index")
1792 .setDirection(Metric.DIRECTION_WORST)
1793 .setQualitative(true)
1794 .setBestValue(0.0)
1795 .setDomain(DOMAIN_DESIGN)
1796 .create();
1797
1798 public static final String PACKAGE_TANGLES_KEY = "package_tangles";
1799 public static final Metric PACKAGE_TANGLES = new Metric.Builder(PACKAGE_TANGLES_KEY, "File dependencies to cut", Metric.ValueType.INT)
1800 .setDescription("File dependencies to cut")
1801 .setDirection(Metric.DIRECTION_WORST)
1802 .setQualitative(false)
1803 .setDomain(DOMAIN_DESIGN)
1804 .setFormula(new SumChildValuesFormula(false))
1805 .create();
1806
1807 public static final String PACKAGE_FEEDBACK_EDGES_KEY = "package_feedback_edges";
1808 public static final Metric PACKAGE_FEEDBACK_EDGES = new Metric.Builder(PACKAGE_FEEDBACK_EDGES_KEY, "Package dependencies to cut", Metric.ValueType.INT)
1809 .setDescription("Package dependencies to cut")
1810 .setDirection(Metric.DIRECTION_WORST)
1811 .setQualitative(false)
1812 .setDomain(DOMAIN_DESIGN)
1813 .setFormula(new SumChildValuesFormula(false))
1814 .setBestValue(0.0)
1815 .create();
1816
1817 public static final String PACKAGE_EDGES_WEIGHT_KEY = "package_edges_weight";
1818 public static final Metric PACKAGE_EDGES_WEIGHT = new Metric.Builder(PACKAGE_EDGES_WEIGHT_KEY, "Package edges weight", Metric.ValueType.INT)
1819 .setDescription("Package edges weight")
1820 .setDirection(Metric.DIRECTION_BETTER)
1821 .setQualitative(false)
1822 .setDomain(DOMAIN_DESIGN)
1823 .setFormula(new SumChildValuesFormula(false))
1824 .setHidden(true)
1825 .setDeleteHistoricalData(true)
1826 .create();
1827
1828 public static final String FILE_CYCLES_KEY = "file_cycles";
1829 public static final Metric FILE_CYCLES = new Metric.Builder(FILE_CYCLES_KEY, "File cycles", Metric.ValueType.INT)
1830 .setDescription("File cycles")
1831 .setDirection(Metric.DIRECTION_WORST)
1832 .setQualitative(true)
1833 .setDomain(DOMAIN_DESIGN)
1834 .setHidden(true)
1835 .setDeleteHistoricalData(true)
1836 .setBestValue(0.0)
1837 .create();
1838
1839 public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index";
1840 public static final Metric FILE_TANGLE_INDEX = new Metric.Builder(FILE_TANGLE_INDEX_KEY, "File tangle index", Metric.ValueType.PERCENT)
1841 .setDescription("File tangle index")
1842 .setDirection(Metric.DIRECTION_WORST)
1843 .setQualitative(true)
1844 .setDomain(DOMAIN_DESIGN)
1845 .setHidden(true)
1846 .setDeleteHistoricalData(true)
1847 .setBestValue(0.0)
1848 .create();
1849
1850 public static final String FILE_TANGLES_KEY = "file_tangles";
1851 public static final Metric FILE_TANGLES = new Metric.Builder(FILE_TANGLES_KEY, "File tangles", Metric.ValueType.INT)
1852 .setDescription("Files tangles")
1853 .setDirection(Metric.DIRECTION_WORST)
1854 .setQualitative(false)
1855 .setDomain(DOMAIN_DESIGN)
1856 .setHidden(true)
1857 .setDeleteHistoricalData(true)
1858 .create();
1859
1860 public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges";
1861 public static final Metric FILE_FEEDBACK_EDGES = new Metric.Builder(FILE_FEEDBACK_EDGES_KEY, "Suspect file dependencies", Metric.ValueType.INT)
1862 .setDescription("Suspect file dependencies")
1863 .setDirection(Metric.DIRECTION_WORST)
1864 .setQualitative(false)
1865 .setDomain(DOMAIN_DESIGN)
1866 .setHidden(true)
1867 .setDeleteHistoricalData(true)
1868 .setBestValue(0.0)
1869 .create();
1870
1871 public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight";
1872 public static final Metric FILE_EDGES_WEIGHT = new Metric.Builder(FILE_EDGES_WEIGHT_KEY, "File edges weight", Metric.ValueType.INT)
1873 .setDescription("File edges weight")
1874 .setDirection(Metric.DIRECTION_BETTER)
1875 .setQualitative(false)
1876 .setDomain(DOMAIN_DESIGN)
1877 .setHidden(true)
1878 .setDeleteHistoricalData(true)
1879 .create();
1880
1881 // --------------------------------------------------------------------------------------------------------------------
1882 //
1883 // SCM
1884 // These metrics are computed by the SCM Activity plugin, since version 1.2 and introduced here since version 2.7.
1885 //
1886 // --------------------------------------------------------------------------------------------------------------------
1887
1888 /**
1889 * @since 2.7
1890 */
1891 public static final String SCM_AUTHORS_BY_LINE_KEY = "authors_by_line";
1892
1893 /**
1894 * Key-value pairs, where key - is a number of line, and value - is an author for this line.
1895 *
1896 * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map)
1897 * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String)
1898 * @since 2.7
1899 */
1900 public static final Metric SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by line", Metric.ValueType.DATA)
1901 .setDomain(DOMAIN_SCM)
1902 .create();
1903
1904 /**
1905 * @since 2.7
1906 */
1907 public static final String SCM_REVISIONS_BY_LINE_KEY = "revisions_by_line";
1908
1909 /**
1910 * Key-value pairs, where key - is a number of line, and value - is a revision for this line.
1911 *
1912 * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map)
1913 * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String)
1914 * @since 2.7
1915 */
1916 public static final Metric SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by line", Metric.ValueType.DATA)
1917 .setDomain(DOMAIN_SCM)
1918 .create();
1919
1920 /**
1921 * @since 2.7
1922 */
1923 public static final String SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY = "last_commit_datetimes_by_line";
1924
1925 /**
1926 * Key-value pairs, where key - is a number of line, and value - is a date of last commit for this line.
1927 *
1928 * @see org.sonar.api.utils.KeyValueFormat#formatIntDateTime(java.util.Map)
1929 * @see org.sonar.api.utils.KeyValueFormat#parseIntDateTime(String)
1930 * @since 2.7
1931 */
1932 public static final Metric SCM_LAST_COMMIT_DATETIMES_BY_LINE = new Metric.Builder(SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY, "Last commit dates by line", Metric.ValueType.DATA)
1933 .setDomain(DOMAIN_SCM)
1934 .create();
1935
1936 // --------------------------------------------------------------------------------------------------------------------
1937 //
1938 // REVIEWS (since 2.14)
1939 //
1940 // --------------------------------------------------------------------------------------------------------------------
1941
1942 /**
1943 * @since 2.14
1944 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
1945 */
1946 @Deprecated
1947 public static final String UNREVIEWED_VIOLATIONS_KEY = "unreviewed_violations";
1948
1949 /**
1950 * @since 2.14
1951 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
1952 */
1953 @Deprecated
1954 public static final Metric UNREVIEWED_VIOLATIONS = new Metric.Builder(UNREVIEWED_VIOLATIONS_KEY, "Unreviewed violations", Metric.ValueType.INT)
1955 .setDescription("Violations that have not been reviewed yet")
1956 .setDirection(Metric.DIRECTION_WORST)
1957 .setDomain(DOMAIN_REVIEWS)
1958 .setBestValue(0.0)
1959 .setOptimizedBestValue(true)
1960 .setHidden(true)
1961 .create();
1962
1963 /**
1964 * @since 2.14
1965 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
1966 */
1967 @Deprecated
1968 public static final String NEW_UNREVIEWED_VIOLATIONS_KEY = "new_unreviewed_violations";
1969
1970 /**
1971 * @since 2.14
1972 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
1973 */
1974 @Deprecated
1975 public static final Metric NEW_UNREVIEWED_VIOLATIONS = new Metric.Builder(NEW_UNREVIEWED_VIOLATIONS_KEY, "New unreviewed violations", Metric.ValueType.INT)
1976 .setDescription("New violations that have not been reviewed yet")
1977 .setDirection(Metric.DIRECTION_WORST)
1978 .setQualitative(true)
1979 .setDomain(DOMAIN_REVIEWS)
1980 .setBestValue(0.0)
1981 .setOptimizedBestValue(true)
1982 .setDeleteHistoricalData(true)
1983 .setHidden(true)
1984 .create();
1985
1986 /**
1987 * @since 2.14
1988 * @deprecated in 3.6. This measure is replaced by {@link #FALSE_POSITIVE_ISSUES_KEY}.
1989 */
1990 @Deprecated
1991 public static final String FALSE_POSITIVE_REVIEWS_KEY = "false_positive_reviews";
1992
1993 /**
1994 * @since 2.14
1995 * @deprecated in 3.6. This measure is replaced by {@link #FALSE_POSITIVE_ISSUES}.
1996 */
1997 @Deprecated
1998 public static final Metric FALSE_POSITIVE_REVIEWS = new Metric.Builder(FALSE_POSITIVE_REVIEWS_KEY, "False-positive reviews", Metric.ValueType.INT)
1999 .setDescription("Active false-positive reviews")
2000 .setDirection(Metric.DIRECTION_WORST)
2001 .setDomain(DOMAIN_REVIEWS)
2002 .setBestValue(0.0)
2003 .setOptimizedBestValue(true)
2004 .setHidden(true)
2005 .create();
2006
2007 /**
2008 * @since 2.14
2009 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2010 */
2011 @Deprecated
2012 public static final String ACTIVE_REVIEWS_KEY = "active_reviews";
2013
2014 /**
2015 * @since 2.14
2016 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2017 */
2018 @Deprecated
2019 public static final Metric ACTIVE_REVIEWS = new Metric.Builder(ACTIVE_REVIEWS_KEY, "Active reviews", Metric.ValueType.INT)
2020 .setDescription("Active open and reopened reviews")
2021 .setDirection(Metric.DIRECTION_WORST)
2022 .setDomain(DOMAIN_REVIEWS)
2023 .setBestValue(0.0)
2024 .setOptimizedBestValue(true)
2025 .setHidden(true)
2026 .create();
2027
2028 /**
2029 * @since 2.14
2030 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2031 */
2032 @Deprecated
2033 public static final String UNASSIGNED_REVIEWS_KEY = "unassigned_reviews";
2034
2035 /**
2036 * @since 2.14
2037 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2038 */
2039 @Deprecated
2040 public static final Metric UNASSIGNED_REVIEWS = new Metric.Builder(UNASSIGNED_REVIEWS_KEY, "Unassigned reviews", Metric.ValueType.INT)
2041 .setDescription("Active unassigned reviews")
2042 .setDirection(Metric.DIRECTION_WORST)
2043 .setDomain(DOMAIN_REVIEWS)
2044 .setBestValue(0.0)
2045 .setOptimizedBestValue(true)
2046 .setHidden(true)
2047 .create();
2048
2049 /**
2050 * @since 2.14
2051 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2052 */
2053 @Deprecated
2054 public static final String UNPLANNED_REVIEWS_KEY = "unplanned_reviews";
2055
2056 /**
2057 * @since 2.14
2058 * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2059 */
2060 @Deprecated
2061 public static final Metric UNPLANNED_REVIEWS = new Metric.Builder(UNPLANNED_REVIEWS_KEY, "Unplanned reviews", Metric.ValueType.INT)
2062 .setDescription("Active unplanned reviews")
2063 .setDirection(Metric.DIRECTION_WORST)
2064 .setDomain(DOMAIN_REVIEWS)
2065 .setBestValue(0.0)
2066 .setOptimizedBestValue(true)
2067 .setHidden(true)
2068 .create();
2069
2070
2071 // --------------------------------------------------------------------------------------------------------------------
2072 //
2073 // TECHNICAL DEBT
2074 //
2075 // --------------------------------------------------------------------------------------------------------------------
2076
2077 /**
2078 * @since 4.0
2079 */
2080 public static final String TECHNICAL_DEBT_KEY = "sqale_index";
2081
2082 /**
2083 * @since 4.0
2084 */
2085 public static final Metric TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.FLOAT)
2086 .setDomain(DOMAIN_TECHNICAL_DEBT)
2087 .setDirection(Metric.DIRECTION_WORST)
2088 .setOptimizedBestValue(true)
2089 .setBestValue(0.0)
2090 .setQualitative(true)
2091 .create();
2092
2093 /**
2094 * @since 4.1
2095 */
2096 public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt";
2097
2098 /**
2099 * @since 4.1
2100 */
2101 public static final Metric NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Technical Debt on new code", Metric.ValueType.FLOAT)
2102 .setDescription("Technical Debt of new code")
2103 .setDomain(DOMAIN_TECHNICAL_DEBT)
2104 .setDirection(Metric.DIRECTION_WORST)
2105 .setOptimizedBestValue(true)
2106 .setBestValue(0.0)
2107 .setQualitative(true)
2108 .setDeleteHistoricalData(true)
2109 .create();
2110
2111
2112 // --------------------------------------------------------------------------------------------------------------------
2113 //
2114 // FILE DATA
2115 //
2116 // --------------------------------------------------------------------------------------------------------------------
2117
2118 /**
2119 * @since 2.14
2120 */
2121 @Beta
2122 public static final String NCLOC_DATA_KEY = "ncloc_data";
2123
2124 /**
2125 * Information about lines of code in file.
2126 * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains code (1) or not (0).
2127 *
2128 * @see org.sonar.api.measures.FileLinesContext
2129 * @since 2.14
2130 */
2131 @Beta
2132 public static final Metric NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA)
2133 .setHidden(true)
2134 .setDomain(DOMAIN_SIZE)
2135 .create();
2136
2137 /**
2138 * @since 2.14
2139 */
2140 @Beta
2141 public static final String COMMENT_LINES_DATA_KEY = "comment_lines_data";
2142
2143 /**
2144 * Information about comments in file.
2145 * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains comment (1) or not (0).
2146 *
2147 * @see org.sonar.api.measures.FileLinesContext
2148 * @since 2.14
2149 */
2150 @Beta
2151 public static final Metric COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA)
2152 .setHidden(true)
2153 .setDomain(DOMAIN_DOCUMENTATION)
2154 .create();
2155
2156 // --------------------------------------------------------------------------------------------------------------------
2157 //
2158 // OTHERS
2159 //
2160 // --------------------------------------------------------------------------------------------------------------------
2161
2162 public static final String ALERT_STATUS_KEY = "alert_status";
2163 public static final Metric ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Alert", Metric.ValueType.LEVEL)
2164 .setDescription("Alert")
2165 .setDirection(Metric.DIRECTION_BETTER)
2166 .setQualitative(true)
2167 .setDomain(DOMAIN_GENERAL)
2168 .create();
2169
2170 public static final String PROFILE_KEY = "profile";
2171 public static final Metric PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA)
2172 .setDescription("Selected quality profile")
2173 .setDomain(DOMAIN_GENERAL)
2174 .create();
2175
2176 /**
2177 * @since 2.9
2178 */
2179 public static final String PROFILE_VERSION_KEY = "profile_version";
2180
2181 /**
2182 * @since 2.9
2183 */
2184 public static final Metric PROFILE_VERSION = new Metric.Builder(PROFILE_VERSION_KEY, "Profile version", Metric.ValueType.INT)
2185 .setDescription("Selected quality profile version")
2186 .setQualitative(false)
2187 .setDomain(DOMAIN_GENERAL)
2188 .setHidden(true)
2189 .create();
2190
2191 private static final List<Metric> METRICS;
2192
2193 static {
2194 METRICS = Lists.newLinkedList();
2195 for (Field field : CoreMetrics.class.getFields()) {
2196 if (Metric.class.isAssignableFrom(field.getType())) {
2197 try {
2198 Metric metric = (Metric) field.get(null);
2199 METRICS.add(metric);
2200 } catch (IllegalAccessException e) {
2201 throw new SonarException("can not introspect " + CoreMetrics.class + " to get metrics", e);
2202 }
2203 }
2204 }
2205 }
2206
2207 public static List<Metric> getMetrics() {
2208 return METRICS;
2209 }
2210 }