001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2011 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar 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 * Sonar 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 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020 package org.sonar.api.measures; 021 022 import com.google.common.collect.Lists; 023 import org.apache.commons.lang.StringUtils; 024 import org.sonar.api.resources.Scopes; 025 import org.sonar.api.utils.SonarException; 026 027 import java.lang.reflect.Field; 028 import java.util.List; 029 030 /** 031 * @since 1.10 032 */ 033 public final class CoreMetrics { 034 035 private CoreMetrics() { 036 // only static stuff 037 } 038 039 public static final String DOMAIN_SIZE = "Size"; 040 public static final String DOMAIN_TESTS = "Tests"; 041 public static final String DOMAIN_COMPLEXITY = "Complexity"; 042 public static final String DOMAIN_DOCUMENTATION = "Documentation"; 043 public static final String DOMAIN_RULES = "Rules"; 044 public static final String DOMAIN_SCM = "SCM"; 045 046 /** 047 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 048 */ 049 @Deprecated 050 public static final String DOMAIN_RULE_CATEGORIES = "Rule categories"; 051 052 public static final String DOMAIN_GENERAL = "General"; 053 public static final String DOMAIN_DUPLICATION = "Duplication"; 054 public static final String DOMAIN_DESIGN = "Design"; 055 056 public static final String LINES_KEY = "lines"; 057 public static final Metric LINES = new Metric(LINES_KEY, "Lines", "Lines", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, 058 DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 059 060 public static final String GENERATED_LINES_KEY = "generated_lines"; 061 public static final Metric GENERATED_LINES = new Metric(GENERATED_LINES_KEY, "Generated Lines", "Number of generated lines", 062 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_SIZE).setBestValue(0.0).setOptimizedBestValue(true).setFormula( 063 new SumChildValuesFormula(false)); 064 065 public static final String NCLOC_KEY = "ncloc"; 066 public static final Metric NCLOC = new Metric(NCLOC_KEY, "Lines of code", "Non Commenting Lines of Code", Metric.ValueType.INT, 067 Metric.DIRECTION_WORST, false, DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 068 069 public static final String GENERATED_NCLOC_KEY = "generated_ncloc"; 070 public static final Metric GENERATED_NCLOC = new Metric(GENERATED_NCLOC_KEY, "Generated lines of code", 071 "Generated non Commenting Lines of Code", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_SIZE).setBestValue(0.0) 072 .setOptimizedBestValue(true).setFormula(new SumChildValuesFormula(false)); 073 074 public static final String CLASSES_KEY = "classes"; 075 public static final Metric CLASSES = new Metric(CLASSES_KEY, "Classes", "Classes", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, 076 DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 077 078 public static final String FILES_KEY = "files"; 079 public static final Metric FILES = new Metric(FILES_KEY, "Files", "Number of files", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, 080 DOMAIN_SIZE); 081 082 public static final String DIRECTORIES_KEY = "directories"; 083 public static final Metric DIRECTORIES = new Metric(DIRECTORIES_KEY, "Directories", "Directories", Metric.ValueType.INT, 084 Metric.DIRECTION_WORST, false, DOMAIN_SIZE); 085 086 public static final String PACKAGES_KEY = "packages"; 087 public static final Metric PACKAGES = new Metric(PACKAGES_KEY, "Packages", "Packages", Metric.ValueType.INT, Metric.DIRECTION_WORST, 088 false, DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 089 090 public static final String FUNCTIONS_KEY = "functions"; 091 public static final Metric FUNCTIONS = new Metric(FUNCTIONS_KEY, "Methods", "Methods", Metric.ValueType.INT, Metric.DIRECTION_WORST, 092 false, DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 093 094 public static final String ACCESSORS_KEY = "accessors"; 095 public static final Metric ACCESSORS = new Metric(ACCESSORS_KEY, "Accessors", "Accessors", Metric.ValueType.INT, Metric.DIRECTION_WORST, 096 false, DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 097 098 public static final String PARAGRAPHS_KEY = "paragraphs"; 099 public static final Metric PARAGRAPHS = new Metric(PARAGRAPHS_KEY, "Paragraphs", "Number of paragraphs", Metric.ValueType.INT, 100 Metric.DIRECTION_WORST, false, DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 101 102 public static final String STATEMENTS_KEY = "statements"; 103 public static final Metric STATEMENTS = new Metric(STATEMENTS_KEY, "Statements", "Number of statements", Metric.ValueType.INT, 104 Metric.DIRECTION_WORST, false, DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 105 106 public static final String PUBLIC_API_KEY = "public_api"; 107 public static final Metric PUBLIC_API = new Metric(PUBLIC_API_KEY, "Public API", "Public API", Metric.ValueType.INT, 108 Metric.DIRECTION_WORST, false, DOMAIN_SIZE).setFormula(new SumChildValuesFormula(false)); 109 110 111 //-------------------------------------------------------------------------------------------------------------------- 112 // 113 // DOCUMENTATION 114 // 115 //-------------------------------------------------------------------------------------------------------------------- 116 117 public static final String COMMENT_LINES_KEY = "comment_lines"; 118 public static final Metric COMMENT_LINES = new Metric(COMMENT_LINES_KEY, "Comment lines", "Number of comment lines", 119 Metric.ValueType.INT, Metric.DIRECTION_BETTER, false, DOMAIN_DOCUMENTATION).setFormula(new SumChildValuesFormula(false)); 120 121 public static final String COMMENT_LINES_DENSITY_KEY = "comment_lines_density"; 122 public static final Metric COMMENT_LINES_DENSITY = new Metric(COMMENT_LINES_DENSITY_KEY, "Comments (%)", 123 "Comments balanced by ncloc + comment lines", Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_DOCUMENTATION); 124 125 public static final String COMMENT_BLANK_LINES_KEY = "comment_blank_lines"; 126 public static final Metric COMMENT_BLANK_LINES = new Metric(COMMENT_BLANK_LINES_KEY, "Blank comments", 127 "Comments that do not contain comments", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, CoreMetrics.DOMAIN_DOCUMENTATION) 128 .setFormula(new SumChildValuesFormula(false)).setBestValue(0.0).setOptimizedBestValue(true); 129 130 public static final String PUBLIC_DOCUMENTED_API_DENSITY_KEY = "public_documented_api_density"; 131 public static final Metric PUBLIC_DOCUMENTED_API_DENSITY = new Metric(PUBLIC_DOCUMENTED_API_DENSITY_KEY, "Public documented API (%)", 132 "Public documented classes and methods balanced by ncloc", Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, 133 DOMAIN_DOCUMENTATION).setWorstValue(0.0).setBestValue(100.0).setOptimizedBestValue(true); 134 135 public static final String PUBLIC_UNDOCUMENTED_API_KEY = "public_undocumented_api"; 136 public static final Metric PUBLIC_UNDOCUMENTED_API = new Metric(PUBLIC_UNDOCUMENTED_API_KEY, "Public undocumented API", 137 "Public undocumented classes, methods and variables", Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_DOCUMENTATION) 138 .setBestValue(0.0).setDirection(Metric.DIRECTION_WORST).setOptimizedBestValue(true).setFormula( 139 new SumChildValuesFormula(false)); 140 141 public static final String COMMENTED_OUT_CODE_LINES_KEY = "commented_out_code_lines"; 142 public static final Metric COMMENTED_OUT_CODE_LINES = new Metric(COMMENTED_OUT_CODE_LINES_KEY, "Commented LOCs", 143 "Commented lines of code", Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_DOCUMENTATION).setFormula( 144 new SumChildValuesFormula(false)).setBestValue(0.0).setOptimizedBestValue(true); 145 146 147 //-------------------------------------------------------------------------------------------------------------------- 148 // 149 // COMPLEXITY 150 // 151 //-------------------------------------------------------------------------------------------------------------------- 152 153 public static final String COMPLEXITY_KEY = "complexity"; 154 public static final Metric COMPLEXITY = new Metric(COMPLEXITY_KEY, "Complexity", "Cyclomatic complexity", Metric.ValueType.INT, 155 Metric.DIRECTION_WORST, false, DOMAIN_COMPLEXITY).setFormula(new SumChildValuesFormula(false)); 156 157 public static final String CLASS_COMPLEXITY_KEY = "class_complexity"; 158 public static final Metric CLASS_COMPLEXITY = new Metric(CLASS_COMPLEXITY_KEY, "Complexity /class", "Complexity average by class", 159 Metric.ValueType.FLOAT, Metric.DIRECTION_WORST, true, DOMAIN_COMPLEXITY) 160 .setFormula(new AverageComplexityFormula(CoreMetrics.CLASSES)); 161 162 public static final String FUNCTION_COMPLEXITY_KEY = "function_complexity"; 163 public static final Metric FUNCTION_COMPLEXITY = new Metric(FUNCTION_COMPLEXITY_KEY, "Complexity /method", 164 "Complexity average by method", Metric.ValueType.FLOAT, Metric.DIRECTION_WORST, true, DOMAIN_COMPLEXITY) 165 .setFormula(new AverageComplexityFormula(CoreMetrics.FUNCTIONS)); 166 167 public static final String FILE_COMPLEXITY_KEY = "file_complexity"; 168 public static final Metric FILE_COMPLEXITY = new Metric(FILE_COMPLEXITY_KEY, "Complexity /file", "Complexity average by file", 169 Metric.ValueType.FLOAT, Metric.DIRECTION_WORST, true, DOMAIN_COMPLEXITY).setFormula(new AverageComplexityFormula(CoreMetrics.FILES)); 170 171 public static final String PARAGRAPH_COMPLEXITY_KEY = "paragraph_complexity"; 172 public static final Metric PARAGRAPH_COMPLEXITY = new Metric(PARAGRAPH_COMPLEXITY_KEY, "Complexity /paragraph", 173 "Complexity average by paragraph", Metric.ValueType.FLOAT, Metric.DIRECTION_WORST, true, DOMAIN_COMPLEXITY) 174 .setFormula(new AverageComplexityFormula(CoreMetrics.PARAGRAPHS)); 175 176 public static final String CLASS_COMPLEXITY_DISTRIBUTION_KEY = "class_complexity_distribution"; 177 public static final Metric CLASS_COMPLEXITY_DISTRIBUTION = new Metric(CLASS_COMPLEXITY_DISTRIBUTION_KEY, 178 "Classes distribution /complexity", "Classes distribution /complexity", Metric.ValueType.DISTRIB, Metric.DIRECTION_NONE, true, 179 DOMAIN_COMPLEXITY).setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY)); 180 181 public static final String FUNCTION_COMPLEXITY_DISTRIBUTION_KEY = "function_complexity_distribution"; 182 public static final Metric FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, 183 "Functions distribution /complexity", "Functions distribution /complexity", Metric.ValueType.DISTRIB, Metric.DIRECTION_NONE, true, 184 DOMAIN_COMPLEXITY).setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY)); 185 186 public static final String FILE_COMPLEXITY_DISTRIBUTION_KEY = "file_complexity_distribution"; 187 public static final Metric FILE_COMPLEXITY_DISTRIBUTION = new Metric(FILE_COMPLEXITY_DISTRIBUTION_KEY, "Files distribution /complexity", 188 "Files distribution /complexity", Metric.ValueType.DISTRIB, Metric.DIRECTION_NONE, true, DOMAIN_COMPLEXITY) 189 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY)); 190 191 public static final String PARAGRAPH_COMPLEXITY_DISTRIBUTION_KEY = "paragraph_complexity_distribution"; 192 public static final Metric PARAGRAPH_COMPLEXITY_DISTRIBUTION = new Metric(PARAGRAPH_COMPLEXITY_DISTRIBUTION_KEY, 193 "Paragraph distribution /complexity", "Paragraph distribution /complexity", Metric.ValueType.DISTRIB, Metric.DIRECTION_NONE, true, 194 DOMAIN_COMPLEXITY).setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY)); 195 196 197 //-------------------------------------------------------------------------------------------------------------------- 198 // 199 // UNIT TESTS 200 // 201 //-------------------------------------------------------------------------------------------------------------------- 202 203 public static final String TESTS_KEY = "tests"; 204 public static final Metric TESTS = new Metric(TESTS_KEY, "Unit tests", "Number of unit tests", Metric.ValueType.INT, 205 Metric.DIRECTION_WORST, false, DOMAIN_TESTS); 206 207 public static final String TEST_EXECUTION_TIME_KEY = "test_execution_time"; 208 public static final Metric TEST_EXECUTION_TIME = new Metric(TEST_EXECUTION_TIME_KEY, "Unit tests duration", 209 "Execution duration of unit tests ", Metric.ValueType.MILLISEC, Metric.DIRECTION_WORST, false, DOMAIN_TESTS); 210 211 public static final String TEST_ERRORS_KEY = "test_errors"; 212 public static final Metric TEST_ERRORS = new Metric(TEST_ERRORS_KEY, "Unit test errors", "Number of unit test errors", 213 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_TESTS).setBestValue(0.0).setOptimizedBestValue(true); 214 public static final String SKIPPED_TESTS_KEY = "skipped_tests"; 215 public static final Metric SKIPPED_TESTS = new Metric(SKIPPED_TESTS_KEY, "Skipped unit tests", "Number of skipped unit tests", 216 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_TESTS).setBestValue(0.0).setOptimizedBestValue(true); 217 public static final String TEST_FAILURES_KEY = "test_failures"; 218 public static final Metric TEST_FAILURES = new Metric(TEST_FAILURES_KEY, "Unit test failures", "Number of unit test failures", 219 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_TESTS).setBestValue(0.0).setOptimizedBestValue(true); 220 221 public static final String TEST_SUCCESS_DENSITY_KEY = "test_success_density"; 222 public static final Metric TEST_SUCCESS_DENSITY = new Metric.Builder(TEST_SUCCESS_DENSITY_KEY, "Unit test success (%)", Metric.ValueType.PERCENT) 223 .setDescription("Density of successful unit tests") 224 .setDirection(Metric.DIRECTION_BETTER) 225 .setQualitative(true) 226 .setDomain(DOMAIN_TESTS) 227 .setWorstValue(0.0) 228 .setBestValue(100.0) 229 .setOptimizedBestValue(true) 230 .create(); 231 232 public static final String TEST_DATA_KEY = "test_data"; 233 public static final Metric TEST_DATA = new Metric.Builder(TEST_DATA_KEY, "Unit tests details", Metric.ValueType.DATA) 234 .setDescription("Unit tests details") 235 .setDirection(Metric.DIRECTION_WORST) 236 .setDomain(DOMAIN_TESTS) 237 .create(); 238 239 public static final String COVERAGE_KEY = "coverage"; 240 public static final Metric COVERAGE = new Metric.Builder(COVERAGE_KEY, "Coverage", Metric.ValueType.PERCENT) 241 .setDescription("Coverage by unit tests") 242 .setDirection(Metric.DIRECTION_BETTER) 243 .setQualitative(true) 244 .setDomain(DOMAIN_TESTS) 245 .setWorstValue(0.0) 246 .setBestValue(100.0) 247 .create(); 248 249 public static final String NEW_COVERAGE_KEY = "new_coverage"; 250 public static final Metric NEW_COVERAGE = new Metric.Builder(NEW_COVERAGE_KEY, "New coverage", Metric.ValueType.PERCENT) 251 .setDescription("Coverage of new/changed code") 252 .setDirection(Metric.DIRECTION_BETTER) 253 .setQualitative(true) 254 .setDomain(DOMAIN_TESTS) 255 .setWorstValue(0.0) 256 .setBestValue(100.0) 257 .create(); 258 259 public static final String LINES_TO_COVER_KEY = "lines_to_cover"; 260 public static final Metric LINES_TO_COVER = new Metric.Builder(LINES_TO_COVER_KEY, "Lines to cover", Metric.ValueType.INT) 261 .setDescription("Lines to cover") 262 .setDirection(Metric.DIRECTION_BETTER) 263 .setQualitative(false) 264 .setDomain(DOMAIN_TESTS) 265 .setFormula(new SumChildValuesFormula(false)) 266 .setHidden(true) 267 .create(); 268 269 public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover"; 270 public static final Metric NEW_LINES_TO_COVER = new Metric.Builder(NEW_LINES_TO_COVER_KEY, "New lines to cover", Metric.ValueType.INT) 271 .setDescription("New lines to cover") 272 .setDirection(Metric.DIRECTION_WORST) 273 .setQualitative(false) 274 .setDomain(DOMAIN_TESTS) 275 .setFormula(new SumChildValuesFormula(false)) 276 .create(); 277 278 public static final String UNCOVERED_LINES_KEY = "uncovered_lines"; 279 public static final Metric UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, "Uncovered lines", Metric.ValueType.INT) 280 .setDescription("Uncovered lines") 281 .setDirection(Metric.DIRECTION_WORST) 282 .setDomain(DOMAIN_TESTS) 283 .setFormula(new SumChildValuesFormula(false)) 284 .create(); 285 286 public static final String NEW_UNCOVERED_LINES_KEY = "new_uncovered_lines"; 287 public static final Metric NEW_UNCOVERED_LINES = new Metric.Builder(NEW_UNCOVERED_LINES_KEY, "New uncovered lines", Metric.ValueType.INT) 288 .setDescription("New uncovered lines") 289 .setDirection(Metric.DIRECTION_WORST) 290 .setDomain(DOMAIN_TESTS) 291 .setFormula(new SumChildValuesFormula(false)) 292 .create(); 293 294 public static final String LINE_COVERAGE_KEY = "line_coverage"; 295 public static final Metric LINE_COVERAGE = new Metric.Builder(LINE_COVERAGE_KEY, "Line coverage", Metric.ValueType.PERCENT) 296 .setDescription("Line coverage") 297 .setDirection(Metric.DIRECTION_BETTER) 298 .setQualitative(true) 299 .setDomain(DOMAIN_TESTS) 300 .create(); 301 302 public static final String NEW_LINE_COVERAGE_KEY = "new_line_coverage"; 303 public static final Metric NEW_LINE_COVERAGE = new Metric.Builder(NEW_LINE_COVERAGE_KEY, "New line coverage", Metric.ValueType.PERCENT) 304 .setDescription("Line coverage of added/changed code") 305 .setDirection(Metric.DIRECTION_BETTER) 306 .setQualitative(true) 307 .setWorstValue(0.0) 308 .setBestValue(100.0) 309 .setDomain(DOMAIN_TESTS) 310 .create(); 311 312 public static final String COVERAGE_LINE_HITS_DATA_KEY = "coverage_line_hits_data"; 313 public static final Metric COVERAGE_LINE_HITS_DATA = new Metric.Builder(COVERAGE_LINE_HITS_DATA_KEY, "Coverage hits by line", Metric.ValueType.DATA) 314 .setDomain(DOMAIN_TESTS) 315 .create(); 316 317 public static final String CONDITIONS_TO_COVER_KEY = "conditions_to_cover"; 318 public static final Metric CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, "Conditions to cover", Metric.ValueType.INT) 319 .setDescription("Conditions to cover") 320 .setDomain(DOMAIN_TESTS) 321 .setFormula(new SumChildValuesFormula(false)) 322 .setHidden(true) 323 .create(); 324 325 public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover"; 326 public static final Metric NEW_CONDITIONS_TO_COVER = new Metric.Builder(NEW_CONDITIONS_TO_COVER_KEY, "New conditions to cover", Metric.ValueType.INT) 327 .setDescription("New conditions to cover") 328 .setDomain(DOMAIN_TESTS) 329 .setFormula(new SumChildValuesFormula(false)) 330 .create(); 331 332 public static final String UNCOVERED_CONDITIONS_KEY = "uncovered_conditions"; 333 public static final Metric UNCOVERED_CONDITIONS = new Metric.Builder(UNCOVERED_CONDITIONS_KEY, "Uncovered conditions", Metric.ValueType.INT) 334 .setDescription("Uncovered conditions") 335 .setDirection(Metric.DIRECTION_WORST) 336 .setDomain(DOMAIN_TESTS) 337 .setFormula(new SumChildValuesFormula(false)) 338 .create(); 339 340 public static final String NEW_UNCOVERED_CONDITIONS_KEY = "new_uncovered_conditions"; 341 public static final Metric NEW_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_UNCOVERED_CONDITIONS_KEY, "New uncovered conditions", Metric.ValueType.INT) 342 .setDescription("New uncovered conditions") 343 .setDirection(Metric.DIRECTION_WORST) 344 .setDomain(DOMAIN_TESTS) 345 .setFormula(new SumChildValuesFormula(false)) 346 .create(); 347 348 public static final String BRANCH_COVERAGE_KEY = "branch_coverage"; 349 public static final Metric BRANCH_COVERAGE = new Metric.Builder(BRANCH_COVERAGE_KEY, "Branch coverage", Metric.ValueType.PERCENT) 350 .setDescription("Branch coverage") 351 .setDirection(Metric.DIRECTION_BETTER) 352 .setQualitative(true) 353 .setDomain(DOMAIN_TESTS) 354 .setWorstValue(0.0) 355 .setBestValue(100.0) 356 .create(); 357 358 public static final String NEW_BRANCH_COVERAGE_KEY = "new_branch_coverage"; 359 public static final Metric NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, "New branch coverage", Metric.ValueType.PERCENT) 360 .setDescription("Branch coverage of new/changed code") 361 .setDirection(Metric.DIRECTION_BETTER) 362 .setQualitative(true) 363 .setDomain(DOMAIN_TESTS) 364 .setWorstValue(0.0) 365 .setBestValue(100.0) 366 .create(); 367 368 /** 369 * @deprecated since 2.7. Replaced by COVERED_CONDITIONS_BY_LINE_KEY and COVERED_CONDITIONS_BY_LINE_KEY 370 */ 371 @Deprecated 372 public static final String BRANCH_COVERAGE_HITS_DATA_KEY = "branch_coverage_hits_data"; 373 374 /** 375 * @deprecated since 2.7 replaced by metrics CONDITIONS_BY_LINE and COVERED_CONDITIONS_BY_LINE 376 */ 377 @Deprecated 378 public static final Metric BRANCH_COVERAGE_HITS_DATA = new Metric.Builder(BRANCH_COVERAGE_HITS_DATA_KEY, "Branch coverage hits", Metric.ValueType.DATA) 379 .setDomain(DOMAIN_TESTS) 380 .create(); 381 382 public static final String CONDITIONS_BY_LINE_KEY = "conditions_by_line"; 383 384 /** 385 * @since 2.7 386 */ 387 public static final Metric CONDITIONS_BY_LINE = new Metric.Builder(CONDITIONS_BY_LINE_KEY, "Conditions by line", Metric.ValueType.DATA) 388 .setDomain(DOMAIN_TESTS) 389 .create(); 390 391 public static final String COVERED_CONDITIONS_BY_LINE_KEY = "covered_conditions_by_line"; 392 393 /** 394 * @since 2.7 395 */ 396 public static final Metric COVERED_CONDITIONS_BY_LINE = new Metric.Builder(COVERED_CONDITIONS_BY_LINE_KEY, "Covered conditions by line", Metric.ValueType.DATA) 397 .setDomain(DOMAIN_TESTS) 398 .create(); 399 400 401 //-------------------------------------------------------------------------------------------------------------------- 402 // 403 // DUPLICATIONS 404 // 405 //-------------------------------------------------------------------------------------------------------------------- 406 407 public static final String DUPLICATED_LINES_KEY = "duplicated_lines"; 408 public static final Metric DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated lines", Metric.ValueType.INT) 409 .setDescription("Duplicated lines") 410 .setDirection(Metric.DIRECTION_WORST) 411 .setDomain(DOMAIN_DUPLICATION) 412 .setBestValue(0.0) 413 .setOptimizedBestValue(true) 414 .create(); 415 416 public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks"; 417 public static final Metric DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated blocks", Metric.ValueType.INT) 418 .setDescription("Duplicated blocks") 419 .setDirection(Metric.DIRECTION_WORST) 420 .setDomain(DOMAIN_DUPLICATION) 421 .setBestValue(0.0) 422 .setOptimizedBestValue(true) 423 .create(); 424 425 public static final String DUPLICATED_FILES_KEY = "duplicated_files"; 426 public static final Metric DUPLICATED_FILES = new Metric(DUPLICATED_FILES_KEY, "Duplicated files", "Duplicated files", 427 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_DUPLICATION).setBestValue(0.0).setOptimizedBestValue(true); 428 429 public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density"; 430 public static final Metric DUPLICATED_LINES_DENSITY = new Metric(DUPLICATED_LINES_DENSITY_KEY, "Duplicated lines (%)", 431 "Duplicated lines balanced by statements", Metric.ValueType.PERCENT, Metric.DIRECTION_WORST, true, DOMAIN_DUPLICATION).setWorstValue( 432 50.0).setBestValue(0.0).setOptimizedBestValue(true); 433 434 public static final String DUPLICATIONS_DATA_KEY = "duplications_data"; 435 public static final Metric DUPLICATIONS_DATA = new Metric(DUPLICATIONS_DATA_KEY, "Duplications details", "Duplications details", 436 Metric.ValueType.DATA, Metric.DIRECTION_NONE, false, DOMAIN_DUPLICATION); 437 438 439 //-------------------------------------------------------------------------------------------------------------------- 440 // 441 // CODING RULES 442 // 443 //-------------------------------------------------------------------------------------------------------------------- 444 /** 445 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 446 */ 447 @Deprecated 448 public static final String USABILITY_KEY = "usability"; 449 450 /** 451 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 452 */ 453 @Deprecated 454 public static final Metric USABILITY = new Metric(USABILITY_KEY, "Usability", "Usability", Metric.ValueType.PERCENT, 455 Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); 456 457 /** 458 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 459 */ 460 @Deprecated 461 public static final String RELIABILITY_KEY = "reliability"; 462 463 /** 464 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 465 */ 466 @Deprecated 467 public static final Metric RELIABILITY = new Metric(RELIABILITY_KEY, "Reliability", "Reliability", Metric.ValueType.PERCENT, 468 Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); 469 470 /** 471 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 472 */ 473 @Deprecated 474 public static final String EFFICIENCY_KEY = "efficiency"; 475 476 /** 477 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 478 */ 479 @Deprecated 480 public static final Metric EFFICIENCY = new Metric(EFFICIENCY_KEY, "Efficiency", "Efficiency", Metric.ValueType.PERCENT, 481 Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); 482 483 /** 484 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 485 */ 486 @Deprecated 487 public static final String PORTABILITY_KEY = "portability"; 488 489 /** 490 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 491 */ 492 @Deprecated 493 public static final Metric PORTABILITY = new Metric(PORTABILITY_KEY, "Portability", "Portability", Metric.ValueType.PERCENT, 494 Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); 495 496 /** 497 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 498 */ 499 @Deprecated 500 public static final String MAINTAINABILITY_KEY = "maintainability"; 501 502 /** 503 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 504 */ 505 @Deprecated 506 public static final Metric MAINTAINABILITY = new Metric(MAINTAINABILITY_KEY, "Maintainability", "Maintainability", 507 Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true); 508 509 public static final String WEIGHTED_VIOLATIONS_KEY = "weighted_violations"; 510 public static final Metric WEIGHTED_VIOLATIONS = new Metric(WEIGHTED_VIOLATIONS_KEY, "Weighted violations", "Weighted Violations", 511 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setHidden(true); 512 513 public static final String VIOLATIONS_DENSITY_KEY = "violations_density"; 514 public static final Metric VIOLATIONS_DENSITY = new Metric(VIOLATIONS_DENSITY_KEY, "Rules compliance", "Rules compliance", 515 Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULES); 516 517 public static final String VIOLATIONS_KEY = "violations"; 518 public static final Metric VIOLATIONS = new Metric(VIOLATIONS_KEY, "Violations", "Violations", Metric.ValueType.INT, 519 Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true); 520 521 public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations"; 522 public static final Metric BLOCKER_VIOLATIONS = new Metric(BLOCKER_VIOLATIONS_KEY, "Blocker violations", "Blocker violations", 523 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true); 524 525 public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations"; 526 public static final Metric CRITICAL_VIOLATIONS = new Metric(CRITICAL_VIOLATIONS_KEY, "Critical violations", "Critical violations", 527 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true); 528 529 public static final String MAJOR_VIOLATIONS_KEY = "major_violations"; 530 public static final Metric MAJOR_VIOLATIONS = new Metric(MAJOR_VIOLATIONS_KEY, "Major violations", "Major violations", 531 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true); 532 533 public static final String MINOR_VIOLATIONS_KEY = "minor_violations"; 534 public static final Metric MINOR_VIOLATIONS = new Metric(MINOR_VIOLATIONS_KEY, "Minor violations", "Minor violations", 535 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true); 536 537 public static final String INFO_VIOLATIONS_KEY = "info_violations"; 538 public static final Metric INFO_VIOLATIONS = new Metric(INFO_VIOLATIONS_KEY, "Info violations", "Info violations", Metric.ValueType.INT, 539 Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true); 540 541 public static final String NEW_VIOLATIONS_KEY = "new_violations"; 542 public static final Metric NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New Violations", Metric.ValueType.INT) 543 .setDescription("New Violations") 544 .setDirection(Metric.DIRECTION_WORST) 545 .setQualitative(true) 546 .setDomain(DOMAIN_RULES) 547 .setBestValue(0.0) 548 .setOptimizedBestValue(true) 549 .create(); 550 551 public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations"; 552 public static final Metric NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker violations", Metric.ValueType.INT) 553 .setDescription("New Blocker violations") 554 .setDirection(Metric.DIRECTION_WORST) 555 .setQualitative(true) 556 .setDomain(DOMAIN_RULES) 557 .setBestValue(0.0) 558 .setOptimizedBestValue(true) 559 .create(); 560 561 public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations"; 562 public static final Metric NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical violations", Metric.ValueType.INT) 563 .setDescription("New Critical violations") 564 .setDirection(Metric.DIRECTION_WORST) 565 .setQualitative(true) 566 .setDomain(DOMAIN_RULES) 567 .setBestValue(0.0) 568 .setOptimizedBestValue(true) 569 .create(); 570 571 public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations"; 572 public static final Metric NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major violations", Metric.ValueType.INT) 573 .setDescription("New Major violations") 574 .setDirection(Metric.DIRECTION_WORST) 575 .setQualitative(true) 576 .setDomain(DOMAIN_RULES) 577 .setBestValue(0.0) 578 .setOptimizedBestValue(true) 579 .create(); 580 581 public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations"; 582 public static final Metric NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor violations", Metric.ValueType.INT) 583 .setDescription("New Minor violations") 584 .setDirection(Metric.DIRECTION_WORST) 585 .setQualitative(true) 586 .setDomain(DOMAIN_RULES) 587 .setBestValue(0.0) 588 .setOptimizedBestValue(true) 589 .create(); 590 591 public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations"; 592 public static final Metric NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info violations", Metric.ValueType.INT) 593 .setDescription("New Info violations") 594 .setDirection(Metric.DIRECTION_WORST) 595 .setQualitative(true) 596 .setDomain(DOMAIN_RULES) 597 .setBestValue(0.0) 598 .setOptimizedBestValue(true) 599 .create(); 600 601 602 //-------------------------------------------------------------------------------------------------------------------- 603 // 604 // DESIGN 605 // 606 //-------------------------------------------------------------------------------------------------------------------- 607 608 public static final String ABSTRACTNESS_KEY = "abstractness"; 609 public static final Metric ABSTRACTNESS = new Metric(ABSTRACTNESS_KEY, "Abstractness", "Abstractness", Metric.ValueType.PERCENT, 610 Metric.DIRECTION_NONE, false, DOMAIN_DESIGN); 611 public static final String INSTABILITY_KEY = "instability"; 612 public static final Metric INSTABILITY = new Metric(INSTABILITY_KEY, "Instability", "Instability", Metric.ValueType.PERCENT, 613 Metric.DIRECTION_NONE, false, DOMAIN_DESIGN); 614 public static final String DISTANCE_KEY = "distance"; 615 public static final Metric DISTANCE = new Metric(DISTANCE_KEY, "Distance", "Distance", Metric.ValueType.FLOAT, Metric.DIRECTION_NONE, 616 false, DOMAIN_DESIGN); 617 618 public static final String DEPTH_IN_TREE_KEY = "dit"; 619 public static final Metric DEPTH_IN_TREE = new Metric(DEPTH_IN_TREE_KEY, "Depth in Tree", "Depth in Inheritance Tree", 620 Metric.ValueType.INT, Metric.DIRECTION_NONE, false, DOMAIN_DESIGN); 621 622 public static final String NUMBER_OF_CHILDREN_KEY = "noc"; 623 public static final Metric NUMBER_OF_CHILDREN = new Metric(NUMBER_OF_CHILDREN_KEY, "Number of Children", "Number of Children", 624 Metric.ValueType.INT, Metric.DIRECTION_NONE, false, DOMAIN_DESIGN); 625 626 public static final String RFC_KEY = "rfc"; 627 public static final Metric RFC = new Metric(RFC_KEY, "RFC", "Response for Class", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, 628 DOMAIN_DESIGN).setFormula(new WeightedMeanAggregationFormula(CoreMetrics.FILES, false)); 629 630 public static final String RFC_DISTRIBUTION_KEY = "rfc_distribution"; 631 public static final Metric RFC_DISTRIBUTION = new Metric(RFC_DISTRIBUTION_KEY, "Class distribution /RFC", "Class distribution /RFC", 632 Metric.ValueType.DISTRIB, Metric.DIRECTION_NONE, true, DOMAIN_DESIGN) 633 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY)); 634 635 public static final String LCOM4_KEY = "lcom4"; 636 public static final Metric LCOM4 = new Metric(LCOM4_KEY, "LCOM4", "Lack of Cohesion of Methods", Metric.ValueType.FLOAT, 637 Metric.DIRECTION_WORST, true, DOMAIN_DESIGN).setFormula(new WeightedMeanAggregationFormula(CoreMetrics.FILES, false)); 638 639 public static final String LCOM4_BLOCKS_KEY = "lcom4_blocks"; 640 public static final Metric LCOM4_BLOCKS = new Metric(LCOM4_BLOCKS_KEY, "LCOM4 blocks", "LCOM4 blocks", Metric.ValueType.DATA, 641 Metric.DIRECTION_NONE, false, DOMAIN_DESIGN).setHidden(true); 642 643 public static final String LCOM4_DISTRIBUTION_KEY = "lcom4_distribution"; 644 public static final Metric LCOM4_DISTRIBUTION = new Metric(LCOM4_DISTRIBUTION_KEY, "Class distribution /LCOM4", 645 "Class distribution /LCOM4", Metric.ValueType.DISTRIB, Metric.DIRECTION_NONE, true, DOMAIN_DESIGN) 646 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY)); 647 648 public static final String SUSPECT_LCOM4_DENSITY_KEY = "suspect_lcom4_density"; 649 public static final Metric SUSPECT_LCOM4_DENSITY = new Metric(SUSPECT_LCOM4_DENSITY_KEY, "Suspect LCOM4 density", 650 "Density of classes having LCOM4>1", Metric.ValueType.PERCENT, Metric.DIRECTION_WORST, true, DOMAIN_DESIGN); 651 652 public static final String AFFERENT_COUPLINGS_KEY = "ca"; 653 public static final Metric AFFERENT_COUPLINGS = new Metric(AFFERENT_COUPLINGS_KEY, "Afferent couplings", "Afferent couplings", 654 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN); 655 public static final String EFFERENT_COUPLINGS_KEY = "ce"; 656 public static final Metric EFFERENT_COUPLINGS = new Metric(EFFERENT_COUPLINGS_KEY, "Efferent couplings", "Efferent couplings", 657 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN); 658 659 public static final String DEPENDENCY_MATRIX_KEY = "dsm"; 660 public static final Metric DEPENDENCY_MATRIX = new Metric(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", "Dependency Matrix", 661 Metric.ValueType.DATA, Metric.DIRECTION_NONE, false, DOMAIN_DESIGN); 662 663 public static final String PACKAGE_CYCLES_KEY = "package_cycles"; 664 public static final Metric PACKAGE_CYCLES = new Metric(PACKAGE_CYCLES_KEY, "Package cycles", "Package cycles", Metric.ValueType.INT, 665 Metric.DIRECTION_WORST, true, DOMAIN_DESIGN).setFormula(new SumChildValuesFormula(false)); 666 667 public static final String PACKAGE_TANGLE_INDEX_KEY = "package_tangle_index"; 668 public static final Metric PACKAGE_TANGLE_INDEX = new Metric(PACKAGE_TANGLE_INDEX_KEY, "Package tangle index", "Package tangle index", 669 Metric.ValueType.PERCENT, Metric.DIRECTION_WORST, true, DOMAIN_DESIGN); 670 671 public static final String PACKAGE_TANGLES_KEY = "package_tangles"; 672 public static final Metric PACKAGE_TANGLES = new Metric(PACKAGE_TANGLES_KEY, "File dependencies to cut", "File dependencies to cut", 673 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN).setFormula(new SumChildValuesFormula(false)); 674 675 public static final String PACKAGE_FEEDBACK_EDGES_KEY = "package_feedback_edges"; 676 public static final Metric PACKAGE_FEEDBACK_EDGES = new Metric(PACKAGE_FEEDBACK_EDGES_KEY, "Package dependencies to cut", 677 "Package dependencies to cut", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN) 678 .setFormula(new SumChildValuesFormula(false)); 679 680 public static final String PACKAGE_EDGES_WEIGHT_KEY = "package_edges_weight"; 681 public static final Metric PACKAGE_EDGES_WEIGHT = new Metric(PACKAGE_EDGES_WEIGHT_KEY, "Package edges weight", "Package edges weight", 682 Metric.ValueType.INT, Metric.DIRECTION_BETTER, false, DOMAIN_DESIGN).setFormula(new SumChildValuesFormula(false)).setHidden(true); 683 684 public static final String FILE_CYCLES_KEY = "file_cycles"; 685 public static final Metric FILE_CYCLES = new Metric(FILE_CYCLES_KEY, "File cycles", "File cycles", Metric.ValueType.INT, 686 Metric.DIRECTION_WORST, true, DOMAIN_DESIGN).setHidden(true); 687 688 public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index"; 689 public static final Metric FILE_TANGLE_INDEX = new Metric(FILE_TANGLE_INDEX_KEY, "File tangle index", "File tangle index", 690 Metric.ValueType.PERCENT, Metric.DIRECTION_WORST, true, DOMAIN_DESIGN).setHidden(true); 691 692 public static final String FILE_TANGLES_KEY = "file_tangles"; 693 public static final Metric FILE_TANGLES = new Metric(FILE_TANGLES_KEY, "File tangles", "Files tangles", Metric.ValueType.INT, 694 Metric.DIRECTION_WORST, false, DOMAIN_DESIGN).setHidden(true); 695 696 public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges"; 697 public static final Metric FILE_FEEDBACK_EDGES = new Metric(FILE_FEEDBACK_EDGES_KEY, "Suspect file dependencies", 698 "Suspect file dependencies", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN).setHidden(true); 699 700 public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight"; 701 public static final Metric FILE_EDGES_WEIGHT = new Metric(FILE_EDGES_WEIGHT_KEY, "File edges weight", "File edges weight", 702 Metric.ValueType.INT, Metric.DIRECTION_BETTER, false, DOMAIN_DESIGN).setHidden(true); 703 704 705 //-------------------------------------------------------------------------------------------------------------------- 706 // 707 // SCM 708 // These metrics are computed by the SCM Activity plugin, since version 1.2. 709 // 710 //-------------------------------------------------------------------------------------------------------------------- 711 712 public static final String SCM_COMMITS_KEY = "commits"; 713 public static final Metric SCM_COMMITS = new Metric.Builder(SCM_COMMITS_KEY, "Commits", Metric.ValueType.INT) 714 .setDomain(DOMAIN_SCM) 715 .create(); 716 717 public static final String SCM_LAST_COMMIT_DATE_KEY = "last_commit_date"; 718 public static final Metric SCM_LAST_COMMIT_DATE = new Metric.Builder(SCM_LAST_COMMIT_DATE_KEY, "Last commit", Metric.ValueType.STRING /* TODO: move to date */) 719 .setDomain(DOMAIN_SCM) 720 .create(); 721 722 public static final String SCM_REVISION_KEY = "revision"; 723 public static final Metric SCM_REVISION = new Metric.Builder(SCM_REVISION_KEY, "Revision", Metric.ValueType.STRING) 724 .setDomain(DOMAIN_SCM) 725 .create(); 726 727 public static final String SCM_AUTHORS_BY_LINE_KEY = "authors_by_line"; 728 public static final Metric SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by line", Metric.ValueType.DATA) 729 .setDomain(DOMAIN_SCM) 730 .create(); 731 732 public static final String SCM_REVISIONS_BY_LINE_KEY = "revisions_by_line"; 733 public static final Metric SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by line", Metric.ValueType.DATA) 734 .setDomain(DOMAIN_SCM) 735 .create(); 736 737 public static final String SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY = "last_commit_datetimes_by_line"; 738 public static final Metric SCM_LAST_COMMIT_DATETIMES_BY_LINE = new Metric.Builder(SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY, "Last commit dates by line", Metric.ValueType.DATA) 739 .setDomain(DOMAIN_SCM) 740 .create(); 741 742 743 //-------------------------------------------------------------------------------------------------------------------- 744 // 745 // OTHERS 746 // 747 //-------------------------------------------------------------------------------------------------------------------- 748 public static final String ALERT_STATUS_KEY = "alert_status"; 749 public static final Metric ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Alert", Metric.ValueType.LEVEL) 750 .setDescription("Alert") 751 .setDirection(Metric.DIRECTION_BETTER) 752 .setQualitative(true) 753 .setDomain(DOMAIN_GENERAL) 754 .create(); 755 756 757 public static final String PROFILE_KEY = "profile"; 758 public static final Metric PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA) 759 .setDescription("Selected quality profile") 760 .setDomain(DOMAIN_GENERAL) 761 .create(); 762 763 764 public static List<Metric> metrics = Lists.newLinkedList(); 765 766 public static List<Metric> getMetrics() { 767 if (metrics.isEmpty()) { 768 for (Field field : CoreMetrics.class.getFields()) { 769 if (Metric.class.isAssignableFrom(field.getType())) { 770 try { 771 Metric metric = (Metric) field.get(null); 772 if (!StringUtils.equals(metric.getDomain(), DOMAIN_RULE_CATEGORIES)) { 773 metrics.add(metric); 774 } 775 } catch (IllegalAccessException e) { 776 throw new SonarException("can not load metrics from " + CoreMetrics.class.getSimpleName(), e); 777 } 778 } 779 } 780 } 781 return metrics; 782 } 783 }