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