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