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