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