001/* 002 * SonarQube 003 * Copyright (C) 2009-2016 SonarSource SA 004 * mailto:contact AT sonarsource DOT com 005 * 006 * This program 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 * This program 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 */ 020package org.sonar.api.measures; 021 022import com.google.common.base.Predicate; 023import com.google.common.collect.Iterables; 024import java.lang.reflect.Field; 025import java.lang.reflect.Modifier; 026import java.util.LinkedList; 027import java.util.List; 028import javax.annotation.Nullable; 029import org.sonar.api.test.MutableTestPlan; 030import org.sonar.api.utils.SonarException; 031 032/** 033 * @since 1.10 034 */ 035public final class CoreMetrics { 036 037 // the following fields are not final to avoid compile-time constants used by plugins 038 public static String DOMAIN_SIZE = "Size"; 039 public static String DOMAIN_COVERAGE = "Coverage"; 040 041 /** 042 * @deprecated in 5.5. Merged into {@link #DOMAIN_COVERAGE} 043 */ 044 @Deprecated 045 public static String DOMAIN_TESTS = "Tests"; 046 047 /** 048 * @deprecated in 5.5. Merged into {@link #DOMAIN_COVERAGE} 049 */ 050 @Deprecated 051 public static String DOMAIN_INTEGRATION_TESTS = "Tests (Integration)"; 052 053 /** 054 * @deprecated in 5.5. Merged into {@link #DOMAIN_COVERAGE} 055 */ 056 @Deprecated 057 public static String DOMAIN_OVERALL_TESTS = "Tests (Overall)"; 058 public static String DOMAIN_COMPLEXITY = "Complexity"; 059 public static String DOMAIN_DOCUMENTATION = "Documentation"; 060 public static String DOMAIN_SCM = "SCM"; 061 public static String DOMAIN_ISSUES = "Issues"; 062 public static String DOMAIN_GENERAL = "General"; 063 public static String DOMAIN_DUPLICATIONS = "Duplications"; 064 065 /** 066 * @deprecated in 5.5. Renamed to {@link #DOMAIN_DUPLICATIONS} 067 */ 068 @Deprecated 069 public static String DOMAIN_DUPLICATION = "Duplication"; 070 public static String DOMAIN_DESIGN = "Design"; 071 072 /** 073 * SonarQube Quality Model 074 * @since 5.5 075 */ 076 public static String DOMAIN_MAINTAINABILITY = "Maintainability"; 077 078 /** 079 * SonarQube Quality Model 080 * @since 5.5 081 */ 082 public static String DOMAIN_RELIABILITY = "Reliability"; 083 084 /** 085 * SonarQube Quality Model 086 * @since 5.5 087 */ 088 public static String DOMAIN_SECURITY = "Security"; 089 090 /** 091 * @since 4.0 092 * 093 * @deprecated in 5.5. Replaced by {@link #DOMAIN_MAINTAINABILITY} 094 */ 095 @Deprecated 096 public static String DOMAIN_TECHNICAL_DEBT = "Technical Debt"; 097 098 /** 099 * @since 5.5 100 */ 101 public static String DOMAIN_RELEASABILITY = "Releasability"; 102 103 /** 104 * Computed by the platform since SQ 5.1 105 */ 106 public static final String LINES_KEY = "lines"; 107 public static final Metric<Integer> LINES = new Metric.Builder(LINES_KEY, "Lines", Metric.ValueType.INT) 108 .setDescription("Lines") 109 .setDirection(Metric.DIRECTION_WORST) 110 .setQualitative(false) 111 .setDomain(DOMAIN_SIZE) 112 .create(); 113 114 public static final String GENERATED_LINES_KEY = "generated_lines"; 115 public static final Metric<Integer> GENERATED_LINES = new Metric.Builder(GENERATED_LINES_KEY, "Generated Lines", Metric.ValueType.INT) 116 .setDescription("Number of generated lines") 117 .setDirection(Metric.DIRECTION_WORST) 118 .setQualitative(false) 119 .setDomain(DOMAIN_SIZE) 120 .setBestValue(0.0) 121 .setOptimizedBestValue(true) 122 .create(); 123 124 public static final String NCLOC_KEY = "ncloc"; 125 public static final Metric<Integer> NCLOC = new Metric.Builder(NCLOC_KEY, "Lines of Code", Metric.ValueType.INT) 126 .setDescription("Non Commenting Lines of Code") 127 .setDirection(Metric.DIRECTION_WORST) 128 .setQualitative(false) 129 .setDomain(DOMAIN_SIZE) 130 .create(); 131 132 /** 133 * @since 4.4 134 */ 135 public static final String NCLOC_LANGUAGE_DISTRIBUTION_KEY = "ncloc_language_distribution"; 136 137 /** 138 * @since 4.4 139 */ 140 public static final Metric<String> NCLOC_LANGUAGE_DISTRIBUTION = new Metric.Builder(NCLOC_LANGUAGE_DISTRIBUTION_KEY, "Lines of Code Per Language", Metric.ValueType.DATA) 141 .setDescription("Non Commenting Lines of Code Distributed By Language") 142 .setDirection(Metric.DIRECTION_WORST) 143 .setQualitative(false) 144 .setDomain(DOMAIN_SIZE) 145 .create(); 146 147 public static final String GENERATED_NCLOC_KEY = "generated_ncloc"; 148 public static final Metric<Integer> GENERATED_NCLOC = new Metric.Builder(GENERATED_NCLOC_KEY, "Generated Lines of Code", Metric.ValueType.INT) 149 .setDescription("Generated non Commenting Lines of Code") 150 .setDirection(Metric.DIRECTION_WORST) 151 .setQualitative(false) 152 .setDomain(DOMAIN_SIZE) 153 .setBestValue(0.0) 154 .setOptimizedBestValue(true) 155 .create(); 156 157 public static final String CLASSES_KEY = "classes"; 158 public static final Metric<Integer> CLASSES = new Metric.Builder(CLASSES_KEY, "Classes", Metric.ValueType.INT) 159 .setDescription("Classes") 160 .setDirection(Metric.DIRECTION_WORST) 161 .setQualitative(false) 162 .setDomain(DOMAIN_SIZE) 163 .create(); 164 165 public static final String FILES_KEY = "files"; 166 /** 167 * Computed by the platform. 168 */ 169 public static final Metric<Integer> FILES = new Metric.Builder(FILES_KEY, "Files", Metric.ValueType.INT) 170 .setDescription("Number of files") 171 .setDirection(Metric.DIRECTION_WORST) 172 .setQualitative(false) 173 .setDomain(DOMAIN_SIZE) 174 .create(); 175 176 public static final String DIRECTORIES_KEY = "directories"; 177 /** 178 * Computed by the platform. 179 */ 180 public static final Metric<Integer> DIRECTORIES = new Metric.Builder(DIRECTORIES_KEY, "Directories", Metric.ValueType.INT) 181 .setDescription("Directories") 182 .setDirection(Metric.DIRECTION_WORST) 183 .setQualitative(false) 184 .setDomain(DOMAIN_SIZE) 185 .create(); 186 187 public static final String FUNCTIONS_KEY = "functions"; 188 public static final Metric<Integer> FUNCTIONS = new Metric.Builder(FUNCTIONS_KEY, "Functions", Metric.ValueType.INT) 189 .setDescription("Functions") 190 .setDirection(Metric.DIRECTION_WORST) 191 .setQualitative(false) 192 .setDomain(DOMAIN_SIZE) 193 .create(); 194 195 /** 196 * @deprecated since 5.0. 197 * @see <a href="https://jira.sonarsource.com/browse/SONAR-5224">SONAR-5224</a> 198 */ 199 @Deprecated 200 public static final String ACCESSORS_KEY = "accessors"; 201 202 /** 203 * @deprecated since 5.0. 204 * @see <a href="https://jira.sonarsource.com/browse/SONAR-5224">SONAR-5224</a> 205 */ 206 @Deprecated 207 public static final Metric<Integer> ACCESSORS = new Metric.Builder(ACCESSORS_KEY, "Accessors", Metric.ValueType.INT) 208 .setDescription("Accessors") 209 .setDirection(Metric.DIRECTION_WORST) 210 .setQualitative(false) 211 .setDomain(DOMAIN_SIZE) 212 .setHidden(true) 213 .create(); 214 215 public static final String STATEMENTS_KEY = "statements"; 216 public static final Metric<Integer> STATEMENTS = new Metric.Builder(STATEMENTS_KEY, "Statements", Metric.ValueType.INT) 217 .setDescription("Number of statements") 218 .setDirection(Metric.DIRECTION_WORST) 219 .setQualitative(false) 220 .setDomain(DOMAIN_SIZE) 221 .create(); 222 223 public static final String PUBLIC_API_KEY = "public_api"; 224 public static final Metric<Integer> PUBLIC_API = new Metric.Builder(PUBLIC_API_KEY, "Public API", Metric.ValueType.INT) 225 .setDescription("Public API") 226 .setDirection(Metric.DIRECTION_WORST) 227 .setQualitative(false) 228 .setDomain(DOMAIN_DOCUMENTATION) 229 .create(); 230 231 /** 232 * @since 3.0 233 */ 234 public static final String PROJECTS_KEY = "projects"; 235 236 /** 237 * @since 3.0 238 */ 239 public static final Metric<Integer> PROJECTS = new Metric.Builder(PROJECTS_KEY, "Projects", Metric.ValueType.INT) 240 .setDescription("Number of projects") 241 .setDirection(Metric.DIRECTION_WORST) 242 .setQualitative(false) 243 .setDomain(DOMAIN_SIZE) 244 .create(); 245 246 // -------------------------------------------------------------------------------------------------------------------- 247 // 248 // DOCUMENTATION 249 // 250 // -------------------------------------------------------------------------------------------------------------------- 251 252 public static final String COMMENT_LINES_KEY = "comment_lines"; 253 public static final Metric<Integer> COMMENT_LINES = new Metric.Builder(COMMENT_LINES_KEY, "Comment Lines", Metric.ValueType.INT) 254 .setDescription("Number of comment lines") 255 .setDirection(Metric.DIRECTION_BETTER) 256 .setQualitative(false) 257 .setDomain(DOMAIN_DOCUMENTATION) 258 .create(); 259 260 public static final String COMMENT_LINES_DENSITY_KEY = "comment_lines_density"; 261 public static final Metric<Double> COMMENT_LINES_DENSITY = new Metric.Builder(COMMENT_LINES_DENSITY_KEY, "Comments (%)", Metric.ValueType.PERCENT) 262 .setDescription("Comments balanced by ncloc + comment lines") 263 .setDirection(Metric.DIRECTION_BETTER) 264 .setQualitative(true) 265 .setDomain(DOMAIN_DOCUMENTATION) 266 .create(); 267 268 public static final String PUBLIC_DOCUMENTED_API_DENSITY_KEY = "public_documented_api_density"; 269 public static final Metric<Double> PUBLIC_DOCUMENTED_API_DENSITY = new Metric.Builder(PUBLIC_DOCUMENTED_API_DENSITY_KEY, "Public Documented API (%)", Metric.ValueType.PERCENT) 270 .setDescription("Public documented classes and functions balanced by ncloc") 271 .setDirection(Metric.DIRECTION_BETTER) 272 .setQualitative(true) 273 .setDomain(DOMAIN_DOCUMENTATION) 274 .setWorstValue(0.0) 275 .setBestValue(100.0) 276 .setOptimizedBestValue(true) 277 .create(); 278 279 public static final String PUBLIC_UNDOCUMENTED_API_KEY = "public_undocumented_api"; 280 public static final Metric<Integer> PUBLIC_UNDOCUMENTED_API = new Metric.Builder(PUBLIC_UNDOCUMENTED_API_KEY, "Public Undocumented API", Metric.ValueType.INT) 281 .setDescription("Public undocumented classes, functions and variables") 282 .setDirection(Metric.DIRECTION_WORST) 283 .setQualitative(true) 284 .setDomain(DOMAIN_DOCUMENTATION) 285 .setBestValue(0.0) 286 .setDirection(Metric.DIRECTION_WORST) 287 .setOptimizedBestValue(true) 288 .create(); 289 290 /** 291 * @deprecated since 4.2 - see SONAR-4990 292 */ 293 @Deprecated 294 public static final String COMMENTED_OUT_CODE_LINES_KEY = "commented_out_code_lines"; 295 296 /** 297 * @deprecated since 4.2 - see SONAR-4990 298 */ 299 @Deprecated 300 public static final Metric<Integer> COMMENTED_OUT_CODE_LINES = new Metric.Builder(COMMENTED_OUT_CODE_LINES_KEY, "Commented-Out LOC", Metric.ValueType.INT) 301 .setDescription("Commented lines of code") 302 .setDirection(Metric.DIRECTION_WORST) 303 .setQualitative(true) 304 .setDomain(DOMAIN_DOCUMENTATION) 305 .setBestValue(0.0) 306 .setOptimizedBestValue(true) 307 .setHidden(true) 308 .create(); 309 310 // -------------------------------------------------------------------------------------------------------------------- 311 // 312 // COMPLEXITY 313 // 314 // -------------------------------------------------------------------------------------------------------------------- 315 316 public static final String COMPLEXITY_KEY = "complexity"; 317 public static final Metric<Integer> COMPLEXITY = new Metric.Builder(COMPLEXITY_KEY, "Complexity", Metric.ValueType.INT) 318 .setDescription("Cyclomatic complexity") 319 .setDirection(Metric.DIRECTION_WORST) 320 .setQualitative(false) 321 .setDomain(DOMAIN_COMPLEXITY) 322 .create(); 323 324 public static final String FILE_COMPLEXITY_KEY = "file_complexity"; 325 public static final Metric<Double> FILE_COMPLEXITY = new Metric.Builder(FILE_COMPLEXITY_KEY, "Complexity / File", Metric.ValueType.FLOAT) 326 .setDescription("Complexity average by file") 327 .setDirection(Metric.DIRECTION_WORST) 328 .setQualitative(true) 329 .setDomain(DOMAIN_COMPLEXITY) 330 .create(); 331 332 /** 333 * @since 3.6 334 */ 335 public static final String COMPLEXITY_IN_CLASSES_KEY = "complexity_in_classes"; 336 337 /** 338 * @since 3.6 339 */ 340 public static final Metric<Integer> COMPLEXITY_IN_CLASSES = new Metric.Builder(COMPLEXITY_IN_CLASSES_KEY, "Complexity in Classes", Metric.ValueType.INT) 341 .setDescription("Cyclomatic complexity in classes") 342 .setHidden(true) 343 .setDirection(Metric.DIRECTION_WORST) 344 .setQualitative(false) 345 .setDomain(DOMAIN_COMPLEXITY) 346 .setDeleteHistoricalData(true) 347 .create(); 348 349 public static final String CLASS_COMPLEXITY_KEY = "class_complexity"; 350 351 /** 352 * Information about the cyclomatic complexity per class, calculated by divided the complexity in classes by the number of classes. 353 * If the complexity in classes is not available, the complexity of the file is used. 354 */ 355 public static final Metric<Double> CLASS_COMPLEXITY = new Metric.Builder(CLASS_COMPLEXITY_KEY, "Complexity / Class", Metric.ValueType.FLOAT) 356 .setDescription("Complexity average by class") 357 .setDirection(Metric.DIRECTION_WORST) 358 .setQualitative(true) 359 .setDomain(DOMAIN_COMPLEXITY) 360 .create(); 361 362 /** 363 * @since 3.6 364 */ 365 public static final String COMPLEXITY_IN_FUNCTIONS_KEY = "complexity_in_functions"; 366 367 /** 368 * @since 3.6 369 */ 370 public static final Metric<Integer> COMPLEXITY_IN_FUNCTIONS = new Metric.Builder(COMPLEXITY_IN_FUNCTIONS_KEY, "Complexity in Functions", Metric.ValueType.INT) 371 .setDescription("Cyclomatic complexity in functions") 372 .setHidden(true) 373 .setDirection(Metric.DIRECTION_WORST) 374 .setQualitative(false) 375 .setDomain(DOMAIN_COMPLEXITY) 376 .setDeleteHistoricalData(true) 377 .create(); 378 379 public static final String FUNCTION_COMPLEXITY_KEY = "function_complexity"; 380 381 /** 382 * Information about the cyclomatic complexity per function, calculated by divided the complexity in functions by the number of functions. 383 * If the complexity in functions is not available, the complexity of the file is used. 384 */ 385 public static final Metric<Double> FUNCTION_COMPLEXITY = new Metric.Builder(FUNCTION_COMPLEXITY_KEY, "Complexity / Function", Metric.ValueType.FLOAT) 386 .setDescription("Complexity average by function") 387 .setDirection(Metric.DIRECTION_WORST) 388 .setQualitative(true) 389 .setDomain(DOMAIN_COMPLEXITY) 390 .create(); 391 392 /** 393 * @deprecated in 3.0 - see SONAR-3289 394 */ 395 @Deprecated 396 public static final String CLASS_COMPLEXITY_DISTRIBUTION_KEY = "class_complexity_distribution"; 397 398 /** 399 * @deprecated in 3.0 - see SONAR-3289 400 */ 401 @Deprecated 402 public static final Metric<String> CLASS_COMPLEXITY_DISTRIBUTION = new Metric.Builder(CLASS_COMPLEXITY_DISTRIBUTION_KEY, "Class Distribution / Complexity", 403 Metric.ValueType.DISTRIB) 404 .setDescription("Classes distribution /complexity") 405 .setDirection(Metric.DIRECTION_NONE) 406 .setQualitative(true) 407 .setDomain(DOMAIN_COMPLEXITY) 408 .setHidden(true) 409 .create(); 410 411 public static final String FUNCTION_COMPLEXITY_DISTRIBUTION_KEY = "function_complexity_distribution"; 412 public static final Metric<String> FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Function Distribution / Complexity", 413 Metric.ValueType.DISTRIB) 414 .setDescription("Functions distribution /complexity") 415 .setDirection(Metric.DIRECTION_NONE) 416 .setQualitative(true) 417 .setDomain(DOMAIN_COMPLEXITY) 418 .create(); 419 420 public static final String FILE_COMPLEXITY_DISTRIBUTION_KEY = "file_complexity_distribution"; 421 public static final Metric<String> FILE_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FILE_COMPLEXITY_DISTRIBUTION_KEY, "File Distribution / Complexity", 422 Metric.ValueType.DISTRIB) 423 .setDescription("Files distribution /complexity") 424 .setDirection(Metric.DIRECTION_NONE) 425 .setQualitative(true) 426 .setDomain(DOMAIN_COMPLEXITY) 427 .create(); 428 429 // -------------------------------------------------------------------------------------------------------------------- 430 // 431 // UNIT TESTS 432 // 433 // -------------------------------------------------------------------------------------------------------------------- 434 435 public static final String TESTS_KEY = "tests"; 436 437 /** 438 * Value of measure for this metric can be saved from Sensor, taking into account following rules: 439 * <ul> 440 * <li>Non-zero value should be saved for resources representing tests. And Sonar provides default Decorator, which will decorate parent resources.</li> 441 * <li>Should include {@link #TEST_FAILURES} and {@link #TEST_ERRORS}, but should not include {@link #SKIPPED_TESTS}.</li> 442 * </ul> 443 */ 444 public static final Metric<Integer> TESTS = new Metric.Builder(TESTS_KEY, "Unit Tests", Metric.ValueType.INT) 445 .setDescription("Number of unit tests") 446 .setDirection(Metric.DIRECTION_WORST) 447 .setQualitative(false) 448 .setDomain(DOMAIN_COVERAGE) 449 .create(); 450 451 public static final String TEST_EXECUTION_TIME_KEY = "test_execution_time"; 452 public static final Metric<Long> TEST_EXECUTION_TIME = new Metric.Builder(TEST_EXECUTION_TIME_KEY, "Unit Test Duration", Metric.ValueType.MILLISEC) 453 .setDescription("Execution duration of unit tests") 454 .setDirection(Metric.DIRECTION_WORST) 455 .setQualitative(false) 456 .setDomain(DOMAIN_COVERAGE) 457 .create(); 458 459 public static final String TEST_ERRORS_KEY = "test_errors"; 460 public static final Metric<Integer> TEST_ERRORS = new Metric.Builder(TEST_ERRORS_KEY, "Unit Test Errors", Metric.ValueType.INT) 461 .setDescription("Number of unit test errors") 462 .setDirection(Metric.DIRECTION_WORST) 463 .setQualitative(true) 464 .setDomain(DOMAIN_COVERAGE) 465 .setBestValue(0.0) 466 .setOptimizedBestValue(true) 467 .create(); 468 469 public static final String SKIPPED_TESTS_KEY = "skipped_tests"; 470 public static final Metric<Integer> SKIPPED_TESTS = new Metric.Builder(SKIPPED_TESTS_KEY, "Skipped Unit Tests", Metric.ValueType.INT) 471 .setDescription("Number of skipped unit tests") 472 .setDirection(Metric.DIRECTION_WORST) 473 .setQualitative(true) 474 .setDomain(DOMAIN_COVERAGE) 475 .setBestValue(0.0) 476 .setOptimizedBestValue(true) 477 .create(); 478 479 public static final String TEST_FAILURES_KEY = "test_failures"; 480 public static final Metric<Integer> TEST_FAILURES = new Metric.Builder(TEST_FAILURES_KEY, "Unit Test Failures", Metric.ValueType.INT) 481 .setDescription("Number of unit test failures") 482 .setDirection(Metric.DIRECTION_WORST) 483 .setQualitative(true) 484 .setDomain(DOMAIN_COVERAGE) 485 .setBestValue(0.0) 486 .setOptimizedBestValue(true) 487 .create(); 488 489 public static final String TEST_SUCCESS_DENSITY_KEY = "test_success_density"; 490 public static final Metric<Double> TEST_SUCCESS_DENSITY = new Metric.Builder(TEST_SUCCESS_DENSITY_KEY, "Unit Test Success (%)", Metric.ValueType.PERCENT) 491 .setDescription("Density of successful unit tests") 492 .setDirection(Metric.DIRECTION_BETTER) 493 .setQualitative(true) 494 .setDomain(DOMAIN_COVERAGE) 495 .setWorstValue(0.0) 496 .setBestValue(100.0) 497 .setOptimizedBestValue(true) 498 .create(); 499 500 /** 501 * @deprecated since 5.2 use {@link MutableTestPlan} 502 */ 503 @Deprecated 504 public static final String TEST_DATA_KEY = "test_data"; 505 /** 506 * @deprecated since 5.2 use {@link MutableTestPlan} 507 */ 508 @Deprecated 509 public static final Metric<String> TEST_DATA = new Metric.Builder(TEST_DATA_KEY, "Unit Test Details", Metric.ValueType.DATA) 510 .setDescription("Unit tests details") 511 .setDirection(Metric.DIRECTION_WORST) 512 .setDomain(DOMAIN_COVERAGE) 513 .create(); 514 515 public static final String COVERAGE_KEY = "coverage"; 516 public static final Metric<Double> COVERAGE = new Metric.Builder(COVERAGE_KEY, "Coverage", Metric.ValueType.PERCENT) 517 .setDescription("Coverage by unit tests") 518 .setDirection(Metric.DIRECTION_BETTER) 519 .setQualitative(true) 520 .setDomain(DOMAIN_COVERAGE) 521 .setWorstValue(0.0) 522 .setBestValue(100.0) 523 .create(); 524 525 public static final String NEW_COVERAGE_KEY = "new_coverage"; 526 public static final Metric<Double> NEW_COVERAGE = new Metric.Builder(NEW_COVERAGE_KEY, "Coverage on New Code", Metric.ValueType.PERCENT) 527 .setDescription("Coverage of new/changed code") 528 .setDirection(Metric.DIRECTION_BETTER) 529 .setQualitative(true) 530 .setDomain(DOMAIN_COVERAGE) 531 .setWorstValue(0.0) 532 .setBestValue(100.0) 533 .setDeleteHistoricalData(true) 534 .create(); 535 536 public static final String LINES_TO_COVER_KEY = "lines_to_cover"; 537 538 /** 539 * Use {@link CoverageMeasuresBuilder} to build measure for this metric. 540 */ 541 public static final Metric<Integer> LINES_TO_COVER = new Metric.Builder(LINES_TO_COVER_KEY, "Lines to Cover", Metric.ValueType.INT) 542 .setDescription("Lines to cover") 543 .setDirection(Metric.DIRECTION_BETTER) 544 .setQualitative(false) 545 .setDomain(DOMAIN_COVERAGE) 546 .create(); 547 548 public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover"; 549 public static final Metric<Integer> NEW_LINES_TO_COVER = new Metric.Builder(NEW_LINES_TO_COVER_KEY, "Lines to Cover on New Code", Metric.ValueType.INT) 550 .setDescription("Lines to cover on new code") 551 .setDirection(Metric.DIRECTION_WORST) 552 .setQualitative(false) 553 .setDomain(DOMAIN_COVERAGE) 554 .setDeleteHistoricalData(true) 555 .create(); 556 557 public static final String UNCOVERED_LINES_KEY = "uncovered_lines"; 558 559 /** 560 * Use {@link CoverageMeasuresBuilder} to build measure for this metric. 561 */ 562 public static final Metric<Integer> UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, "Uncovered Lines", Metric.ValueType.INT) 563 .setDescription("Uncovered lines") 564 .setDirection(Metric.DIRECTION_WORST) 565 .setDomain(DOMAIN_COVERAGE) 566 .setBestValue(0.0) 567 .create(); 568 569 public static final String NEW_UNCOVERED_LINES_KEY = "new_uncovered_lines"; 570 public static final Metric<Integer> NEW_UNCOVERED_LINES = new Metric.Builder(NEW_UNCOVERED_LINES_KEY, "Uncovered Lines on New Code", Metric.ValueType.INT) 571 .setDescription("Uncovered lines on new code") 572 .setDirection(Metric.DIRECTION_WORST) 573 .setDomain(DOMAIN_COVERAGE) 574 .setBestValue(0.0) 575 .setDeleteHistoricalData(true) 576 .create(); 577 578 public static final String LINE_COVERAGE_KEY = "line_coverage"; 579 public static final Metric<Double> LINE_COVERAGE = new Metric.Builder(LINE_COVERAGE_KEY, "Line Coverage", Metric.ValueType.PERCENT) 580 .setDescription("Line coverage") 581 .setDirection(Metric.DIRECTION_BETTER) 582 .setQualitative(true) 583 .setDomain(DOMAIN_COVERAGE) 584 .setWorstValue(0.0) 585 .setBestValue(100.0) 586 .create(); 587 588 public static final String NEW_LINE_COVERAGE_KEY = "new_line_coverage"; 589 public static final Metric<Double> NEW_LINE_COVERAGE = new Metric.Builder(NEW_LINE_COVERAGE_KEY, "Line Coverage on New Code", Metric.ValueType.PERCENT) 590 .setDescription("Line coverage of added/changed code") 591 .setDirection(Metric.DIRECTION_BETTER) 592 .setQualitative(true) 593 .setWorstValue(0.0) 594 .setBestValue(100.0) 595 .setDomain(DOMAIN_COVERAGE) 596 .setDeleteHistoricalData(true) 597 .create(); 598 599 /** 600 * 601 * @deprecated since 5.2 soon to be removed 602 */ 603 @Deprecated 604 public static final String COVERAGE_LINE_HITS_DATA_KEY = "coverage_line_hits_data"; 605 606 /** 607 * Key-value pairs, where key - is a number of line, and value - is a number of hits for this line. 608 * Use {@link CoverageMeasuresBuilder} to build measure for this metric. 609 * @deprecated since 5.2 soon to be removed 610 */ 611 @Deprecated 612 public static final Metric<String> COVERAGE_LINE_HITS_DATA = new Metric.Builder(COVERAGE_LINE_HITS_DATA_KEY, "Coverage Hits by Line", Metric.ValueType.DATA) 613 .setDescription("Coverage hits by line") 614 .setDomain(DOMAIN_COVERAGE) 615 .setDeleteHistoricalData(true) 616 .create(); 617 618 public static final String CONDITIONS_TO_COVER_KEY = "conditions_to_cover"; 619 620 /** 621 * Use {@link CoverageMeasuresBuilder} to build measure for this metric. 622 */ 623 public static final Metric<Integer> CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, "Branches to Cover", Metric.ValueType.INT) 624 .setDescription("Branches to cover") 625 .setDomain(DOMAIN_COVERAGE) 626 .setHidden(true) 627 .create(); 628 629 public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover"; 630 public static final Metric<Integer> NEW_CONDITIONS_TO_COVER = new Metric.Builder(NEW_CONDITIONS_TO_COVER_KEY, "Branches to Cover on New Code", Metric.ValueType.INT) 631 .setDescription("Branches to cover on New Code") 632 .setDomain(DOMAIN_COVERAGE) 633 .setDeleteHistoricalData(true) 634 .setHidden(true) 635 .create(); 636 637 public static final String UNCOVERED_CONDITIONS_KEY = "uncovered_conditions"; 638 639 /** 640 * Use {@link CoverageMeasuresBuilder} to build measure for this metric. 641 */ 642 public static final Metric<Integer> UNCOVERED_CONDITIONS = new Metric.Builder(UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions", Metric.ValueType.INT) 643 .setDescription("Uncovered conditions") 644 .setDirection(Metric.DIRECTION_WORST) 645 .setDomain(DOMAIN_COVERAGE) 646 .setBestValue(0.0) 647 .create(); 648 649 public static final String NEW_UNCOVERED_CONDITIONS_KEY = "new_uncovered_conditions"; 650 public static final Metric<Integer> NEW_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions on New Code", Metric.ValueType.INT) 651 .setDescription("Uncovered conditions on new code") 652 .setDirection(Metric.DIRECTION_WORST) 653 .setDomain(DOMAIN_COVERAGE) 654 .setBestValue(0.0) 655 .setDeleteHistoricalData(true) 656 .create(); 657 658 public static final String BRANCH_COVERAGE_KEY = "branch_coverage"; 659 public static final Metric<Double> BRANCH_COVERAGE = new Metric.Builder(BRANCH_COVERAGE_KEY, "Condition Coverage", Metric.ValueType.PERCENT) 660 .setDescription("Condition coverage") 661 .setDirection(Metric.DIRECTION_BETTER) 662 .setQualitative(true) 663 .setDomain(DOMAIN_COVERAGE) 664 .setWorstValue(0.0) 665 .setBestValue(100.0) 666 .create(); 667 668 public static final String NEW_BRANCH_COVERAGE_KEY = "new_branch_coverage"; 669 public static final Metric<Double> NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, "Condition Coverage on New Code", Metric.ValueType.PERCENT) 670 .setDescription("Condition coverage of new/changed code") 671 .setDirection(Metric.DIRECTION_BETTER) 672 .setQualitative(true) 673 .setDomain(DOMAIN_COVERAGE) 674 .setWorstValue(0.0) 675 .setBestValue(100.0) 676 .setDeleteHistoricalData(true) 677 .create(); 678 679 /** 680 * @deprecated since 5.2 soon to be removed 681 */ 682 @Deprecated 683 public static final String CONDITIONS_BY_LINE_KEY = "conditions_by_line"; 684 685 /** 686 * Use {@link CoverageMeasuresBuilder} to build measure for this metric. 687 * 688 * @since 2.7 689 * @deprecated since 5.2 soon to be removed 690 */ 691 @Deprecated 692 public static final Metric<String> CONDITIONS_BY_LINE = new Metric.Builder(CONDITIONS_BY_LINE_KEY, "Conditions by Line", Metric.ValueType.DATA) 693 .setDescription("Conditions by line") 694 .setDomain(DOMAIN_COVERAGE) 695 .setDeleteHistoricalData(true) 696 .create(); 697 698 /** 699 * @deprecated since 5.2 soon to be removed 700 */ 701 @Deprecated 702 public static final String COVERED_CONDITIONS_BY_LINE_KEY = "covered_conditions_by_line"; 703 704 /** 705 * Use {@link CoverageMeasuresBuilder} to build measure for this metric. 706 * 707 * @since 2.7 708 * @deprecated since 5.2 soon to be removed 709 */ 710 @Deprecated 711 public static final Metric<String> COVERED_CONDITIONS_BY_LINE = new Metric.Builder(COVERED_CONDITIONS_BY_LINE_KEY, "Covered Conditions by Line", Metric.ValueType.DATA) 712 .setDescription("Covered conditions by line") 713 .setDomain(DOMAIN_COVERAGE) 714 .setDeleteHistoricalData(true) 715 .create(); 716 717 // -------------------------------------------------------------------------------------------------------------------- 718 // 719 // INTEGRATION TESTS 720 // 721 // -------------------------------------------------------------------------------------------------------------------- 722 723 /** 724 * @since 2.12 725 */ 726 public static final String IT_COVERAGE_KEY = "it_coverage"; 727 728 /** 729 * @since 2.12 730 */ 731 public static final Metric<Double> IT_COVERAGE = new Metric.Builder(IT_COVERAGE_KEY, "IT Coverage", Metric.ValueType.PERCENT) 732 .setDescription("Integration tests coverage") 733 .setDirection(Metric.DIRECTION_BETTER) 734 .setQualitative(true) 735 .setDomain(DOMAIN_COVERAGE) 736 .setWorstValue(0.0) 737 .setBestValue(100.0) 738 .create(); 739 740 /** 741 * @since 2.12 742 */ 743 public static final String NEW_IT_COVERAGE_KEY = "new_it_coverage"; 744 745 /** 746 * @since 2.12 747 */ 748 public static final Metric<Double> NEW_IT_COVERAGE = new Metric.Builder(NEW_IT_COVERAGE_KEY, "Coverage by IT on New Code", Metric.ValueType.PERCENT) 749 .setDescription("Integration tests coverage of new/changed code") 750 .setDirection(Metric.DIRECTION_BETTER) 751 .setQualitative(true) 752 .setDomain(DOMAIN_COVERAGE) 753 .setWorstValue(0.0) 754 .setBestValue(100.0) 755 .setDeleteHistoricalData(true) 756 .create(); 757 758 /** 759 * @since 2.12 760 */ 761 public static final String IT_LINES_TO_COVER_KEY = "it_lines_to_cover"; 762 763 /** 764 * @since 2.12 765 */ 766 public static final Metric<Integer> IT_LINES_TO_COVER = new Metric.Builder(IT_LINES_TO_COVER_KEY, "IT Lines to Cover", Metric.ValueType.INT) 767 .setDescription("Lines to cover by Integration Tests") 768 .setDirection(Metric.DIRECTION_BETTER) 769 .setDomain(DOMAIN_COVERAGE) 770 .setQualitative(false) 771 .setHidden(true) 772 .create(); 773 774 /** 775 * @since 2.12 776 */ 777 public static final String NEW_IT_LINES_TO_COVER_KEY = "new_it_lines_to_cover"; 778 779 /** 780 * @since 2.12 781 */ 782 public static final Metric<Integer> 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) 783 .setDescription("Lines to cover on new code by integration tests") 784 .setDirection(Metric.DIRECTION_WORST) 785 .setQualitative(false) 786 .setDomain(DOMAIN_COVERAGE) 787 .setDeleteHistoricalData(true) 788 .create(); 789 790 /** 791 * @since 2.12 792 */ 793 public static final String IT_UNCOVERED_LINES_KEY = "it_uncovered_lines"; 794 795 /** 796 * @since 2.12 797 */ 798 public static final Metric<Integer> IT_UNCOVERED_LINES = new Metric.Builder(IT_UNCOVERED_LINES_KEY, "IT Uncovered Lines", Metric.ValueType.INT) 799 .setDescription("Uncovered lines by integration tests") 800 .setDirection(Metric.DIRECTION_WORST) 801 .setQualitative(false) 802 .setDomain(DOMAIN_COVERAGE) 803 .create(); 804 805 /** 806 * @since 2.12 807 */ 808 public static final String NEW_IT_UNCOVERED_LINES_KEY = "new_it_uncovered_lines"; 809 810 /** 811 * @since 2.12 812 */ 813 public static final Metric<Integer> NEW_IT_UNCOVERED_LINES = new Metric.Builder(NEW_IT_UNCOVERED_LINES_KEY, "Uncovered Lines by IT on New Code", Metric.ValueType.INT) 814 .setDescription("New lines that are not covered by integration tests") 815 .setDirection(Metric.DIRECTION_WORST) 816 .setDomain(DOMAIN_COVERAGE) 817 .setBestValue(0.0) 818 .setDeleteHistoricalData(true) 819 .create(); 820 821 /** 822 * @since 2.12 823 */ 824 public static final String IT_LINE_COVERAGE_KEY = "it_line_coverage"; 825 826 /** 827 * @since 2.12 828 */ 829 public static final Metric<Double> IT_LINE_COVERAGE = new Metric.Builder(IT_LINE_COVERAGE_KEY, "IT Line Coverage", Metric.ValueType.PERCENT) 830 .setDescription("Line coverage by integration tests") 831 .setDirection(Metric.DIRECTION_BETTER) 832 .setQualitative(true) 833 .setDomain(DOMAIN_COVERAGE) 834 .create(); 835 836 /** 837 * @since 2.12 838 */ 839 public static final String NEW_IT_LINE_COVERAGE_KEY = "new_it_line_coverage"; 840 841 /** 842 * @since 2.12 843 */ 844 public static final Metric<Double> NEW_IT_LINE_COVERAGE = new Metric.Builder(NEW_IT_LINE_COVERAGE_KEY, "Line Coverage by IT on New Code", Metric.ValueType.PERCENT) 845 .setDescription("Integration tests line coverage of added/changed code") 846 .setDirection(Metric.DIRECTION_BETTER) 847 .setQualitative(true) 848 .setWorstValue(0.0) 849 .setBestValue(100.0) 850 .setDomain(DOMAIN_COVERAGE) 851 .setDeleteHistoricalData(true) 852 .create(); 853 854 /** 855 * @since 2.12 856 * @deprecated since 5.2 soon to be removed 857 */ 858 @Deprecated 859 public static final String IT_COVERAGE_LINE_HITS_DATA_KEY = "it_coverage_line_hits_data"; 860 861 /** 862 * @since 2.12 863 * @deprecated since 5.2 soon to be removed 864 */ 865 @Deprecated 866 public static final Metric<String> IT_COVERAGE_LINE_HITS_DATA = new Metric.Builder(IT_COVERAGE_LINE_HITS_DATA_KEY, "IT Coverage Hits by Line", Metric.ValueType.DATA) 867 .setDescription("Coverage hits by line by integration tests") 868 .setDirection(Metric.DIRECTION_NONE) 869 .setQualitative(false) 870 .setDomain(DOMAIN_COVERAGE) 871 .setDeleteHistoricalData(true) 872 .create(); 873 874 /** 875 * @since 2.12 876 */ 877 public static final String IT_CONDITIONS_TO_COVER_KEY = "it_conditions_to_cover"; 878 879 /** 880 * @since 2.12 881 */ 882 public static final Metric<Integer> IT_CONDITIONS_TO_COVER = new Metric.Builder(IT_CONDITIONS_TO_COVER_KEY, "IT Branches to Cover", Metric.ValueType.INT) 883 .setDescription("Integration Tests conditions to cover") 884 .setDirection(Metric.DIRECTION_BETTER) 885 .setQualitative(false) 886 .setDomain(DOMAIN_COVERAGE) 887 .setHidden(true) 888 .create(); 889 890 /** 891 * @since 2.12 892 */ 893 public static final String NEW_IT_CONDITIONS_TO_COVER_KEY = "new_it_conditions_to_cover"; 894 895 /** 896 * @since 2.12 897 */ 898 public static final Metric<Integer> 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) 899 .setDescription("Branches to cover by Integration Tests on New Code") 900 .setDomain(DOMAIN_COVERAGE) 901 .setDeleteHistoricalData(true) 902 .setHidden(true) 903 .create(); 904 905 /** 906 * @since 2.12 907 */ 908 public static final String IT_UNCOVERED_CONDITIONS_KEY = "it_uncovered_conditions"; 909 910 /** 911 * @since 2.12 912 */ 913 public static final Metric<Integer> IT_UNCOVERED_CONDITIONS = new Metric.Builder(IT_UNCOVERED_CONDITIONS_KEY, "IT Uncovered Conditions", Metric.ValueType.INT) 914 .setDescription("Uncovered conditions by integration tests") 915 .setDirection(Metric.DIRECTION_WORST) 916 .setDomain(DOMAIN_COVERAGE) 917 .create(); 918 919 /** 920 * @since 2.12 921 */ 922 public static final String NEW_IT_UNCOVERED_CONDITIONS_KEY = "new_it_uncovered_conditions"; 923 924 /** 925 * @since 2.12 926 */ 927 public static final Metric<Integer> NEW_IT_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_IT_UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions by IT on New Code", 928 Metric.ValueType.INT) 929 .setDescription("New conditions that are not covered by integration tests") 930 .setDirection(Metric.DIRECTION_WORST) 931 .setDomain(DOMAIN_COVERAGE) 932 .setBestValue(0.0) 933 .setDeleteHistoricalData(true) 934 .create(); 935 936 /** 937 * @since 2.12 938 */ 939 public static final String IT_BRANCH_COVERAGE_KEY = "it_branch_coverage"; 940 941 /** 942 * @since 2.12 943 */ 944 public static final Metric<Double> IT_BRANCH_COVERAGE = new Metric.Builder(IT_BRANCH_COVERAGE_KEY, "IT Condition Coverage", Metric.ValueType.PERCENT) 945 .setDescription("Condition coverage by integration tests") 946 .setDirection(Metric.DIRECTION_BETTER) 947 .setQualitative(true) 948 .setDomain(DOMAIN_COVERAGE) 949 .setWorstValue(0.0) 950 .setBestValue(100.0) 951 .create(); 952 953 /** 954 * @since 2.12 955 */ 956 public static final String NEW_IT_BRANCH_COVERAGE_KEY = "new_it_branch_coverage"; 957 958 /** 959 * @since 2.12 960 */ 961 public static final Metric<Double> NEW_IT_BRANCH_COVERAGE = new Metric.Builder(NEW_IT_BRANCH_COVERAGE_KEY, "Condition Coverage by IT on New Code", Metric.ValueType.PERCENT) 962 .setDescription("Integration tests condition coverage of new/changed code") 963 .setDirection(Metric.DIRECTION_BETTER) 964 .setQualitative(true) 965 .setDomain(DOMAIN_COVERAGE) 966 .setWorstValue(0.0) 967 .setBestValue(100.0) 968 .setDeleteHistoricalData(true) 969 .create(); 970 971 /** 972 * @since 2.12 973 * @deprecated since 5.2 soon to be removed 974 */ 975 @Deprecated 976 public static final String IT_CONDITIONS_BY_LINE_KEY = "it_conditions_by_line"; 977 978 /** 979 * @since 2.12 980 * @deprecated since 5.2 soon to be removed 981 */ 982 @Deprecated 983 public static final Metric<String> IT_CONDITIONS_BY_LINE = new Metric.Builder(IT_CONDITIONS_BY_LINE_KEY, "IT Conditions by Line", Metric.ValueType.DATA) 984 .setDescription("IT conditions by line") 985 .setDomain(DOMAIN_COVERAGE) 986 .setDeleteHistoricalData(true) 987 .create(); 988 989 /** 990 * @since 2.12 991 * @deprecated since 5.2 soon to be removed 992 */ 993 @Deprecated 994 public static final String IT_COVERED_CONDITIONS_BY_LINE_KEY = "it_covered_conditions_by_line"; 995 996 /** 997 * @since 2.12 998 * @deprecated since 5.2 soon to be removed 999 */ 1000 @Deprecated 1001 public static final Metric<String> IT_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(IT_COVERED_CONDITIONS_BY_LINE_KEY, "IT Covered Conditions by Line", Metric.ValueType.DATA) 1002 .setDescription("IT covered conditions by line") 1003 .setDomain(DOMAIN_COVERAGE) 1004 .setDeleteHistoricalData(true) 1005 .create(); 1006 1007 // -------------------------------------------------------------------------------------------------------------------- 1008 // 1009 // OVERALL TESTS 1010 // 1011 // -------------------------------------------------------------------------------------------------------------------- 1012 1013 /** 1014 * @since 3.3 1015 */ 1016 public static final String OVERALL_COVERAGE_KEY = "overall_coverage"; 1017 1018 /** 1019 * @since 3.3 1020 */ 1021 public static final Metric<Double> OVERALL_COVERAGE = new Metric.Builder(OVERALL_COVERAGE_KEY, "Overall Coverage", Metric.ValueType.PERCENT) 1022 .setDescription("Overall test coverage") 1023 .setDirection(Metric.DIRECTION_BETTER) 1024 .setQualitative(true) 1025 .setDomain(DOMAIN_COVERAGE) 1026 .setWorstValue(0.0) 1027 .setBestValue(100.0) 1028 .create(); 1029 1030 /** 1031 * @since 3.3 1032 */ 1033 public static final String NEW_OVERALL_COVERAGE_KEY = "new_overall_coverage"; 1034 1035 /** 1036 * @since 3.3 1037 */ 1038 public static final Metric<Double> NEW_OVERALL_COVERAGE = new Metric.Builder(NEW_OVERALL_COVERAGE_KEY, "Overall Coverage on New Code", Metric.ValueType.PERCENT) 1039 .setDescription("Overall coverage of new/changed code") 1040 .setDirection(Metric.DIRECTION_BETTER) 1041 .setQualitative(true) 1042 .setDomain(DOMAIN_COVERAGE) 1043 .setWorstValue(0.0) 1044 .setBestValue(100.0) 1045 .setDeleteHistoricalData(true) 1046 .create(); 1047 1048 /** 1049 * @since 3.3 1050 */ 1051 public static final String OVERALL_LINES_TO_COVER_KEY = "overall_lines_to_cover"; 1052 1053 /** 1054 * @since 3.3 1055 */ 1056 public static final Metric<Integer> OVERALL_LINES_TO_COVER = new Metric.Builder(OVERALL_LINES_TO_COVER_KEY, "Overall Lines to Cover", Metric.ValueType.INT) 1057 .setDescription("Overall lines to cover by all tests") 1058 .setDirection(Metric.DIRECTION_BETTER) 1059 .setDomain(DOMAIN_COVERAGE) 1060 .setQualitative(false) 1061 .setHidden(true) 1062 .create(); 1063 1064 /** 1065 * @since 3.3 1066 */ 1067 public static final String NEW_OVERALL_LINES_TO_COVER_KEY = "new_overall_lines_to_cover"; 1068 1069 /** 1070 * @since 3.3 1071 */ 1072 public static final Metric<Integer> NEW_OVERALL_LINES_TO_COVER = new Metric.Builder(NEW_OVERALL_LINES_TO_COVER_KEY, "Overall Lines to Cover on New Code", Metric.ValueType.INT) 1073 .setDescription("New lines to cover by all tests") 1074 .setDirection(Metric.DIRECTION_WORST) 1075 .setQualitative(false) 1076 .setDomain(DOMAIN_COVERAGE) 1077 .setDeleteHistoricalData(true) 1078 .create(); 1079 1080 /** 1081 * @since 3.3 1082 */ 1083 public static final String OVERALL_UNCOVERED_LINES_KEY = "overall_uncovered_lines"; 1084 1085 /** 1086 * @since 3.3 1087 */ 1088 public static final Metric<Integer> OVERALL_UNCOVERED_LINES = new Metric.Builder(OVERALL_UNCOVERED_LINES_KEY, "Overall Uncovered Lines", Metric.ValueType.INT) 1089 .setDescription("Uncovered lines by all tests") 1090 .setDirection(Metric.DIRECTION_WORST) 1091 .setQualitative(false) 1092 .setDomain(DOMAIN_COVERAGE) 1093 .create(); 1094 1095 /** 1096 * @since 3.3 1097 */ 1098 public static final String NEW_OVERALL_UNCOVERED_LINES_KEY = "new_overall_uncovered_lines"; 1099 1100 /** 1101 * @since 3.3 1102 */ 1103 public static final Metric<Integer> NEW_OVERALL_UNCOVERED_LINES = new Metric.Builder(NEW_OVERALL_UNCOVERED_LINES_KEY, "Overall Uncovered Lines on New Code", Metric.ValueType.INT) 1104 .setDescription("New lines that are not covered by any tests") 1105 .setDirection(Metric.DIRECTION_WORST) 1106 .setDomain(DOMAIN_COVERAGE) 1107 .setBestValue(0.0) 1108 .setDeleteHistoricalData(true) 1109 .create(); 1110 1111 /** 1112 * @since 3.3 1113 */ 1114 public static final String OVERALL_LINE_COVERAGE_KEY = "overall_line_coverage"; 1115 1116 /** 1117 * @since 3.3 1118 */ 1119 public static final Metric<Double> OVERALL_LINE_COVERAGE = new Metric.Builder(OVERALL_LINE_COVERAGE_KEY, "Overall Line Coverage", Metric.ValueType.PERCENT) 1120 .setDescription("Line coverage by all tests") 1121 .setDirection(Metric.DIRECTION_BETTER) 1122 .setQualitative(true) 1123 .setDomain(DOMAIN_COVERAGE) 1124 .create(); 1125 1126 /** 1127 * @since 3.3 1128 */ 1129 public static final String NEW_OVERALL_LINE_COVERAGE_KEY = "new_overall_line_coverage"; 1130 1131 /** 1132 * @since 3.3 1133 */ 1134 public static final Metric<Double> NEW_OVERALL_LINE_COVERAGE = new Metric.Builder(NEW_OVERALL_LINE_COVERAGE_KEY, "Overall Line Coverage on New Code", Metric.ValueType.PERCENT) 1135 .setDescription("Line coverage of added/changed code by all tests") 1136 .setDirection(Metric.DIRECTION_BETTER) 1137 .setQualitative(true) 1138 .setWorstValue(0.0) 1139 .setBestValue(100.0) 1140 .setDomain(DOMAIN_COVERAGE) 1141 .setDeleteHistoricalData(true) 1142 .create(); 1143 1144 /** 1145 * @since 3.3 1146 * @deprecated since 5.2 soon to be removed 1147 */ 1148 @Deprecated 1149 public static final String OVERALL_COVERAGE_LINE_HITS_DATA_KEY = "overall_coverage_line_hits_data"; 1150 1151 /** 1152 * @since 3.3 1153 * @deprecated since 5.2 soon to be removed 1154 */ 1155 @Deprecated 1156 public static final Metric<String> OVERALL_COVERAGE_LINE_HITS_DATA = new Metric.Builder(OVERALL_COVERAGE_LINE_HITS_DATA_KEY, "Overall Coverage Hits by Line", 1157 Metric.ValueType.DATA) 1158 .setDescription("Coverage hits by all tests and by line") 1159 .setDirection(Metric.DIRECTION_NONE) 1160 .setQualitative(false) 1161 .setDomain(DOMAIN_COVERAGE) 1162 .setDeleteHistoricalData(true) 1163 .create(); 1164 1165 /** 1166 * @since 3.3 1167 */ 1168 public static final String OVERALL_CONDITIONS_TO_COVER_KEY = "overall_conditions_to_cover"; 1169 1170 /** 1171 * @since 3.3 1172 */ 1173 public static final Metric<Integer> OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(OVERALL_CONDITIONS_TO_COVER_KEY, "Overall Branches to Cover", Metric.ValueType.INT) 1174 .setDescription("Branches to cover by all tests") 1175 .setDirection(Metric.DIRECTION_BETTER) 1176 .setQualitative(false) 1177 .setDomain(DOMAIN_COVERAGE) 1178 .setHidden(true) 1179 .create(); 1180 1181 /** 1182 * @since 3.3 1183 */ 1184 public static final String NEW_OVERALL_CONDITIONS_TO_COVER_KEY = "new_overall_conditions_to_cover"; 1185 1186 /** 1187 * @since 3.3 1188 */ 1189 public static final Metric<Integer> NEW_OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(NEW_OVERALL_CONDITIONS_TO_COVER_KEY, "Overall Branches to Cover on New Code", 1190 Metric.ValueType.INT) 1191 .setDescription("New branches to cover by all tests") 1192 .setDomain(DOMAIN_COVERAGE) 1193 .setDeleteHistoricalData(true) 1194 .setHidden(true) 1195 .create(); 1196 1197 /** 1198 * @since 3.3 1199 */ 1200 public static final String OVERALL_UNCOVERED_CONDITIONS_KEY = "overall_uncovered_conditions"; 1201 1202 /** 1203 * @since 3.3 1204 */ 1205 public static final Metric<Integer> OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall Uncovered Conditions", Metric.ValueType.INT) 1206 .setDescription("Uncovered conditions by all tests") 1207 .setDirection(Metric.DIRECTION_WORST) 1208 .setDomain(DOMAIN_COVERAGE) 1209 .create(); 1210 1211 /** 1212 * @since 3.3 1213 */ 1214 public static final String NEW_OVERALL_UNCOVERED_CONDITIONS_KEY = "new_overall_uncovered_conditions"; 1215 1216 /** 1217 * @since 3.3 1218 */ 1219 public static final Metric<Integer> NEW_OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall Uncovered Conditions on New Code", 1220 Metric.ValueType.INT) 1221 .setDescription("New conditions that are not covered by any test") 1222 .setDirection(Metric.DIRECTION_WORST) 1223 .setDomain(DOMAIN_COVERAGE) 1224 .setBestValue(0.0) 1225 .setDeleteHistoricalData(true) 1226 .create(); 1227 1228 /** 1229 * @since 3.3 1230 */ 1231 public static final String OVERALL_BRANCH_COVERAGE_KEY = "overall_branch_coverage"; 1232 1233 /** 1234 * @since 3.3 1235 */ 1236 public static final Metric<Double> OVERALL_BRANCH_COVERAGE = new Metric.Builder(OVERALL_BRANCH_COVERAGE_KEY, "Overall Condition Coverage", Metric.ValueType.PERCENT) 1237 .setDescription("Condition coverage by all tests") 1238 .setDirection(Metric.DIRECTION_BETTER) 1239 .setQualitative(true) 1240 .setDomain(DOMAIN_COVERAGE) 1241 .setWorstValue(0.0) 1242 .setBestValue(100.0) 1243 .create(); 1244 1245 /** 1246 * @since 3.3 1247 */ 1248 public static final String NEW_OVERALL_BRANCH_COVERAGE_KEY = "new_overall_branch_coverage"; 1249 1250 /** 1251 * @since 3.3 1252 */ 1253 public static final Metric<Double> NEW_OVERALL_BRANCH_COVERAGE = new Metric.Builder(NEW_OVERALL_BRANCH_COVERAGE_KEY, "Overall Condition Coverage on New Code", 1254 Metric.ValueType.PERCENT) 1255 .setDescription("Condition coverage of new/changed code by all tests") 1256 .setDirection(Metric.DIRECTION_BETTER) 1257 .setQualitative(true) 1258 .setDomain(DOMAIN_COVERAGE) 1259 .setWorstValue(0.0) 1260 .setBestValue(100.0) 1261 .setDeleteHistoricalData(true) 1262 .create(); 1263 1264 /** 1265 * @since 3.3 1266 * @deprecated since 5.2 soon to be removed 1267 */ 1268 @Deprecated 1269 public static final String OVERALL_CONDITIONS_BY_LINE_KEY = "overall_conditions_by_line"; 1270 1271 /** 1272 * @since 3.3 1273 * @deprecated since 5.2 soon to be removed 1274 */ 1275 @Deprecated 1276 public static final Metric<String> OVERALL_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_CONDITIONS_BY_LINE_KEY, "Overall Conditions by Line", Metric.ValueType.DATA) 1277 .setDescription("Overall conditions by all tests and by line") 1278 .setDomain(DOMAIN_COVERAGE) 1279 .setDeleteHistoricalData(true) 1280 .create(); 1281 1282 /** 1283 * @since 3.3 1284 * @deprecated since 5.2 soon to be removed 1285 */ 1286 @Deprecated 1287 public static final String OVERALL_COVERED_CONDITIONS_BY_LINE_KEY = "overall_covered_conditions_by_line"; 1288 1289 /** 1290 * @since 3.3 1291 * @deprecated since 5.2 soon to be removed 1292 */ 1293 @Deprecated 1294 public static final Metric<String> OVERALL_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_COVERED_CONDITIONS_BY_LINE_KEY, "Overall Covered Conditions by Line", 1295 Metric.ValueType.DATA) 1296 .setDescription("Overall covered conditions by all tests and by line") 1297 .setDomain(DOMAIN_COVERAGE) 1298 .setDeleteHistoricalData(true) 1299 .create(); 1300 1301 // -------------------------------------------------------------------------------------------------------------------- 1302 // 1303 // DUPLICATIONS 1304 // 1305 // -------------------------------------------------------------------------------------------------------------------- 1306 1307 public static final String DUPLICATED_LINES_KEY = "duplicated_lines"; 1308 public static final Metric<Integer> DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated Lines", Metric.ValueType.INT) 1309 .setDescription("Duplicated lines") 1310 .setDirection(Metric.DIRECTION_WORST) 1311 .setQualitative(true) 1312 .setDomain(DOMAIN_DUPLICATIONS) 1313 .setBestValue(0.0) 1314 .setOptimizedBestValue(true) 1315 .create(); 1316 1317 public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks"; 1318 public static final Metric<Integer> DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated Blocks", Metric.ValueType.INT) 1319 .setDescription("Duplicated blocks") 1320 .setDirection(Metric.DIRECTION_WORST) 1321 .setQualitative(true) 1322 .setDomain(DOMAIN_DUPLICATIONS) 1323 .setBestValue(0.0) 1324 .setOptimizedBestValue(true) 1325 .create(); 1326 1327 public static final String DUPLICATED_FILES_KEY = "duplicated_files"; 1328 1329 /** 1330 * For files: if it contains duplicates, then 1, otherwise 0. 1331 * For other resources: amount of files under this resource with duplicates. 1332 */ 1333 public static final Metric<Integer> DUPLICATED_FILES = new Metric.Builder(DUPLICATED_FILES_KEY, "Duplicated Files", Metric.ValueType.INT) 1334 .setDescription("Duplicated files") 1335 .setDirection(Metric.DIRECTION_WORST) 1336 .setQualitative(true) 1337 .setDomain(DOMAIN_DUPLICATIONS) 1338 .setBestValue(0.0) 1339 .setOptimizedBestValue(true) 1340 .create(); 1341 1342 public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density"; 1343 public static final Metric<Double> DUPLICATED_LINES_DENSITY = new Metric.Builder(DUPLICATED_LINES_DENSITY_KEY, "Duplicated Lines (%)", Metric.ValueType.PERCENT) 1344 .setDescription("Duplicated lines balanced by statements") 1345 .setDirection(Metric.DIRECTION_WORST) 1346 .setQualitative(true) 1347 .setDomain(DOMAIN_DUPLICATIONS) 1348 .setWorstValue(50.0) 1349 .setBestValue(0.0) 1350 .setOptimizedBestValue(true) 1351 .create(); 1352 1353 /** 1354 * @deprecated since 4.5. Internal storage of duplication is not an API. 1355 */ 1356 @Deprecated 1357 public static final String DUPLICATIONS_DATA_KEY = "duplications_data"; 1358 1359 /** 1360 * Information about duplications, which is represented as an XML string. 1361 * <p> 1362 * Here is the format (since Sonar 2.12): 1363 * <pre> 1364 * {@literal 1365 * <duplications> 1366 * <!-- Multiple groups: --> 1367 * <g> 1368 * <!-- Multiple blocks: --> 1369 * <b r="[resource key]" s="[first line]" l="[number of lines]" /> 1370 * ... 1371 * </g> 1372 * ... 1373 * </duplications> 1374 * } 1375 * </pre> 1376 * 1377 * @deprecated since 4.5. Internal storage of duplication is not an API. 1378 */ 1379 @Deprecated 1380 public static final Metric<String> DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplication Details", Metric.ValueType.DATA) 1381 .setDescription("Duplications details") 1382 .setDirection(Metric.DIRECTION_NONE) 1383 .setQualitative(false) 1384 .setDomain(DOMAIN_DUPLICATIONS) 1385 .setDeleteHistoricalData(true) 1386 .create(); 1387 1388 // -------------------------------------------------------------------------------------------------------------------- 1389 // 1390 // CODING RULES 1391 // 1392 // -------------------------------------------------------------------------------------------------------------------- 1393 1394 public static final String VIOLATIONS_KEY = "violations"; 1395 public static final Metric<Integer> VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT) 1396 .setDescription("Issues") 1397 .setDirection(Metric.DIRECTION_WORST) 1398 .setQualitative(true) 1399 .setDomain(DOMAIN_ISSUES) 1400 .setBestValue(0.0) 1401 .setOptimizedBestValue(true) 1402 .create(); 1403 1404 public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations"; 1405 public static final Metric<Integer> BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker Issues", Metric.ValueType.INT) 1406 .setDescription("Blocker issues") 1407 .setDirection(Metric.DIRECTION_WORST) 1408 .setQualitative(true) 1409 .setDomain(DOMAIN_ISSUES) 1410 .setBestValue(0.0) 1411 .setOptimizedBestValue(true) 1412 .create(); 1413 1414 public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations"; 1415 public static final Metric<Integer> CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical Issues", Metric.ValueType.INT) 1416 .setDescription("Critical issues") 1417 .setDirection(Metric.DIRECTION_WORST) 1418 .setQualitative(true) 1419 .setDomain(DOMAIN_ISSUES) 1420 .setBestValue(0.0) 1421 .setOptimizedBestValue(true) 1422 .create(); 1423 1424 public static final String MAJOR_VIOLATIONS_KEY = "major_violations"; 1425 public static final Metric<Integer> MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major Issues", Metric.ValueType.INT) 1426 .setDescription("Major issues") 1427 .setDirection(Metric.DIRECTION_WORST) 1428 .setQualitative(true) 1429 .setDomain(DOMAIN_ISSUES) 1430 .setBestValue(0.0) 1431 .setOptimizedBestValue(true) 1432 .create(); 1433 1434 public static final String MINOR_VIOLATIONS_KEY = "minor_violations"; 1435 public static final Metric<Integer> MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor Issues", Metric.ValueType.INT) 1436 .setDescription("Minor issues") 1437 .setDirection(Metric.DIRECTION_WORST) 1438 .setQualitative(true) 1439 .setDomain(DOMAIN_ISSUES) 1440 .setBestValue(0.0) 1441 .setOptimizedBestValue(true) 1442 .create(); 1443 1444 public static final String INFO_VIOLATIONS_KEY = "info_violations"; 1445 public static final Metric<Integer> INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info Issues", Metric.ValueType.INT) 1446 .setDescription("Info issues") 1447 .setDirection(Metric.DIRECTION_WORST) 1448 .setQualitative(true) 1449 .setDomain(DOMAIN_ISSUES) 1450 .setBestValue(0.0) 1451 .setOptimizedBestValue(true) 1452 .create(); 1453 1454 public static final String NEW_VIOLATIONS_KEY = "new_violations"; 1455 public static final Metric<Integer> NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New Issues", Metric.ValueType.INT) 1456 .setDescription("New issues") 1457 .setDirection(Metric.DIRECTION_WORST) 1458 .setQualitative(true) 1459 .setDomain(DOMAIN_ISSUES) 1460 .setBestValue(0.0) 1461 .setOptimizedBestValue(true) 1462 .setDeleteHistoricalData(true) 1463 .create(); 1464 1465 public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations"; 1466 public static final Metric<Integer> NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker Issues", Metric.ValueType.INT) 1467 .setDescription("New Blocker issues") 1468 .setDirection(Metric.DIRECTION_WORST) 1469 .setQualitative(true) 1470 .setDomain(DOMAIN_ISSUES) 1471 .setBestValue(0.0) 1472 .setOptimizedBestValue(true) 1473 .setDeleteHistoricalData(true) 1474 .create(); 1475 1476 public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations"; 1477 public static final Metric<Integer> NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical Issues", Metric.ValueType.INT) 1478 .setDescription("New Critical issues") 1479 .setDirection(Metric.DIRECTION_WORST) 1480 .setQualitative(true) 1481 .setDomain(DOMAIN_ISSUES) 1482 .setBestValue(0.0) 1483 .setOptimizedBestValue(true) 1484 .setDeleteHistoricalData(true) 1485 .create(); 1486 1487 public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations"; 1488 public static final Metric<Integer> NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major Issues", Metric.ValueType.INT) 1489 .setDescription("New Major issues") 1490 .setDirection(Metric.DIRECTION_WORST) 1491 .setQualitative(true) 1492 .setDomain(DOMAIN_ISSUES) 1493 .setBestValue(0.0) 1494 .setOptimizedBestValue(true) 1495 .setDeleteHistoricalData(true) 1496 .create(); 1497 1498 public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations"; 1499 public static final Metric<Integer> NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor Issues", Metric.ValueType.INT) 1500 .setDescription("New Minor issues") 1501 .setDirection(Metric.DIRECTION_WORST) 1502 .setQualitative(true) 1503 .setDomain(DOMAIN_ISSUES) 1504 .setBestValue(0.0) 1505 .setOptimizedBestValue(true) 1506 .setDeleteHistoricalData(true) 1507 .create(); 1508 1509 public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations"; 1510 public static final Metric<Integer> NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info Issues", Metric.ValueType.INT) 1511 .setDescription("New Info issues") 1512 .setDirection(Metric.DIRECTION_WORST) 1513 .setQualitative(true) 1514 .setDomain(DOMAIN_ISSUES) 1515 .setBestValue(0.0) 1516 .setOptimizedBestValue(true) 1517 .setDeleteHistoricalData(true) 1518 .create(); 1519 1520 /** 1521 * @since 3.6 1522 */ 1523 public static final String FALSE_POSITIVE_ISSUES_KEY = "false_positive_issues"; 1524 1525 /** 1526 * @since 3.6 1527 */ 1528 public static final Metric<Integer> FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False Positive Issues", Metric.ValueType.INT) 1529 .setDescription("False positive issues") 1530 .setDirection(Metric.DIRECTION_WORST) 1531 .setDomain(DOMAIN_ISSUES) 1532 .setBestValue(0.0) 1533 .setOptimizedBestValue(true) 1534 .create(); 1535 1536 /** 1537 * @since 5.6 1538 */ 1539 public static final String WONT_FIX_ISSUES_KEY = "wont_fix_issues"; 1540 1541 /** 1542 * @since 5.6 1543 */ 1544 public static final Metric<Integer> WONT_FIX_ISSUES = new Metric.Builder(WONT_FIX_ISSUES_KEY, "Won't Fix Issues", Metric.ValueType.INT) 1545 .setDescription("Won't fix issues") 1546 .setDirection(Metric.DIRECTION_WORST) 1547 .setDomain(DOMAIN_ISSUES) 1548 .setBestValue(0.0) 1549 .setOptimizedBestValue(true) 1550 .create(); 1551 1552 /** 1553 * @since 3.6 1554 */ 1555 public static final String OPEN_ISSUES_KEY = "open_issues"; 1556 1557 /** 1558 * @since 3.6 1559 */ 1560 public static final Metric<Integer> OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open Issues", Metric.ValueType.INT) 1561 .setDescription("Open issues") 1562 .setDirection(Metric.DIRECTION_WORST) 1563 .setDomain(DOMAIN_ISSUES) 1564 .setBestValue(0.0) 1565 .setOptimizedBestValue(true) 1566 .create(); 1567 1568 /** 1569 * @since 3.6 1570 */ 1571 public static final String REOPENED_ISSUES_KEY = "reopened_issues"; 1572 1573 /** 1574 * @since 3.6 1575 */ 1576 public static final Metric<Integer> REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened Issues", Metric.ValueType.INT) 1577 .setDescription("Reopened issues") 1578 .setDirection(Metric.DIRECTION_WORST) 1579 .setQualitative(true) 1580 .setDomain(DOMAIN_ISSUES) 1581 .setBestValue(0.0) 1582 .setOptimizedBestValue(true) 1583 .create(); 1584 1585 /** 1586 * @since 3.6 1587 */ 1588 public static final String CONFIRMED_ISSUES_KEY = "confirmed_issues"; 1589 1590 /** 1591 * @since 3.6 1592 */ 1593 public static final Metric<Integer> CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed Issues", Metric.ValueType.INT) 1594 .setDescription("Confirmed issues") 1595 .setDirection(Metric.DIRECTION_WORST) 1596 .setQualitative(true) 1597 .setDomain(DOMAIN_ISSUES) 1598 .setBestValue(0.0) 1599 .setOptimizedBestValue(true) 1600 .create(); 1601 1602 /** 1603 * SonarQube Quality Model 1604 * @since 5.5 1605 */ 1606 public static final String CODE_SMELLS_KEY = "code_smells"; 1607 1608 /** 1609 * SonarQube Quality Model 1610 * @since 5.5 1611 */ 1612 public static final Metric<Integer> CODE_SMELLS = new Metric.Builder(CODE_SMELLS_KEY, "Code Smells", Metric.ValueType.INT) 1613 .setDescription("Code Smells") 1614 .setDirection(Metric.DIRECTION_WORST) 1615 .setQualitative(false) 1616 .setDomain(DOMAIN_MAINTAINABILITY) 1617 .setBestValue(0.0) 1618 .setOptimizedBestValue(true) 1619 .create(); 1620 1621 /** 1622 * SonarQube Quality Model 1623 * @since 5.5 1624 */ 1625 public static final String NEW_CODE_SMELLS_KEY = "new_code_smells"; 1626 1627 /** 1628 * SonarQube Quality Model 1629 * @since 5.5 1630 */ 1631 public static final Metric<Integer> NEW_CODE_SMELLS = new Metric.Builder(NEW_CODE_SMELLS_KEY, "New Code Smells", Metric.ValueType.INT) 1632 .setDescription("New Code Smells") 1633 .setDirection(Metric.DIRECTION_WORST) 1634 .setQualitative(true) 1635 .setDomain(DOMAIN_MAINTAINABILITY) 1636 .setBestValue(0.0) 1637 .setOptimizedBestValue(true) 1638 .setDeleteHistoricalData(true) 1639 .create(); 1640 1641 /** 1642 * SonarQube Quality Model 1643 * @since 5.5 1644 */ 1645 public static final String BUGS_KEY = "bugs"; 1646 1647 /** 1648 * SonarQube Quality Model 1649 * @since 5.5 1650 */ 1651 public static final Metric<Integer> BUGS = new Metric.Builder(BUGS_KEY, "Bugs", Metric.ValueType.INT) 1652 .setDescription("Bugs") 1653 .setDirection(Metric.DIRECTION_WORST) 1654 .setQualitative(false) 1655 .setDomain(DOMAIN_RELIABILITY) 1656 .setBestValue(0.0) 1657 .setOptimizedBestValue(true) 1658 .create(); 1659 1660 /** 1661 * SonarQube Quality Model 1662 * @since 5.5 1663 */ 1664 public static final String NEW_BUGS_KEY = "new_bugs"; 1665 1666 /** 1667 * SonarQube Quality Model 1668 * @since 5.5 1669 */ 1670 public static final Metric<Integer> NEW_BUGS = new Metric.Builder(NEW_BUGS_KEY, "New Bugs", Metric.ValueType.INT) 1671 .setDescription("New Bugs") 1672 .setDirection(Metric.DIRECTION_WORST) 1673 .setQualitative(true) 1674 .setDomain(DOMAIN_RELIABILITY) 1675 .setBestValue(0.0) 1676 .setOptimizedBestValue(true) 1677 .setDeleteHistoricalData(true) 1678 .create(); 1679 1680 /** 1681 * SonarQube Quality Model 1682 * @since 5.5 1683 */ 1684 public static final String VULNERABILITIES_KEY = "vulnerabilities"; 1685 1686 /** 1687 * SonarQube Quality Model 1688 * @since 5.5 1689 */ 1690 public static final Metric<Integer> VULNERABILITIES = new Metric.Builder(VULNERABILITIES_KEY, "Vulnerabilities", Metric.ValueType.INT) 1691 .setDescription("Vulnerabilities") 1692 .setDirection(Metric.DIRECTION_WORST) 1693 .setQualitative(false) 1694 .setDomain(DOMAIN_SECURITY) 1695 .setBestValue(0.0) 1696 .setOptimizedBestValue(true) 1697 .create(); 1698 1699 /** 1700 * SonarQube Quality Model 1701 * @since 5.5 1702 */ 1703 public static final String NEW_VULNERABILITIES_KEY = "new_vulnerabilities"; 1704 1705 /** 1706 * SonarQube Quality Model 1707 * @since 5.5 1708 */ 1709 public static final Metric<Integer> NEW_VULNERABILITIES = new Metric.Builder(NEW_VULNERABILITIES_KEY, "New Vulnerabilities", Metric.ValueType.INT) 1710 .setDescription("New Vulnerabilities") 1711 .setDirection(Metric.DIRECTION_WORST) 1712 .setQualitative(true) 1713 .setDomain(DOMAIN_SECURITY) 1714 .setBestValue(0.0) 1715 .setOptimizedBestValue(true) 1716 .setDeleteHistoricalData(true) 1717 .create(); 1718 1719 // -------------------------------------------------------------------------------------------------------------------- 1720 // 1721 // DESIGN 1722 // 1723 // -------------------------------------------------------------------------------------------------------------------- 1724 1725 /** 1726 * @deprecated since 5.0 this is an internal metric that should not be accessed by plugins 1727 */ 1728 @Deprecated 1729 public static final String DEPENDENCY_MATRIX_KEY = "dsm"; 1730 /** 1731 * @deprecated since 5.0 this is an internal metric that should not be accessed by plugins 1732 */ 1733 @Deprecated 1734 public static final transient Metric<String> DEPENDENCY_MATRIX = new Metric.Builder(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", Metric.ValueType.DATA) 1735 .setDescription("Dependency Matrix") 1736 .setDirection(Metric.DIRECTION_NONE) 1737 .setQualitative(false) 1738 .setDomain(DOMAIN_DESIGN) 1739 .setDeleteHistoricalData(true) 1740 .create(); 1741 1742 /** 1743 * @deprecated since 5.2 No more design features 1744 */ 1745 @Deprecated 1746 public static final String DIRECTORY_CYCLES_KEY = "package_cycles"; 1747 /** 1748 * @deprecated since 5.2 No more design features 1749 */ 1750 @Deprecated 1751 public static final transient Metric<Integer> DIRECTORY_CYCLES = new Metric.Builder(DIRECTORY_CYCLES_KEY, "Directory Cycles", Metric.ValueType.INT) 1752 .setDescription("Directory cycles") 1753 .setDirection(Metric.DIRECTION_WORST) 1754 .setQualitative(true) 1755 .setDomain(DOMAIN_DESIGN) 1756 .setBestValue(0.0) 1757 .create(); 1758 1759 /** 1760 * @deprecated since 5.0 use {@link #DIRECTORY_CYCLES_KEY} 1761 */ 1762 @Deprecated 1763 public static final String PACKAGE_CYCLES_KEY = DIRECTORY_CYCLES_KEY; 1764 /** 1765 * @deprecated since 5.0 use {@link #DIRECTORY_CYCLES} 1766 */ 1767 @Deprecated 1768 public static final transient Metric<Integer> PACKAGE_CYCLES = DIRECTORY_CYCLES; 1769 1770 /** 1771 * @deprecated since 5.2 No more design features 1772 */ 1773 @Deprecated 1774 public static final String DIRECTORY_TANGLE_INDEX_KEY = "package_tangle_index"; 1775 /** 1776 * @deprecated since 5.2 No more design features 1777 */ 1778 @Deprecated 1779 public static final transient Metric<Double> DIRECTORY_TANGLE_INDEX = new Metric.Builder(DIRECTORY_TANGLE_INDEX_KEY, "Directory Tangle Index", Metric.ValueType.PERCENT) 1780 .setDescription("Directory tangle index") 1781 .setDirection(Metric.DIRECTION_WORST) 1782 .setQualitative(true) 1783 .setBestValue(0.0) 1784 .setDomain(DOMAIN_DESIGN) 1785 .create(); 1786 1787 /** 1788 * @deprecated since 5.0 use {@link #DIRECTORY_TANGLE_INDEX_KEY} 1789 */ 1790 @Deprecated 1791 public static final String PACKAGE_TANGLE_INDEX_KEY = DIRECTORY_TANGLE_INDEX_KEY; 1792 /** 1793 * @deprecated since 5.0 use {@link #DIRECTORY_TANGLE_INDEX} 1794 */ 1795 @Deprecated 1796 public static final transient Metric<Double> PACKAGE_TANGLE_INDEX = DIRECTORY_TANGLE_INDEX; 1797 1798 /** 1799 * @deprecated since 5.2 No more design features 1800 */ 1801 @Deprecated 1802 public static final String DIRECTORY_TANGLES_KEY = "package_tangles"; 1803 /** 1804 * @deprecated since 5.2 No more design features 1805 */ 1806 @Deprecated 1807 public static final transient Metric<Integer> DIRECTORY_TANGLES = new Metric.Builder(DIRECTORY_TANGLES_KEY, "File Dependencies to Cut", Metric.ValueType.INT) 1808 .setDescription("File dependencies to cut") 1809 .setDirection(Metric.DIRECTION_WORST) 1810 .setQualitative(false) 1811 .setDomain(DOMAIN_DESIGN) 1812 .create(); 1813 1814 /** 1815 * @deprecated since 5.0 use {@link #DIRECTORY_TANGLES_KEY} 1816 */ 1817 @Deprecated 1818 public static final String PACKAGE_TANGLES_KEY = DIRECTORY_TANGLES_KEY; 1819 /** 1820 * @deprecated since 5.0 use {@link #DIRECTORY_TANGLES} 1821 */ 1822 @Deprecated 1823 public static final transient Metric<Integer> PACKAGE_TANGLES = DIRECTORY_TANGLES; 1824 1825 /** 1826 * @deprecated since 5.2 No more design features 1827 */ 1828 @Deprecated 1829 public static final String DIRECTORY_FEEDBACK_EDGES_KEY = "package_feedback_edges"; 1830 /** 1831 * @deprecated since 5.2 No more design features 1832 */ 1833 @Deprecated 1834 public static final transient Metric<Integer> DIRECTORY_FEEDBACK_EDGES = new Metric.Builder(DIRECTORY_FEEDBACK_EDGES_KEY, "Package Dependencies to Cut", Metric.ValueType.INT) 1835 .setDescription("Package dependencies to cut") 1836 .setDirection(Metric.DIRECTION_WORST) 1837 .setQualitative(false) 1838 .setDomain(DOMAIN_DESIGN) 1839 .setBestValue(0.0) 1840 .create(); 1841 1842 /** 1843 * @deprecated since 5.0 use {@link #DIRECTORY_FEEDBACK_EDGES_KEY} 1844 */ 1845 @Deprecated 1846 public static final String PACKAGE_FEEDBACK_EDGES_KEY = DIRECTORY_FEEDBACK_EDGES_KEY; 1847 /** 1848 * @deprecated since 5.0 use {@link #DIRECTORY_FEEDBACK_EDGES} 1849 */ 1850 @Deprecated 1851 public static final transient Metric<Integer> PACKAGE_FEEDBACK_EDGES = DIRECTORY_FEEDBACK_EDGES; 1852 1853 /** 1854 * @deprecated since 5.2 No more design features 1855 */ 1856 @Deprecated 1857 public static final String DIRECTORY_EDGES_WEIGHT_KEY = "package_edges_weight"; 1858 /** 1859 * @deprecated since 5.2 No more design features 1860 */ 1861 @Deprecated 1862 public static final transient Metric<Integer> DIRECTORY_EDGES_WEIGHT = new Metric.Builder(DIRECTORY_EDGES_WEIGHT_KEY, "Directory Edges Weight", Metric.ValueType.INT) 1863 .setDescription("Directory edges weight") 1864 .setDirection(Metric.DIRECTION_BETTER) 1865 .setQualitative(false) 1866 .setDomain(DOMAIN_DESIGN) 1867 .setHidden(true) 1868 .setDeleteHistoricalData(true) 1869 .create(); 1870 1871 /** 1872 * @deprecated since 5.0 use {@link #DIRECTORY_EDGES_WEIGHT_KEY} 1873 */ 1874 @Deprecated 1875 public static final String PACKAGE_EDGES_WEIGHT_KEY = DIRECTORY_EDGES_WEIGHT_KEY; 1876 /** 1877 * @deprecated since 5.0 use {@link #DIRECTORY_EDGES_WEIGHT} 1878 */ 1879 @Deprecated 1880 public static final transient Metric<Integer> PACKAGE_EDGES_WEIGHT = DIRECTORY_EDGES_WEIGHT; 1881 1882 /** 1883 * @deprecated since 5.2 No more design features 1884 */ 1885 @Deprecated 1886 public static final String FILE_CYCLES_KEY = "file_cycles"; 1887 /** 1888 * @deprecated since 5.2 No more design features 1889 */ 1890 @Deprecated 1891 public static final transient Metric<Integer> FILE_CYCLES = new Metric.Builder(FILE_CYCLES_KEY, "File Cycles", Metric.ValueType.INT) 1892 .setDescription("File cycles") 1893 .setDirection(Metric.DIRECTION_WORST) 1894 .setQualitative(true) 1895 .setDomain(DOMAIN_DESIGN) 1896 .setHidden(true) 1897 .setDeleteHistoricalData(true) 1898 .setBestValue(0.0) 1899 .create(); 1900 1901 /** 1902 * @deprecated since 5.2 No more design features 1903 */ 1904 @Deprecated 1905 public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index"; 1906 /** 1907 * @deprecated since 5.2 No more design features 1908 */ 1909 @Deprecated 1910 public static final transient Metric<Double> FILE_TANGLE_INDEX = new Metric.Builder(FILE_TANGLE_INDEX_KEY, "File Tangle Index", Metric.ValueType.PERCENT) 1911 .setDescription("File tangle index") 1912 .setDirection(Metric.DIRECTION_WORST) 1913 .setQualitative(true) 1914 .setDomain(DOMAIN_DESIGN) 1915 .setHidden(true) 1916 .setDeleteHistoricalData(true) 1917 .setBestValue(0.0) 1918 .create(); 1919 1920 /** 1921 * @deprecated since 5.2 No more design features 1922 */ 1923 @Deprecated 1924 public static final String FILE_TANGLES_KEY = "file_tangles"; 1925 /** 1926 * @deprecated since 5.2 No more design features 1927 */ 1928 @Deprecated 1929 public static final transient Metric<Integer> FILE_TANGLES = new Metric.Builder(FILE_TANGLES_KEY, "File Tangles", Metric.ValueType.INT) 1930 .setDescription("Files tangles") 1931 .setDirection(Metric.DIRECTION_WORST) 1932 .setQualitative(false) 1933 .setDomain(DOMAIN_DESIGN) 1934 .setHidden(true) 1935 .setDeleteHistoricalData(true) 1936 .create(); 1937 1938 /** 1939 * @deprecated since 5.2 No more design features 1940 */ 1941 @Deprecated 1942 public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges"; 1943 /** 1944 * @deprecated since 5.2 No more design features 1945 */ 1946 @Deprecated 1947 public static final transient Metric<Integer> FILE_FEEDBACK_EDGES = new Metric.Builder(FILE_FEEDBACK_EDGES_KEY, "Suspect File Dependencies", Metric.ValueType.INT) 1948 .setDescription("Suspect file dependencies") 1949 .setDirection(Metric.DIRECTION_WORST) 1950 .setQualitative(false) 1951 .setDomain(DOMAIN_DESIGN) 1952 .setHidden(true) 1953 .setDeleteHistoricalData(true) 1954 .setBestValue(0.0) 1955 .create(); 1956 1957 /** 1958 * @deprecated since 5.2 No more design features 1959 */ 1960 @Deprecated 1961 public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight"; 1962 /** 1963 * @deprecated since 5.2 No more design features 1964 */ 1965 @Deprecated 1966 public static final transient Metric<Integer> FILE_EDGES_WEIGHT = new Metric.Builder(FILE_EDGES_WEIGHT_KEY, "File Edges Weight", Metric.ValueType.INT) 1967 .setDescription("File edges weight") 1968 .setDirection(Metric.DIRECTION_BETTER) 1969 .setQualitative(false) 1970 .setDomain(DOMAIN_DESIGN) 1971 .setHidden(true) 1972 .setDeleteHistoricalData(true) 1973 .create(); 1974 1975 // -------------------------------------------------------------------------------------------------------------------- 1976 // 1977 // SCM 1978 // 1979 // -------------------------------------------------------------------------------------------------------------------- 1980 1981 /** 1982 * @since 2.7 1983 * @deprecated since 5.0 SCM data will no more be stored as measures 1984 */ 1985 @Deprecated 1986 public static final String SCM_AUTHORS_BY_LINE_KEY = "authors_by_line"; 1987 1988 /** 1989 * Key-value pairs, where key - is a number of line, and value - is an author for this line. 1990 * 1991 * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map) 1992 * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String) 1993 * @since 2.7 1994 * @deprecated since 5.0 SCM data will no more be stored as measures 1995 */ 1996 @Deprecated 1997 public static final transient Metric<String> SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by Line", Metric.ValueType.DATA) 1998 .setDomain(DOMAIN_SCM) 1999 .create(); 2000 2001 /** 2002 * @since 2.7 2003 * @deprecated since 5.0 SCM data will no more be stored as measures 2004 */ 2005 @Deprecated 2006 public static final String SCM_REVISIONS_BY_LINE_KEY = "revisions_by_line"; 2007 2008 /** 2009 * Key-value pairs, where key - is a number of line, and value - is a revision for this line. 2010 * 2011 * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map) 2012 * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String) 2013 * @since 2.7 2014 * @deprecated since 5.0 SCM data will no more be stored as measures 2015 */ 2016 @Deprecated 2017 public static final transient Metric<String> SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by Line", Metric.ValueType.DATA) 2018 .setDomain(DOMAIN_SCM) 2019 .create(); 2020 2021 /** 2022 * @since 2.7 2023 * @deprecated since 5.0 SCM data will no more be stored as measures 2024 */ 2025 @Deprecated 2026 public static final String SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY = "last_commit_datetimes_by_line"; 2027 2028 /** 2029 * Key-value pairs, where key - is a number of line, and value - is a date of last commit for this line. 2030 * 2031 * @see org.sonar.api.utils.KeyValueFormat#formatIntDateTime(java.util.Map) 2032 * @see org.sonar.api.utils.KeyValueFormat#parseIntDateTime(String) 2033 * @since 2.7 2034 * @deprecated since 5.0 SCM data will no more be stored as measures 2035 */ 2036 @Deprecated 2037 public static final transient Metric<String> SCM_LAST_COMMIT_DATETIMES_BY_LINE = new Metric.Builder(SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY, "Last Commit Dates by Line", 2038 Metric.ValueType.DATA) 2039 .setDomain(DOMAIN_SCM) 2040 .create(); 2041 2042 // -------------------------------------------------------------------------------------------------------------------- 2043 // 2044 // MAINTAINABILITY CHARACTERISTIC 2045 // 2046 // -------------------------------------------------------------------------------------------------------------------- 2047 2048 /** 2049 * @since 4.0 2050 */ 2051 // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "maintainability_remediation_effort" 2052 public static final String TECHNICAL_DEBT_KEY = "sqale_index"; 2053 2054 /** 2055 * @since 4.0 2056 */ 2057 // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT 2058 public static final Metric<Long> TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR) 2059 .setDescription("Total effort (in days) to fix all the issues on the component and therefore to comply to all the requirements.") 2060 .setDomain(DOMAIN_MAINTAINABILITY) 2061 .setDirection(Metric.DIRECTION_WORST) 2062 .setOptimizedBestValue(true) 2063 .setBestValue(0.0) 2064 .setQualitative(true) 2065 .create(); 2066 2067 /** 2068 * @since 4.1 2069 */ 2070 // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "new_maintainability_remediation_effort" 2071 public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt"; 2072 2073 /** 2074 * @since 4.1 2075 */ 2076 // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT 2077 public static final Metric<Long> NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Added Technical Debt", Metric.ValueType.WORK_DUR) 2078 .setDescription("Added technical debt") 2079 .setDomain(DOMAIN_MAINTAINABILITY) 2080 .setDirection(Metric.DIRECTION_WORST) 2081 .setOptimizedBestValue(true) 2082 .setBestValue(0.0) 2083 .setQualitative(true) 2084 .setDeleteHistoricalData(true) 2085 .create(); 2086 2087 /** 2088 * @since 4.5 2089 */ 2090 // TODO should be renamed to MAINTAINABILITY_RATING_KEY = "maintainability_rating" 2091 public static final String SQALE_RATING_KEY = "sqale_rating"; 2092 2093 /** 2094 * @since 4.5 2095 */ 2096 // TODO should be renamed to MAINTAINABILITY_RATING 2097 public static final Metric<Integer> SQALE_RATING = new Metric.Builder(SQALE_RATING_KEY, "Maintainability Rating", Metric.ValueType.RATING) 2098 .setDescription("A-to-E rating based on the technical debt ratio") 2099 .setDomain(DOMAIN_MAINTAINABILITY) 2100 .setDirection(Metric.DIRECTION_WORST) 2101 .setQualitative(true) 2102 .setBestValue(1.0) 2103 .setWorstValue(5.0) 2104 .create(); 2105 2106 /** 2107 * @since 4.5 2108 */ 2109 public static final String DEVELOPMENT_COST_KEY = "development_cost"; 2110 2111 /** 2112 * @since 4.5 2113 */ 2114 public static final Metric<String> DEVELOPMENT_COST = new Metric.Builder(DEVELOPMENT_COST_KEY, "SQALE Development Cost", Metric.ValueType.STRING) 2115 .setDescription("SQALE development cost") 2116 .setDomain(DOMAIN_MAINTAINABILITY) 2117 .setDirection(Metric.DIRECTION_WORST) 2118 .setOptimizedBestValue(true) 2119 .setBestValue(0.0) 2120 .setQualitative(true) 2121 .setHidden(true) 2122 .create(); 2123 2124 /** 2125 * @since 4.5 2126 */ 2127 // TODO should be renamed to TECHNICALDEBT_RATIO_KEY = "technicaldebt_ratio" 2128 public static final String SQALE_DEBT_RATIO_KEY = "sqale_debt_ratio"; 2129 2130 /** 2131 * @since 4.5 2132 */ 2133 // TODO should be renamed to TECHNICALDEBT_RATIO 2134 public static final Metric<Double> SQALE_DEBT_RATIO = new Metric.Builder(SQALE_DEBT_RATIO_KEY, "Technical Debt Ratio", Metric.ValueType.PERCENT) 2135 .setDescription("Ratio of the actual technical debt compared to the estimated cost to develop the whole source code from scratch") 2136 .setDomain(DOMAIN_MAINTAINABILITY) 2137 .setDirection(Metric.DIRECTION_WORST) 2138 .setOptimizedBestValue(true) 2139 .setBestValue(0.0) 2140 .setQualitative(true) 2141 .create(); 2142 2143 /** 2144 * @since 5.2 2145 */ 2146 // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE_KEY = "technicaldebt_ratio_on_new_code" 2147 public static final String NEW_SQALE_DEBT_RATIO_KEY = "new_sqale_debt_ratio"; 2148 2149 /** 2150 * @since 5.2 2151 */ 2152 // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE 2153 public static final Metric<Double> NEW_SQALE_DEBT_RATIO = new Metric.Builder(NEW_SQALE_DEBT_RATIO_KEY, "Technical Debt Ratio on New Code", Metric.ValueType.PERCENT) 2154 .setDescription("Technical Debt Ratio of new/changed code.") 2155 .setDomain(DOMAIN_MAINTAINABILITY) 2156 .setDirection(Metric.DIRECTION_WORST) 2157 .setOptimizedBestValue(true) 2158 .setBestValue(0.0) 2159 .setQualitative(true) 2160 .create(); 2161 2162 /** 2163 * @since 5.5 2164 */ 2165 public static final String EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY = "effort_to_reach_maintainability_rating_a"; 2166 2167 /** 2168 * @since 5.5 2169 */ 2170 public static final Metric<Long> EFFORT_TO_REACH_MAINTAINABILITY_RATING_A = new Metric.Builder(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY, 2171 "Effort to Reach Maintainability Rating A", Metric.ValueType.WORK_DUR) 2172 .setDescription("Effort to reach maintainability rating A") 2173 .setDomain(DOMAIN_MAINTAINABILITY) 2174 .setDirection(Metric.DIRECTION_WORST) 2175 .setQualitative(true) 2176 .setBestValue(0.0) 2177 .setOptimizedBestValue(true) 2178 .create(); 2179 2180 // -------------------------------------------------------------------------------------------------------------------- 2181 // 2182 // RELIABILITY CHARACTERISTIC 2183 // 2184 // -------------------------------------------------------------------------------------------------------------------- 2185 2186 /** 2187 * @since 5.5 2188 */ 2189 public static final String RELIABILITY_REMEDIATION_EFFORT_KEY = "reliability_remediation_effort"; 2190 2191 /** 2192 * @since 5.5 2193 */ 2194 public static final Metric<Long> RELIABILITY_REMEDIATION_EFFORT = new Metric.Builder(RELIABILITY_REMEDIATION_EFFORT_KEY, "Reliability Remediation Effort", 2195 Metric.ValueType.WORK_DUR) 2196 .setDescription("Reliability Remediation Effort") 2197 .setDomain(DOMAIN_RELIABILITY) 2198 .setDirection(Metric.DIRECTION_WORST) 2199 .setOptimizedBestValue(true) 2200 .setBestValue(0.0) 2201 .setQualitative(true) 2202 .create(); 2203 2204 /** 2205 * @since 5.5 2206 */ 2207 public static final String NEW_RELIABILITY_REMEDIATION_EFFORT_KEY = "new_reliability_remediation_effort"; 2208 2209 /** 2210 * @since 5.5 2211 */ 2212 public static final Metric<Long> NEW_RELIABILITY_REMEDIATION_EFFORT = new Metric.Builder(NEW_RELIABILITY_REMEDIATION_EFFORT_KEY, "Reliability Remediation Effort on New Code", 2213 Metric.ValueType.WORK_DUR) 2214 .setDescription("Reliability remediation effort on new code") 2215 .setDomain(DOMAIN_RELIABILITY) 2216 .setDirection(Metric.DIRECTION_WORST) 2217 .setOptimizedBestValue(true) 2218 .setBestValue(0.0) 2219 .setQualitative(true) 2220 .setDeleteHistoricalData(true) 2221 .create(); 2222 2223 /** 2224 * @since 5.5 2225 */ 2226 public static final String RELIABILITY_RATING_KEY = "reliability_rating"; 2227 2228 /** 2229 * @since 5.5 2230 */ 2231 public static final Metric<Integer> RELIABILITY_RATING = new Metric.Builder(RELIABILITY_RATING_KEY, "Reliability Rating", Metric.ValueType.RATING) 2232 .setDescription("Reliability rating") 2233 .setDomain(DOMAIN_RELIABILITY) 2234 .setDirection(Metric.DIRECTION_WORST) 2235 .setQualitative(true) 2236 .setBestValue(1.0) 2237 .setWorstValue(5.0) 2238 .create(); 2239 2240 // -------------------------------------------------------------------------------------------------------------------- 2241 // 2242 // SECURITY CHARACTERISTIC 2243 // 2244 // -------------------------------------------------------------------------------------------------------------------- 2245 2246 /** 2247 * @since 5.5 2248 */ 2249 public static final String SECURITY_REMEDIATION_EFFORT_KEY = "security_remediation_effort"; 2250 2251 /** 2252 * @since 5.5 2253 */ 2254 public static final Metric<Long> SECURITY_REMEDIATION_EFFORT = new Metric.Builder(SECURITY_REMEDIATION_EFFORT_KEY, "Security Remediation Effort", Metric.ValueType.WORK_DUR) 2255 .setDescription("Security remediation effort") 2256 .setDomain(DOMAIN_SECURITY) 2257 .setDirection(Metric.DIRECTION_WORST) 2258 .setOptimizedBestValue(true) 2259 .setBestValue(0.0) 2260 .setQualitative(true) 2261 .create(); 2262 2263 /** 2264 * @since 5.5 2265 */ 2266 public static final String NEW_SECURITY_REMEDIATION_EFFORT_KEY = "new_security_remediation_effort"; 2267 2268 /** 2269 * @since 5.5 2270 */ 2271 public static final Metric<Long> NEW_SECURITY_REMEDIATION_EFFORT = new Metric.Builder(NEW_SECURITY_REMEDIATION_EFFORT_KEY, "Security Remediation Effort on New Code", 2272 Metric.ValueType.WORK_DUR) 2273 .setDescription("Security remediation effort on new code") 2274 .setDomain(DOMAIN_SECURITY) 2275 .setDirection(Metric.DIRECTION_WORST) 2276 .setOptimizedBestValue(true) 2277 .setBestValue(0.0) 2278 .setQualitative(true) 2279 .setDeleteHistoricalData(true) 2280 .create(); 2281 2282 /** 2283 * @since 5.5 2284 */ 2285 public static final String SECURITY_RATING_KEY = "security_rating"; 2286 2287 /** 2288 * @since 5.5 2289 */ 2290 public static final Metric<Integer> SECURITY_RATING = new Metric.Builder(SECURITY_RATING_KEY, "Security Rating", Metric.ValueType.RATING) 2291 .setDescription("Security rating") 2292 .setDomain(DOMAIN_SECURITY) 2293 .setDirection(Metric.DIRECTION_WORST) 2294 .setQualitative(true) 2295 .setBestValue(1.0) 2296 .setWorstValue(5.0) 2297 .create(); 2298 2299 // -------------------------------------------------------------------------------------------------------------------- 2300 // 2301 // FILE DATA 2302 // 2303 // -------------------------------------------------------------------------------------------------------------------- 2304 2305 /** 2306 * @since 2.14 2307 */ 2308 public static final String NCLOC_DATA_KEY = "ncloc_data"; 2309 2310 /** 2311 * Information about lines of code in file. 2312 * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains code (1) or not (0). 2313 * If a line number is missing in the map it is equivalent to the default value (0). 2314 * 2315 * @see org.sonar.api.measures.FileLinesContext 2316 * @since 2.14 2317 */ 2318 public static final Metric<String> NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA) 2319 .setHidden(true) 2320 .setDomain(DOMAIN_SIZE) 2321 .create(); 2322 2323 /** 2324 * @since 2.14 2325 */ 2326 public static final String COMMENT_LINES_DATA_KEY = "comment_lines_data"; 2327 2328 /** 2329 * Information about comments in file. 2330 * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains comment (1) or not (0). 2331 * If a line number is missing in the map it is equivalent to the default value (0). 2332 * 2333 * @see org.sonar.api.measures.FileLinesContext 2334 * @since 2.14 2335 */ 2336 public static final Metric<String> COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA) 2337 .setHidden(true) 2338 .setDomain(DOMAIN_DOCUMENTATION) 2339 .create(); 2340 2341 /** 2342 * @since 5.5 2343 */ 2344 public static final String EXECUTABLE_LINES_DATA_KEY = "executable_lines_data"; 2345 2346 /** 2347 * Information about executable lines of code in file. 2348 * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains executable code (1) or not (0). 2349 * If a line number is missing in the map it is equivalent to the default value (0). 2350 * 2351 * @see org.sonar.api.measures.FileLinesContext 2352 * @since 5.5 2353 */ 2354 public static final Metric<String> EXECUTABLE_LINES_DATA = new Metric.Builder(EXECUTABLE_LINES_DATA_KEY, "executable_lines_data", Metric.ValueType.DATA) 2355 .setHidden(true) 2356 .setDomain(DOMAIN_COVERAGE) 2357 .create(); 2358 2359 // -------------------------------------------------------------------------------------------------------------------- 2360 // 2361 // OTHERS 2362 // 2363 // -------------------------------------------------------------------------------------------------------------------- 2364 2365 public static final String ALERT_STATUS_KEY = "alert_status"; 2366 public static final Metric<Metric.Level> ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Quality Gate Status", Metric.ValueType.LEVEL) 2367 .setDescription("The project status with regard to its quality gate.") 2368 .setDirection(Metric.DIRECTION_BETTER) 2369 .setQualitative(true) 2370 .setDomain(DOMAIN_RELEASABILITY) 2371 .create(); 2372 2373 /** 2374 * @since 4.4 2375 */ 2376 public static final String QUALITY_GATE_DETAILS_KEY = "quality_gate_details"; 2377 /** 2378 * The project detailed status with regard to its quality gate. 2379 * Storing the global quality gate status, along with all evaluated conditions, into a JSON object. 2380 * @since 4.4 2381 */ 2382 public static final Metric<String> QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA) 2383 .setDescription("The project detailed status with regard to its quality gate") 2384 .setDomain(DOMAIN_GENERAL) 2385 .create(); 2386 2387 /** 2388 * @since 4.4 2389 * @deprecated since 5.5 2390 */ 2391 @Deprecated 2392 public static final String QUALITY_PROFILES_KEY = "quality_profiles"; 2393 2394 /** 2395 * @since 4.4 2396 * @deprecated since 5.5 2397 */ 2398 @Deprecated 2399 public static final Metric<String> QUALITY_PROFILES = new Metric.Builder(QUALITY_PROFILES_KEY, "Profiles", Metric.ValueType.DATA) 2400 .setDescription("Details of quality profiles used during analysis") 2401 .setQualitative(false) 2402 .setDomain(DOMAIN_GENERAL) 2403 .setHidden(true) 2404 .create(); 2405 2406 /** 2407 * @since 5.2 2408 */ 2409 public static final String LAST_COMMIT_DATE_KEY = "last_commit_date"; 2410 2411 /** 2412 * Date of the most recent commit. Current implementation is based on commits touching lines of source code. It 2413 * ignores other changes like file renaming or file deletion. 2414 * @since 5.2 2415 */ 2416 public static final Metric LAST_COMMIT_DATE = new Metric.Builder(LAST_COMMIT_DATE_KEY, "Date of Last Commit", Metric.ValueType.MILLISEC) 2417 .setDomain(CoreMetrics.DOMAIN_SCM) 2418 // waiting for type "datetime" to be correctly handled 2419 .setHidden(true) 2420 .create(); 2421 2422 private static final List<Metric> METRICS; 2423 2424 static { 2425 METRICS = new LinkedList<>(); 2426 for (Field field : CoreMetrics.class.getFields()) { 2427 if (!Modifier.isTransient(field.getModifiers()) && Metric.class.isAssignableFrom(field.getType())) { 2428 try { 2429 Metric metric = (Metric) field.get(null); 2430 METRICS.add(metric); 2431 } catch (IllegalAccessException e) { 2432 throw new SonarException("can not introspect " + CoreMetrics.class + " to get metrics", e); 2433 } 2434 } 2435 } 2436 } 2437 2438 private CoreMetrics() { 2439 // only static stuff 2440 } 2441 2442 public static List<Metric> getMetrics() { 2443 return METRICS; 2444 } 2445 2446 public static Metric getMetric(final String key) { 2447 return Iterables.find(METRICS, new Predicate<Metric>() { 2448 @Override 2449 public boolean apply(@Nullable Metric input) { 2450 return input != null && input.getKey().equals(key); 2451 } 2452 }); 2453 } 2454}