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