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 @Deprecated
369 public static final String BRANCH_COVERAGE_HITS_DATA_KEY = "branch_coverage_hits_data";
370
371 /**
372 * @deprecated since 2.7 replaced by metrics CONDITIONS_BY_LINE and COVERED_CONDITIONS_BY_LINE
373 */
374 @Deprecated
375 public static final Metric BRANCH_COVERAGE_HITS_DATA = new Metric.Builder(BRANCH_COVERAGE_HITS_DATA_KEY, "Branch coverage hits", Metric.ValueType.DATA)
376 .setDomain(DOMAIN_TESTS)
377 .create();
378
379 public static final String CONDITIONS_BY_LINE_KEY = "conditions_by_line";
380
381 /**
382 * @since 2.7
383 */
384 public static final Metric CONDITIONS_BY_LINE = new Metric.Builder(CONDITIONS_BY_LINE_KEY, "Conditions by line", Metric.ValueType.DATA)
385 .setDomain(DOMAIN_TESTS)
386 .create();
387
388 public static final String COVERED_CONDITIONS_BY_LINE_KEY = "covered_conditions_by_line";
389
390 /**
391 * @since 2.7
392 */
393 public static final Metric COVERED_CONDITIONS_BY_LINE = new Metric.Builder(COVERED_CONDITIONS_BY_LINE_KEY, "Covered conditions by line", Metric.ValueType.DATA)
394 .setDomain(DOMAIN_TESTS)
395 .create();
396
397
398 //--------------------------------------------------------------------------------------------------------------------
399 //
400 // DUPLICATIONS
401 //
402 //--------------------------------------------------------------------------------------------------------------------
403
404 public static final String DUPLICATED_LINES_KEY = "duplicated_lines";
405 public static final Metric DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated lines", Metric.ValueType.INT)
406 .setDescription("Duplicated lines")
407 .setDirection(Metric.DIRECTION_WORST)
408 .setDomain(DOMAIN_DUPLICATION)
409 .setBestValue(0.0)
410 .setOptimizedBestValue(true)
411 .create();
412
413 public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks";
414 public static final Metric DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated blocks", Metric.ValueType.INT)
415 .setDescription("Duplicated blocks")
416 .setDirection(Metric.DIRECTION_WORST)
417 .setDomain(DOMAIN_DUPLICATION)
418 .setBestValue(0.0)
419 .setOptimizedBestValue(true)
420 .create();
421
422 public static final String DUPLICATED_FILES_KEY = "duplicated_files";
423 public static final Metric DUPLICATED_FILES = new Metric(DUPLICATED_FILES_KEY, "Duplicated files", "Duplicated files",
424 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_DUPLICATION).setBestValue(0.0).setOptimizedBestValue(true);
425
426 public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density";
427 public static final Metric DUPLICATED_LINES_DENSITY = new Metric(DUPLICATED_LINES_DENSITY_KEY, "Duplicated lines (%)",
428 "Duplicated lines balanced by statements", Metric.ValueType.PERCENT, Metric.DIRECTION_WORST, true, DOMAIN_DUPLICATION).setWorstValue(
429 50.0).setBestValue(0.0).setOptimizedBestValue(true);
430
431 public static final String DUPLICATIONS_DATA_KEY = "duplications_data";
432 public static final Metric DUPLICATIONS_DATA = new Metric(DUPLICATIONS_DATA_KEY, "Duplications details", "Duplications details",
433 Metric.ValueType.DATA, Metric.DIRECTION_NONE, false, DOMAIN_DUPLICATION);
434
435
436 //--------------------------------------------------------------------------------------------------------------------
437 //
438 // CODING RULES
439 //
440 //--------------------------------------------------------------------------------------------------------------------
441 /**
442 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
443 */
444 @Deprecated
445 public static final String USABILITY_KEY = "usability";
446
447 /**
448 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
449 */
450 @Deprecated
451 public static final Metric USABILITY = new Metric(USABILITY_KEY, "Usability", "Usability", Metric.ValueType.PERCENT,
452 Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
453
454 /**
455 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
456 */
457 @Deprecated
458 public static final String RELIABILITY_KEY = "reliability";
459
460 /**
461 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
462 */
463 @Deprecated
464 public static final Metric RELIABILITY = new Metric(RELIABILITY_KEY, "Reliability", "Reliability", Metric.ValueType.PERCENT,
465 Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
466
467 /**
468 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
469 */
470 @Deprecated
471 public static final String EFFICIENCY_KEY = "efficiency";
472
473 /**
474 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
475 */
476 @Deprecated
477 public static final Metric EFFICIENCY = new Metric(EFFICIENCY_KEY, "Efficiency", "Efficiency", Metric.ValueType.PERCENT,
478 Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
479
480 /**
481 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
482 */
483 @Deprecated
484 public static final String PORTABILITY_KEY = "portability";
485
486 /**
487 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
488 */
489 @Deprecated
490 public static final Metric PORTABILITY = new Metric(PORTABILITY_KEY, "Portability", "Portability", Metric.ValueType.PERCENT,
491 Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
492
493 /**
494 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
495 */
496 @Deprecated
497 public static final String MAINTAINABILITY_KEY = "maintainability";
498
499 /**
500 * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
501 */
502 @Deprecated
503 public static final Metric MAINTAINABILITY = new Metric(MAINTAINABILITY_KEY, "Maintainability", "Maintainability",
504 Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULE_CATEGORIES).setBestValue(100.0).setOptimizedBestValue(true);
505
506 public static final String WEIGHTED_VIOLATIONS_KEY = "weighted_violations";
507 public static final Metric WEIGHTED_VIOLATIONS = new Metric(WEIGHTED_VIOLATIONS_KEY, "Weighted violations", "Weighted Violations",
508 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setHidden(true);
509
510 public static final String VIOLATIONS_DENSITY_KEY = "violations_density";
511 public static final Metric VIOLATIONS_DENSITY = new Metric(VIOLATIONS_DENSITY_KEY, "Rules compliance", "Rules compliance",
512 Metric.ValueType.PERCENT, Metric.DIRECTION_BETTER, true, DOMAIN_RULES);
513
514 public static final String VIOLATIONS_KEY = "violations";
515 public static final Metric VIOLATIONS = new Metric(VIOLATIONS_KEY, "Violations", "Violations", Metric.ValueType.INT,
516 Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true);
517
518 public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations";
519 public static final Metric BLOCKER_VIOLATIONS = new Metric(BLOCKER_VIOLATIONS_KEY, "Blocker violations", "Blocker violations",
520 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true);
521
522 public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations";
523 public static final Metric CRITICAL_VIOLATIONS = new Metric(CRITICAL_VIOLATIONS_KEY, "Critical violations", "Critical violations",
524 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true);
525
526 public static final String MAJOR_VIOLATIONS_KEY = "major_violations";
527 public static final Metric MAJOR_VIOLATIONS = new Metric(MAJOR_VIOLATIONS_KEY, "Major violations", "Major violations",
528 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true);
529
530 public static final String MINOR_VIOLATIONS_KEY = "minor_violations";
531 public static final Metric MINOR_VIOLATIONS = new Metric(MINOR_VIOLATIONS_KEY, "Minor violations", "Minor violations",
532 Metric.ValueType.INT, Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true);
533
534 public static final String INFO_VIOLATIONS_KEY = "info_violations";
535 public static final Metric INFO_VIOLATIONS = new Metric(INFO_VIOLATIONS_KEY, "Info violations", "Info violations", Metric.ValueType.INT,
536 Metric.DIRECTION_WORST, true, DOMAIN_RULES).setBestValue(0.0).setOptimizedBestValue(true);
537
538 public static final String NEW_VIOLATIONS_KEY = "new_violations";
539 public static final Metric NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New Violations", Metric.ValueType.INT)
540 .setDescription("New Violations")
541 .setDirection(Metric.DIRECTION_WORST)
542 .setQualitative(true)
543 .setDomain(DOMAIN_RULES)
544 .setBestValue(0.0)
545 .setOptimizedBestValue(true)
546 .create();
547
548 public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations";
549 public static final Metric NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker violations", Metric.ValueType.INT)
550 .setDescription("New Blocker violations")
551 .setDirection(Metric.DIRECTION_WORST)
552 .setQualitative(true)
553 .setDomain(DOMAIN_RULES)
554 .setBestValue(0.0)
555 .setOptimizedBestValue(true)
556 .create();
557
558 public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations";
559 public static final Metric NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical violations", Metric.ValueType.INT)
560 .setDescription("New Critical violations")
561 .setDirection(Metric.DIRECTION_WORST)
562 .setQualitative(true)
563 .setDomain(DOMAIN_RULES)
564 .setBestValue(0.0)
565 .setOptimizedBestValue(true)
566 .create();
567
568 public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations";
569 public static final Metric NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major violations", Metric.ValueType.INT)
570 .setDescription("New Major violations")
571 .setDirection(Metric.DIRECTION_WORST)
572 .setQualitative(true)
573 .setDomain(DOMAIN_RULES)
574 .setBestValue(0.0)
575 .setOptimizedBestValue(true)
576 .create();
577
578 public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations";
579 public static final Metric NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor violations", Metric.ValueType.INT)
580 .setDescription("New Minor violations")
581 .setDirection(Metric.DIRECTION_WORST)
582 .setQualitative(true)
583 .setDomain(DOMAIN_RULES)
584 .setBestValue(0.0)
585 .setOptimizedBestValue(true)
586 .create();
587
588 public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations";
589 public static final Metric NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info violations", Metric.ValueType.INT)
590 .setDescription("New Info violations")
591 .setDirection(Metric.DIRECTION_WORST)
592 .setQualitative(true)
593 .setDomain(DOMAIN_RULES)
594 .setBestValue(0.0)
595 .setOptimizedBestValue(true)
596 .create();
597
598
599 //--------------------------------------------------------------------------------------------------------------------
600 //
601 // DESIGN
602 //
603 //--------------------------------------------------------------------------------------------------------------------
604
605 public static final String ABSTRACTNESS_KEY = "abstractness";
606 public static final Metric ABSTRACTNESS = new Metric(ABSTRACTNESS_KEY, "Abstractness", "Abstractness", Metric.ValueType.PERCENT,
607 Metric.DIRECTION_NONE, false, DOMAIN_DESIGN);
608 public static final String INSTABILITY_KEY = "instability";
609 public static final Metric INSTABILITY = new Metric(INSTABILITY_KEY, "Instability", "Instability", Metric.ValueType.PERCENT,
610 Metric.DIRECTION_NONE, false, DOMAIN_DESIGN);
611 public static final String DISTANCE_KEY = "distance";
612 public static final Metric DISTANCE = new Metric(DISTANCE_KEY, "Distance", "Distance", Metric.ValueType.FLOAT, Metric.DIRECTION_NONE,
613 false, DOMAIN_DESIGN);
614
615 public static final String DEPTH_IN_TREE_KEY = "dit";
616 public static final Metric DEPTH_IN_TREE = new Metric(DEPTH_IN_TREE_KEY, "Depth in Tree", "Depth in Inheritance Tree",
617 Metric.ValueType.INT, Metric.DIRECTION_NONE, false, DOMAIN_DESIGN);
618
619 public static final String NUMBER_OF_CHILDREN_KEY = "noc";
620 public static final Metric NUMBER_OF_CHILDREN = new Metric(NUMBER_OF_CHILDREN_KEY, "Number of Children", "Number of Children",
621 Metric.ValueType.INT, Metric.DIRECTION_NONE, false, DOMAIN_DESIGN);
622
623 public static final String RFC_KEY = "rfc";
624 public static final Metric RFC = new Metric(RFC_KEY, "RFC", "Response for Class", Metric.ValueType.INT, Metric.DIRECTION_WORST, false,
625 DOMAIN_DESIGN).setFormula(new WeightedMeanAggregationFormula(CoreMetrics.FILES, false));
626
627 public static final String RFC_DISTRIBUTION_KEY = "rfc_distribution";
628 public static final Metric RFC_DISTRIBUTION = new Metric(RFC_DISTRIBUTION_KEY, "Class distribution /RFC", "Class distribution /RFC",
629 Metric.ValueType.DISTRIB, Metric.DIRECTION_NONE, true, DOMAIN_DESIGN)
630 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY));
631
632 public static final String LCOM4_KEY = "lcom4";
633 public static final Metric LCOM4 = new Metric(LCOM4_KEY, "LCOM4", "Lack of Cohesion of Methods", Metric.ValueType.FLOAT,
634 Metric.DIRECTION_WORST, true, DOMAIN_DESIGN).setFormula(new WeightedMeanAggregationFormula(CoreMetrics.FILES, false));
635
636 public static final String LCOM4_BLOCKS_KEY = "lcom4_blocks";
637 public static final Metric LCOM4_BLOCKS = new Metric(LCOM4_BLOCKS_KEY, "LCOM4 blocks", "LCOM4 blocks", Metric.ValueType.DATA,
638 Metric.DIRECTION_NONE, false, DOMAIN_DESIGN).setHidden(true);
639
640 public static final String LCOM4_DISTRIBUTION_KEY = "lcom4_distribution";
641 public static final Metric LCOM4_DISTRIBUTION = new Metric(LCOM4_DISTRIBUTION_KEY, "Class distribution /LCOM4",
642 "Class distribution /LCOM4", Metric.ValueType.DISTRIB, Metric.DIRECTION_NONE, true, DOMAIN_DESIGN)
643 .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY));
644
645 public static final String SUSPECT_LCOM4_DENSITY_KEY = "suspect_lcom4_density";
646 public static final Metric SUSPECT_LCOM4_DENSITY = new Metric(SUSPECT_LCOM4_DENSITY_KEY, "Suspect LCOM4 density",
647 "Density of classes having LCOM4>1", Metric.ValueType.PERCENT, Metric.DIRECTION_WORST, true, DOMAIN_DESIGN);
648
649 public static final String AFFERENT_COUPLINGS_KEY = "ca";
650 public static final Metric AFFERENT_COUPLINGS = new Metric(AFFERENT_COUPLINGS_KEY, "Afferent couplings", "Afferent couplings",
651 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN);
652 public static final String EFFERENT_COUPLINGS_KEY = "ce";
653 public static final Metric EFFERENT_COUPLINGS = new Metric(EFFERENT_COUPLINGS_KEY, "Efferent couplings", "Efferent couplings",
654 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN);
655
656 public static final String DEPENDENCY_MATRIX_KEY = "dsm";
657 public static final Metric DEPENDENCY_MATRIX = new Metric(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", "Dependency Matrix",
658 Metric.ValueType.DATA, Metric.DIRECTION_NONE, false, DOMAIN_DESIGN);
659
660 public static final String PACKAGE_CYCLES_KEY = "package_cycles";
661 public static final Metric PACKAGE_CYCLES = new Metric(PACKAGE_CYCLES_KEY, "Package cycles", "Package cycles", Metric.ValueType.INT,
662 Metric.DIRECTION_WORST, true, DOMAIN_DESIGN).setFormula(new SumChildValuesFormula(false));
663
664 public static final String PACKAGE_TANGLE_INDEX_KEY = "package_tangle_index";
665 public static final Metric PACKAGE_TANGLE_INDEX = new Metric(PACKAGE_TANGLE_INDEX_KEY, "Package tangle index", "Package tangle index",
666 Metric.ValueType.PERCENT, Metric.DIRECTION_WORST, true, DOMAIN_DESIGN);
667
668 public static final String PACKAGE_TANGLES_KEY = "package_tangles";
669 public static final Metric PACKAGE_TANGLES = new Metric(PACKAGE_TANGLES_KEY, "File dependencies to cut", "File dependencies to cut",
670 Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN).setFormula(new SumChildValuesFormula(false));
671
672 public static final String PACKAGE_FEEDBACK_EDGES_KEY = "package_feedback_edges";
673 public static final Metric PACKAGE_FEEDBACK_EDGES = new Metric(PACKAGE_FEEDBACK_EDGES_KEY, "Package dependencies to cut",
674 "Package dependencies to cut", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN)
675 .setFormula(new SumChildValuesFormula(false));
676
677 public static final String PACKAGE_EDGES_WEIGHT_KEY = "package_edges_weight";
678 public static final Metric PACKAGE_EDGES_WEIGHT = new Metric(PACKAGE_EDGES_WEIGHT_KEY, "Package edges weight", "Package edges weight",
679 Metric.ValueType.INT, Metric.DIRECTION_BETTER, false, DOMAIN_DESIGN).setFormula(new SumChildValuesFormula(false)).setHidden(true);
680
681 public static final String FILE_CYCLES_KEY = "file_cycles";
682 public static final Metric FILE_CYCLES = new Metric(FILE_CYCLES_KEY, "File cycles", "File cycles", Metric.ValueType.INT,
683 Metric.DIRECTION_WORST, true, DOMAIN_DESIGN).setHidden(true);
684
685 public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index";
686 public static final Metric FILE_TANGLE_INDEX = new Metric(FILE_TANGLE_INDEX_KEY, "File tangle index", "File tangle index",
687 Metric.ValueType.PERCENT, Metric.DIRECTION_WORST, true, DOMAIN_DESIGN).setHidden(true);
688
689 public static final String FILE_TANGLES_KEY = "file_tangles";
690 public static final Metric FILE_TANGLES = new Metric(FILE_TANGLES_KEY, "File tangles", "Files tangles", Metric.ValueType.INT,
691 Metric.DIRECTION_WORST, false, DOMAIN_DESIGN).setHidden(true);
692
693 public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges";
694 public static final Metric FILE_FEEDBACK_EDGES = new Metric(FILE_FEEDBACK_EDGES_KEY, "Suspect file dependencies",
695 "Suspect file dependencies", Metric.ValueType.INT, Metric.DIRECTION_WORST, false, DOMAIN_DESIGN).setHidden(true);
696
697 public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight";
698 public static final Metric FILE_EDGES_WEIGHT = new Metric(FILE_EDGES_WEIGHT_KEY, "File edges weight", "File edges weight",
699 Metric.ValueType.INT, Metric.DIRECTION_BETTER, false, DOMAIN_DESIGN).setHidden(true);
700
701
702 //--------------------------------------------------------------------------------------------------------------------
703 //
704 // SCM
705 // These metrics are computed by the SCM Activity plugin, since version 1.2.
706 //
707 //--------------------------------------------------------------------------------------------------------------------
708
709 public static final String SCM_COMMITS_KEY = "commits";
710 public static final Metric SCM_COMMITS = new Metric.Builder(SCM_COMMITS_KEY, "Commits", Metric.ValueType.INT)
711 .setDomain(DOMAIN_SCM)
712 .create();
713
714 public static final String SCM_LAST_COMMIT_DATE_KEY = "last_commit_date";
715 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 */)
716 .setDomain(DOMAIN_SCM)
717 .create();
718
719 public static final String SCM_REVISION_KEY = "revision";
720 public static final Metric SCM_REVISION = new Metric.Builder(SCM_REVISION_KEY, "Revision", Metric.ValueType.STRING)
721 .setDomain(DOMAIN_SCM)
722 .create();
723
724 public static final String SCM_AUTHORS_BY_LINE_KEY = "authors_by_line";
725 public static final Metric SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by line", Metric.ValueType.DATA)
726 .setDomain(DOMAIN_SCM)
727 .create();
728
729 public static final String SCM_REVISIONS_BY_LINE_KEY = "revisions_by_line";
730 public static final Metric SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by line", Metric.ValueType.DATA)
731 .setDomain(DOMAIN_SCM)
732 .create();
733
734 public static final String SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY = "last_commit_datetimes_by_line";
735 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)
736 .setDomain(DOMAIN_SCM)
737 .create();
738
739
740 //--------------------------------------------------------------------------------------------------------------------
741 //
742 // OTHERS
743 //
744 //--------------------------------------------------------------------------------------------------------------------
745 public static final String ALERT_STATUS_KEY = "alert_status";
746 public static final Metric ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Alert", Metric.ValueType.LEVEL)
747 .setDescription("Alert")
748 .setDirection(Metric.DIRECTION_BETTER)
749 .setQualitative(true)
750 .setDomain(DOMAIN_GENERAL)
751 .create();
752
753
754 public static final String PROFILE_KEY = "profile";
755 public static final Metric PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA)
756 .setDescription("Selected quality profile")
757 .setDomain(DOMAIN_GENERAL)
758 .create();
759
760
761 public static List<Metric> metrics = Lists.newLinkedList();
762
763 public static List<Metric> getMetrics() {
764 if (metrics.isEmpty()) {
765 for (Field field : CoreMetrics.class.getFields()) {
766 if (Metric.class.isAssignableFrom(field.getType())) {
767 try {
768 Metric metric = (Metric) field.get(null);
769 if (!StringUtils.equals(metric.getDomain(), DOMAIN_RULE_CATEGORIES)) {
770 metrics.add(metric);
771 }
772 } catch (IllegalAccessException e) {
773 throw new SonarException("can not load metrics from " + CoreMetrics.class.getSimpleName(), e);
774 }
775 }
776 }
777 }
778 return metrics;
779 }
780 }