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