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     */
020    package org.sonar.api.measures;
021    
022    import com.google.common.annotations.Beta;
023    import com.google.common.base.Predicate;
024    import com.google.common.collect.Iterables;
025    import com.google.common.collect.Lists;
026    import org.sonar.api.resources.Scopes;
027    import org.sonar.api.utils.SonarException;
028    
029    import javax.annotation.Nullable;
030    
031    import java.lang.reflect.Field;
032    import java.util.List;
033    
034    /**
035     * @since 1.10
036     */
037    public 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        .setDeleteHistoricalData(true)
750        .create();
751    
752      /**
753       * @since 2.12
754       */
755      public static final String NEW_IT_LINES_TO_COVER_KEY = "new_it_lines_to_cover";
756    
757      /**
758       * @since 2.12
759       */
760      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)
761        .setDescription("Lines to cover by Integration Tests on new code")
762        .setDirection(Metric.DIRECTION_WORST)
763        .setQualitative(false)
764        .setDomain(DOMAIN_INTEGRATION_TESTS)
765        .setFormula(new SumChildValuesFormula(false))
766        .setDeleteHistoricalData(true)
767        .create();
768    
769      /**
770       * @since 2.12
771       */
772      public static final String IT_UNCOVERED_LINES_KEY = "it_uncovered_lines";
773    
774      /**
775       * @since 2.12
776       */
777      public static final Metric<Integer> IT_UNCOVERED_LINES = new Metric.Builder(IT_UNCOVERED_LINES_KEY, "IT uncovered lines", Metric.ValueType.INT)
778        .setDescription("IT uncovered lines")
779        .setDirection(Metric.DIRECTION_WORST)
780        .setQualitative(false)
781        .setDomain(DOMAIN_INTEGRATION_TESTS)
782        .setFormula(new SumChildValuesFormula(false))
783        .create();
784    
785      /**
786       * @since 2.12
787       */
788      public static final String NEW_IT_UNCOVERED_LINES_KEY = "new_it_uncovered_lines";
789    
790      /**
791       * @since 2.12
792       */
793      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)
794        .setDescription("Uncovered lines by IT on new code")
795        .setDirection(Metric.DIRECTION_WORST)
796        .setDomain(DOMAIN_INTEGRATION_TESTS)
797        .setFormula(new SumChildValuesFormula(false))
798        .setBestValue(0.0)
799        .setDeleteHistoricalData(true)
800        .create();
801    
802      /**
803       * @since 2.12
804       */
805      public static final String IT_LINE_COVERAGE_KEY = "it_line_coverage";
806    
807      /**
808       * @since 2.12
809       */
810      public static final Metric<Double> IT_LINE_COVERAGE = new Metric.Builder(IT_LINE_COVERAGE_KEY, "IT line coverage", Metric.ValueType.PERCENT)
811        .setDescription("IT line coverage")
812        .setDirection(Metric.DIRECTION_BETTER)
813        .setQualitative(true)
814        .setDomain(DOMAIN_INTEGRATION_TESTS)
815        .create();
816    
817      /**
818       * @since 2.12
819       */
820      public static final String NEW_IT_LINE_COVERAGE_KEY = "new_it_line_coverage";
821    
822      /**
823       * @since 2.12
824       */
825      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)
826        .setDescription("Line Coverage by Integration Tests of added/changed code")
827        .setDirection(Metric.DIRECTION_BETTER)
828        .setQualitative(true)
829        .setWorstValue(0.0)
830        .setBestValue(100.0)
831        .setDomain(DOMAIN_INTEGRATION_TESTS)
832        .setDeleteHistoricalData(true)
833        .create();
834    
835      /**
836       * @since 2.12
837       */
838      public static final String IT_COVERAGE_LINE_HITS_DATA_KEY = "it_coverage_line_hits_data";
839    
840      /**
841       * @since 2.12
842       */
843      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)
844        .setDescription("Integration Tests Code coverage line hits data")
845        .setDirection(Metric.DIRECTION_NONE)
846        .setQualitative(false)
847        .setDomain(DOMAIN_INTEGRATION_TESTS)
848        .setDeleteHistoricalData(true)
849        .create();
850    
851      /**
852       * @since 2.12
853       */
854      public static final String IT_CONDITIONS_TO_COVER_KEY = "it_conditions_to_cover";
855    
856      /**
857       * @since 2.12
858       */
859      public static final Metric<Integer> IT_CONDITIONS_TO_COVER = new Metric.Builder(IT_CONDITIONS_TO_COVER_KEY, "IT branches to cover", Metric.ValueType.INT)
860        .setDescription("Integration Tests conditions to cover")
861        .setDirection(Metric.DIRECTION_BETTER)
862        .setQualitative(false)
863        .setDomain(DOMAIN_INTEGRATION_TESTS)
864        .setFormula(new SumChildValuesFormula(false))
865        .setHidden(true)
866        .create();
867    
868      /**
869       * @since 2.12
870       */
871      public static final String NEW_IT_CONDITIONS_TO_COVER_KEY = "new_it_conditions_to_cover";
872    
873      /**
874       * @since 2.12
875       */
876      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)
877        .setDescription("Branches to cover by Integration Tests on new code")
878        .setDomain(DOMAIN_INTEGRATION_TESTS)
879        .setFormula(new SumChildValuesFormula(false))
880        .setDeleteHistoricalData(true)
881        .setHidden(true)
882        .create();
883    
884      /**
885       * @since 2.12
886       */
887      public static final String IT_UNCOVERED_CONDITIONS_KEY = "it_uncovered_conditions";
888    
889      /**
890       * @since 2.12
891       */
892      public static final Metric<Integer> IT_UNCOVERED_CONDITIONS = new Metric.Builder(IT_UNCOVERED_CONDITIONS_KEY, "IT uncovered branches", Metric.ValueType.INT)
893        .setDescription("Integration Tests uncovered conditions")
894        .setDirection(Metric.DIRECTION_WORST)
895        .setDomain(DOMAIN_INTEGRATION_TESTS)
896        .setFormula(new SumChildValuesFormula(false))
897        .create();
898    
899      /**
900       * @since 2.12
901       */
902      public static final String NEW_IT_UNCOVERED_CONDITIONS_KEY = "new_it_uncovered_conditions";
903    
904      /**
905       * @since 2.12
906       */
907      public static final Metric<Integer> NEW_IT_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_IT_UNCOVERED_CONDITIONS_KEY, "Uncovered branches by IT on new code",
908        Metric.ValueType.INT)
909        .setDescription("Uncovered branches by Integration Tests on new code")
910        .setDirection(Metric.DIRECTION_WORST)
911        .setDomain(DOMAIN_INTEGRATION_TESTS)
912        .setFormula(new SumChildValuesFormula(false))
913        .setBestValue(0.0)
914        .setDeleteHistoricalData(true)
915        .create();
916    
917      /**
918       * @since 2.12
919       */
920      public static final String IT_BRANCH_COVERAGE_KEY = "it_branch_coverage";
921    
922      /**
923       * @since 2.12
924       */
925      public static final Metric<Double> IT_BRANCH_COVERAGE = new Metric.Builder(IT_BRANCH_COVERAGE_KEY, "IT condition coverage", Metric.ValueType.PERCENT)
926        .setDescription("IT condition coverage")
927        .setDirection(Metric.DIRECTION_BETTER)
928        .setQualitative(true)
929        .setDomain(DOMAIN_INTEGRATION_TESTS)
930        .setWorstValue(0.0)
931        .setBestValue(100.0)
932        .create();
933    
934      /**
935       * @since 2.12
936       */
937      public static final String NEW_IT_BRANCH_COVERAGE_KEY = "new_it_branch_coverage";
938    
939      /**
940       * @since 2.12
941       */
942      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)
943        .setDescription("Condition coverage by Integration Tests of new/changed code")
944        .setDirection(Metric.DIRECTION_BETTER)
945        .setQualitative(true)
946        .setDomain(DOMAIN_INTEGRATION_TESTS)
947        .setWorstValue(0.0)
948        .setBestValue(100.0)
949        .setDeleteHistoricalData(true)
950        .create();
951    
952      /**
953       * @since 2.12
954       */
955      public static final String IT_CONDITIONS_BY_LINE_KEY = "it_conditions_by_line";
956    
957      /**
958       * @since 2.12
959       */
960      public static final Metric<String> IT_CONDITIONS_BY_LINE = new Metric.Builder(IT_CONDITIONS_BY_LINE_KEY, "IT conditions by line", Metric.ValueType.DATA)
961        .setDomain(DOMAIN_INTEGRATION_TESTS)
962        .setDeleteHistoricalData(true)
963        .create();
964    
965      /**
966       * @since 2.12
967       */
968      public static final String IT_COVERED_CONDITIONS_BY_LINE_KEY = "it_covered_conditions_by_line";
969    
970      /**
971       * @since 2.12
972       */
973      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)
974        .setDomain(DOMAIN_INTEGRATION_TESTS)
975        .setDeleteHistoricalData(true)
976        .create();
977    
978      // --------------------------------------------------------------------------------------------------------------------
979      //
980      // OVERALL TESTS
981      //
982      // --------------------------------------------------------------------------------------------------------------------
983    
984      /**
985       * @since 3.3
986       */
987      public static final String OVERALL_COVERAGE_KEY = "overall_coverage";
988    
989      /**
990       * @since 3.3
991       */
992      public static final Metric<Double> OVERALL_COVERAGE = new Metric.Builder(OVERALL_COVERAGE_KEY, "Overall coverage", Metric.ValueType.PERCENT)
993        .setDescription("Overall test coverage")
994        .setDirection(Metric.DIRECTION_BETTER)
995        .setQualitative(true)
996        .setDomain(DOMAIN_OVERALL_TESTS)
997        .setWorstValue(0.0)
998        .setBestValue(100.0)
999        .create();
1000    
1001      /**
1002       * @since 3.3
1003       */
1004      public static final String NEW_OVERALL_COVERAGE_KEY = "new_overall_coverage";
1005    
1006      /**
1007       * @since 3.3
1008       */
1009      public static final Metric<Double> NEW_OVERALL_COVERAGE = new Metric.Builder(NEW_OVERALL_COVERAGE_KEY, "Overall coverage on new code", Metric.ValueType.PERCENT)
1010        .setDescription("Overall coverage of new/changed code")
1011        .setDirection(Metric.DIRECTION_BETTER)
1012        .setQualitative(true)
1013        .setDomain(DOMAIN_OVERALL_TESTS)
1014        .setWorstValue(0.0)
1015        .setBestValue(100.0)
1016        .setDeleteHistoricalData(true)
1017        .create();
1018    
1019      /**
1020       * @since 3.3
1021       */
1022      public static final String OVERALL_LINES_TO_COVER_KEY = "overall_lines_to_cover";
1023    
1024      /**
1025       * @since 3.3
1026       */
1027      public static final Metric<Integer> OVERALL_LINES_TO_COVER = new Metric.Builder(OVERALL_LINES_TO_COVER_KEY, "Overall lines to cover", Metric.ValueType.INT)
1028        .setDescription("Overall lines to cover by all tests")
1029        .setDirection(Metric.DIRECTION_BETTER)
1030        .setDomain(DOMAIN_OVERALL_TESTS)
1031        .setQualitative(false)
1032        .setFormula(new SumChildValuesFormula(false))
1033        .setHidden(true)
1034        .setDeleteHistoricalData(true)
1035        .create();
1036    
1037      /**
1038       * @since 3.3
1039       */
1040      public static final String NEW_OVERALL_LINES_TO_COVER_KEY = "new_overall_lines_to_cover";
1041    
1042      /**
1043       * @since 3.3
1044       */
1045      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)
1046        .setDescription("New lines to cover by all tests")
1047        .setDirection(Metric.DIRECTION_WORST)
1048        .setQualitative(false)
1049        .setDomain(DOMAIN_OVERALL_TESTS)
1050        .setFormula(new SumChildValuesFormula(false))
1051        .setDeleteHistoricalData(true)
1052        .create();
1053    
1054      /**
1055       * @since 3.3
1056       */
1057      public static final String OVERALL_UNCOVERED_LINES_KEY = "overall_uncovered_lines";
1058    
1059      /**
1060       * @since 3.3
1061       */
1062      public static final Metric<Integer> OVERALL_UNCOVERED_LINES = new Metric.Builder(OVERALL_UNCOVERED_LINES_KEY, "Overall uncovered lines", Metric.ValueType.INT)
1063        .setDescription("Uncovered lines by all tests")
1064        .setDirection(Metric.DIRECTION_WORST)
1065        .setQualitative(false)
1066        .setDomain(DOMAIN_OVERALL_TESTS)
1067        .setFormula(new SumChildValuesFormula(false))
1068        .create();
1069    
1070      /**
1071       * @since 3.3
1072       */
1073      public static final String NEW_OVERALL_UNCOVERED_LINES_KEY = "new_overall_uncovered_lines";
1074    
1075      /**
1076       * @since 3.3
1077       */
1078      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)
1079        .setDescription("New lines that are not covered by any tests")
1080        .setDirection(Metric.DIRECTION_WORST)
1081        .setDomain(DOMAIN_OVERALL_TESTS)
1082        .setFormula(new SumChildValuesFormula(false))
1083        .setBestValue(0.0)
1084        .setDeleteHistoricalData(true)
1085        .create();
1086    
1087      /**
1088       * @since 3.3
1089       */
1090      public static final String OVERALL_LINE_COVERAGE_KEY = "overall_line_coverage";
1091    
1092      /**
1093       * @since 3.3
1094       */
1095      public static final Metric<Double> OVERALL_LINE_COVERAGE = new Metric.Builder(OVERALL_LINE_COVERAGE_KEY, "Overall line coverage", Metric.ValueType.PERCENT)
1096        .setDescription("Line coverage by all tests")
1097        .setDirection(Metric.DIRECTION_BETTER)
1098        .setQualitative(true)
1099        .setDomain(DOMAIN_OVERALL_TESTS)
1100        .create();
1101    
1102      /**
1103       * @since 3.3
1104       */
1105      public static final String NEW_OVERALL_LINE_COVERAGE_KEY = "new_overall_line_coverage";
1106    
1107      /**
1108       * @since 3.3
1109       */
1110      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)
1111        .setDescription("Line coverage of added/changed code by all tests")
1112        .setDirection(Metric.DIRECTION_BETTER)
1113        .setQualitative(true)
1114        .setWorstValue(0.0)
1115        .setBestValue(100.0)
1116        .setDomain(DOMAIN_OVERALL_TESTS)
1117        .setDeleteHistoricalData(true)
1118        .create();
1119    
1120      /**
1121       * @since 3.3
1122       */
1123      public static final String OVERALL_COVERAGE_LINE_HITS_DATA_KEY = "overall_coverage_line_hits_data";
1124    
1125      /**
1126       * @since 3.3
1127       */
1128      public static final Metric<String> OVERALL_COVERAGE_LINE_HITS_DATA = new Metric.Builder(OVERALL_COVERAGE_LINE_HITS_DATA_KEY, "Overall coverage hits by line",
1129        Metric.ValueType.DATA)
1130        .setDescription("Coverage hits by all tests and by line")
1131        .setDirection(Metric.DIRECTION_NONE)
1132        .setQualitative(false)
1133        .setDomain(DOMAIN_OVERALL_TESTS)
1134        .setDeleteHistoricalData(true)
1135        .create();
1136    
1137      /**
1138       * @since 3.3
1139       */
1140      public static final String OVERALL_CONDITIONS_TO_COVER_KEY = "overall_conditions_to_cover";
1141    
1142      /**
1143       * @since 3.3
1144       */
1145      public static final Metric<Integer> OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(OVERALL_CONDITIONS_TO_COVER_KEY, "Overall branches to cover", Metric.ValueType.INT)
1146        .setDescription("Branches to cover by all tests")
1147        .setDirection(Metric.DIRECTION_BETTER)
1148        .setQualitative(false)
1149        .setDomain(DOMAIN_OVERALL_TESTS)
1150        .setFormula(new SumChildValuesFormula(false))
1151        .setHidden(true)
1152        .create();
1153    
1154      /**
1155       * @since 3.3
1156       */
1157      public static final String NEW_OVERALL_CONDITIONS_TO_COVER_KEY = "new_overall_conditions_to_cover";
1158    
1159      /**
1160       * @since 3.3
1161       */
1162      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",
1163        Metric.ValueType.INT)
1164        .setDescription("New branches to cover by all tests")
1165        .setDomain(DOMAIN_OVERALL_TESTS)
1166        .setFormula(new SumChildValuesFormula(false))
1167        .setDeleteHistoricalData(true)
1168        .setHidden(true)
1169        .create();
1170    
1171      /**
1172       * @since 3.3
1173       */
1174      public static final String OVERALL_UNCOVERED_CONDITIONS_KEY = "overall_uncovered_conditions";
1175    
1176      /**
1177       * @since 3.3
1178       */
1179      public static final Metric<Integer> OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall uncovered branches", Metric.ValueType.INT)
1180        .setDescription("Uncovered branches by all tests")
1181        .setDirection(Metric.DIRECTION_WORST)
1182        .setDomain(DOMAIN_OVERALL_TESTS)
1183        .setFormula(new SumChildValuesFormula(false))
1184        .create();
1185    
1186      /**
1187       * @since 3.3
1188       */
1189      public static final String NEW_OVERALL_UNCOVERED_CONDITIONS_KEY = "new_overall_uncovered_conditions";
1190    
1191      /**
1192       * @since 3.3
1193       */
1194      public static final Metric<Integer> NEW_OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall uncovered branches on new code",
1195        Metric.ValueType.INT)
1196        .setDescription("New branches that are not covered by any test")
1197        .setDirection(Metric.DIRECTION_WORST)
1198        .setDomain(DOMAIN_OVERALL_TESTS)
1199        .setFormula(new SumChildValuesFormula(false))
1200        .setBestValue(0.0)
1201        .setDeleteHistoricalData(true)
1202        .create();
1203    
1204      /**
1205       * @since 3.3
1206       */
1207      public static final String OVERALL_BRANCH_COVERAGE_KEY = "overall_branch_coverage";
1208    
1209      /**
1210       * @since 3.3
1211       */
1212      public static final Metric<Double> OVERALL_BRANCH_COVERAGE = new Metric.Builder(OVERALL_BRANCH_COVERAGE_KEY, "Overall condition coverage", Metric.ValueType.PERCENT)
1213        .setDescription("Condition coverage by all tests")
1214        .setDirection(Metric.DIRECTION_BETTER)
1215        .setQualitative(true)
1216        .setDomain(DOMAIN_OVERALL_TESTS)
1217        .setWorstValue(0.0)
1218        .setBestValue(100.0)
1219        .create();
1220    
1221      /**
1222       * @since 3.3
1223       */
1224      public static final String NEW_OVERALL_BRANCH_COVERAGE_KEY = "new_overall_branch_coverage";
1225    
1226      /**
1227       * @since 3.3
1228       */
1229      public static final Metric<Double> NEW_OVERALL_BRANCH_COVERAGE = new Metric.Builder(NEW_OVERALL_BRANCH_COVERAGE_KEY, "Overall condition coverage on new code",
1230        Metric.ValueType.PERCENT)
1231        .setDescription("Condition coverage of new/changed code by all tests")
1232        .setDirection(Metric.DIRECTION_BETTER)
1233        .setQualitative(true)
1234        .setDomain(DOMAIN_OVERALL_TESTS)
1235        .setWorstValue(0.0)
1236        .setBestValue(100.0)
1237        .setDeleteHistoricalData(true)
1238        .create();
1239    
1240      /**
1241       * @since 3.3
1242       */
1243      public static final String OVERALL_CONDITIONS_BY_LINE_KEY = "overall_conditions_by_line";
1244    
1245      /**
1246       * @since 3.3
1247       */
1248      public static final Metric<String> OVERALL_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_CONDITIONS_BY_LINE_KEY, "Overall conditions by line", Metric.ValueType.DATA)
1249        .setDescription("Overall conditions by all tests and by line")
1250        .setDomain(DOMAIN_OVERALL_TESTS)
1251        .setDeleteHistoricalData(true)
1252        .create();
1253    
1254      /**
1255       * @since 3.3
1256       */
1257      public static final String OVERALL_COVERED_CONDITIONS_BY_LINE_KEY = "overall_covered_conditions_by_line";
1258    
1259      /**
1260       * @since 3.3
1261       */
1262      public static final Metric<String> OVERALL_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_COVERED_CONDITIONS_BY_LINE_KEY, "Overall covered branches by line",
1263        Metric.ValueType.DATA)
1264        .setDescription("Overall covered branches by all tests and by line")
1265        .setDomain(DOMAIN_OVERALL_TESTS)
1266        .setDeleteHistoricalData(true)
1267        .create();
1268    
1269      // --------------------------------------------------------------------------------------------------------------------
1270      //
1271      // DUPLICATIONS
1272      //
1273      // --------------------------------------------------------------------------------------------------------------------
1274    
1275      public static final String DUPLICATED_LINES_KEY = "duplicated_lines";
1276      public static final Metric<Integer> DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated lines", Metric.ValueType.INT)
1277        .setDescription("Duplicated lines")
1278        .setDirection(Metric.DIRECTION_WORST)
1279        .setQualitative(true)
1280        .setDomain(DOMAIN_DUPLICATION)
1281        .setBestValue(0.0)
1282        .setOptimizedBestValue(true)
1283        .create();
1284    
1285      public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks";
1286      public static final Metric<Integer> DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated blocks", Metric.ValueType.INT)
1287        .setDescription("Duplicated blocks")
1288        .setDirection(Metric.DIRECTION_WORST)
1289        .setQualitative(true)
1290        .setDomain(DOMAIN_DUPLICATION)
1291        .setBestValue(0.0)
1292        .setOptimizedBestValue(true)
1293        .create();
1294    
1295      public static final String DUPLICATED_FILES_KEY = "duplicated_files";
1296    
1297      /**
1298       * For files: if it contains duplicates, then 1, otherwise 0.
1299       * For other resources: amount of files under this resource with duplicates.
1300       */
1301      public static final Metric<Integer> DUPLICATED_FILES = new Metric.Builder(DUPLICATED_FILES_KEY, "Duplicated files", Metric.ValueType.INT)
1302        .setDescription("Duplicated files")
1303        .setDirection(Metric.DIRECTION_WORST)
1304        .setQualitative(true)
1305        .setDomain(DOMAIN_DUPLICATION)
1306        .setBestValue(0.0)
1307        .setOptimizedBestValue(true)
1308        .create();
1309    
1310      public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density";
1311      public static final Metric<Double> DUPLICATED_LINES_DENSITY = new Metric.Builder(DUPLICATED_LINES_DENSITY_KEY, "Duplicated lines (%)", Metric.ValueType.PERCENT)
1312        .setDescription("Duplicated lines balanced by statements")
1313        .setDirection(Metric.DIRECTION_WORST)
1314        .setQualitative(true)
1315        .setDomain(DOMAIN_DUPLICATION)
1316        .setWorstValue(50.0)
1317        .setBestValue(0.0)
1318        .setOptimizedBestValue(true)
1319        .create();
1320    
1321      /**
1322       * @deprecated since 4.5. Internal storage of duplication is not an API. No more available on batch side.
1323       */
1324      @Deprecated
1325      public static final String DUPLICATIONS_DATA_KEY = "duplications_data";
1326    
1327      /**
1328       * Information about duplications, which is represented as an XML string.
1329       * <p>
1330       * Here is the format (since Sonar 2.12):
1331       * <pre>
1332       *   <duplications>
1333       *     <!-- Multiple groups: -->
1334       *     <g>
1335       *       <!-- Multiple blocks: -->
1336       *       <b r="[resource key]" s="[first line]" l="[number of lines]" />
1337       *       ...
1338       *     </g>
1339       *     ...
1340       *   </duplications>
1341       * </pre>
1342       * </p>
1343       * @deprecated since 4.5. Internal storage of duplication is not an API. No more available on batch side.
1344       */
1345      @Deprecated
1346      public static final Metric<String> DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplications details", Metric.ValueType.DATA)
1347        .setDescription("Duplications details")
1348        .setDirection(Metric.DIRECTION_NONE)
1349        .setQualitative(false)
1350        .setDomain(DOMAIN_DUPLICATION)
1351        .setDeleteHistoricalData(true)
1352        .create();
1353    
1354      /**
1355       * @since 4.5 used by dev cockpit.
1356       */
1357      @Beta
1358      public static final String DUPLICATION_LINES_DATA_KEY = "duplication_lines_data";
1359    
1360      /**
1361       * Information about duplication in file.
1362       * 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).
1363       *
1364       * @see org.sonar.api.measures.FileLinesContext
1365       * @since 4.5 used by dev cockpit
1366       */
1367      @Beta
1368      public static final Metric<String> DUPLICATION_LINES_DATA = new Metric.Builder(DUPLICATION_LINES_DATA_KEY, "duplication_lines_data", Metric.ValueType.DATA)
1369        .setHidden(true)
1370        .setDomain(DOMAIN_DUPLICATION)
1371        .create();
1372    
1373      // --------------------------------------------------------------------------------------------------------------------
1374      //
1375      // CODING RULES
1376      //
1377      // --------------------------------------------------------------------------------------------------------------------
1378    
1379      public static final String VIOLATIONS_KEY = "violations";
1380      public static final Metric<Integer> VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT)
1381        .setDescription("Issues")
1382        .setDirection(Metric.DIRECTION_WORST)
1383        .setQualitative(true)
1384        .setDomain(DOMAIN_ISSUES)
1385        .setBestValue(0.0)
1386        .setOptimizedBestValue(true)
1387        .create();
1388    
1389      public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations";
1390      public static final Metric<Integer> BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker issues", Metric.ValueType.INT)
1391        .setDescription("Blocker issues")
1392        .setDirection(Metric.DIRECTION_WORST)
1393        .setQualitative(true)
1394        .setDomain(DOMAIN_ISSUES)
1395        .setBestValue(0.0)
1396        .setOptimizedBestValue(true)
1397        .create();
1398    
1399      public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations";
1400      public static final Metric<Integer> CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical issues", Metric.ValueType.INT)
1401        .setDescription("Critical issues")
1402        .setDirection(Metric.DIRECTION_WORST)
1403        .setQualitative(true)
1404        .setDomain(DOMAIN_ISSUES)
1405        .setBestValue(0.0)
1406        .setOptimizedBestValue(true)
1407        .create();
1408    
1409      public static final String MAJOR_VIOLATIONS_KEY = "major_violations";
1410      public static final Metric<Integer> MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major issues", Metric.ValueType.INT)
1411        .setDescription("Major issues")
1412        .setDirection(Metric.DIRECTION_WORST)
1413        .setQualitative(true)
1414        .setDomain(DOMAIN_ISSUES)
1415        .setBestValue(0.0)
1416        .setOptimizedBestValue(true)
1417        .create();
1418    
1419      public static final String MINOR_VIOLATIONS_KEY = "minor_violations";
1420      public static final Metric<Integer> MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor issues", Metric.ValueType.INT)
1421        .setDescription("Minor issues")
1422        .setDirection(Metric.DIRECTION_WORST)
1423        .setQualitative(true)
1424        .setDomain(DOMAIN_ISSUES)
1425        .setBestValue(0.0)
1426        .setOptimizedBestValue(true)
1427        .create();
1428    
1429      public static final String INFO_VIOLATIONS_KEY = "info_violations";
1430      public static final Metric<Integer> INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info issues", Metric.ValueType.INT)
1431        .setDescription("Info issues")
1432        .setDirection(Metric.DIRECTION_WORST)
1433        .setQualitative(true)
1434        .setDomain(DOMAIN_ISSUES)
1435        .setBestValue(0.0)
1436        .setOptimizedBestValue(true)
1437        .create();
1438    
1439      public static final String NEW_VIOLATIONS_KEY = "new_violations";
1440      public static final Metric<Integer> NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New issues", Metric.ValueType.INT)
1441        .setDescription("New Issues")
1442        .setDirection(Metric.DIRECTION_WORST)
1443        .setQualitative(true)
1444        .setDomain(DOMAIN_ISSUES)
1445        .setBestValue(0.0)
1446        .setOptimizedBestValue(true)
1447        .setDeleteHistoricalData(true)
1448        .create();
1449    
1450      public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations";
1451      public static final Metric<Integer> NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker issues", Metric.ValueType.INT)
1452        .setDescription("New Blocker issues")
1453        .setDirection(Metric.DIRECTION_WORST)
1454        .setQualitative(true)
1455        .setDomain(DOMAIN_ISSUES)
1456        .setBestValue(0.0)
1457        .setOptimizedBestValue(true)
1458        .setDeleteHistoricalData(true)
1459        .create();
1460    
1461      public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations";
1462      public static final Metric<Integer> NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical issues", Metric.ValueType.INT)
1463        .setDescription("New Critical issues")
1464        .setDirection(Metric.DIRECTION_WORST)
1465        .setQualitative(true)
1466        .setDomain(DOMAIN_ISSUES)
1467        .setBestValue(0.0)
1468        .setOptimizedBestValue(true)
1469        .setDeleteHistoricalData(true)
1470        .create();
1471    
1472      public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations";
1473      public static final Metric<Integer> NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major issues", Metric.ValueType.INT)
1474        .setDescription("New Major issues")
1475        .setDirection(Metric.DIRECTION_WORST)
1476        .setQualitative(true)
1477        .setDomain(DOMAIN_ISSUES)
1478        .setBestValue(0.0)
1479        .setOptimizedBestValue(true)
1480        .setDeleteHistoricalData(true)
1481        .create();
1482    
1483      public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations";
1484      public static final Metric<Integer> NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor issues", Metric.ValueType.INT)
1485        .setDescription("New Minor issues")
1486        .setDirection(Metric.DIRECTION_WORST)
1487        .setQualitative(true)
1488        .setDomain(DOMAIN_ISSUES)
1489        .setBestValue(0.0)
1490        .setOptimizedBestValue(true)
1491        .setDeleteHistoricalData(true)
1492        .create();
1493    
1494      public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations";
1495      public static final Metric<Integer> NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info issues", Metric.ValueType.INT)
1496        .setDescription("New Info issues")
1497        .setDirection(Metric.DIRECTION_WORST)
1498        .setQualitative(true)
1499        .setDomain(DOMAIN_ISSUES)
1500        .setBestValue(0.0)
1501        .setOptimizedBestValue(true)
1502        .setDeleteHistoricalData(true)
1503        .create();
1504    
1505      /**
1506       * @since 3.6
1507       */
1508      public static final String FALSE_POSITIVE_ISSUES_KEY = "false_positive_issues";
1509    
1510      /**
1511       * @since 3.6
1512       */
1513      public static final Metric<Integer> FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False positive issues", Metric.ValueType.INT)
1514        .setDescription("False positive issues")
1515        .setDirection(Metric.DIRECTION_WORST)
1516        .setDomain(DOMAIN_ISSUES)
1517        .setBestValue(0.0)
1518        .setOptimizedBestValue(true)
1519        .create();
1520    
1521      /**
1522       * @since 3.6
1523       */
1524      public static final String OPEN_ISSUES_KEY = "open_issues";
1525    
1526      /**
1527       * @since 3.6
1528       */
1529      public static final Metric<Integer> OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open issues", Metric.ValueType.INT)
1530        .setDescription("Open issues")
1531        .setDirection(Metric.DIRECTION_WORST)
1532        .setDomain(DOMAIN_ISSUES)
1533        .setBestValue(0.0)
1534        .setOptimizedBestValue(true)
1535        .create();
1536    
1537      /**
1538       * @since 3.6
1539       */
1540      public static final String REOPENED_ISSUES_KEY = "reopened_issues";
1541    
1542      /**
1543       * @since 3.6
1544       */
1545      public static final Metric<Integer> REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened issues", Metric.ValueType.INT)
1546        .setDescription("Reopened issues")
1547        .setDirection(Metric.DIRECTION_WORST)
1548        .setQualitative(true)
1549        .setDomain(DOMAIN_ISSUES)
1550        .setBestValue(0.0)
1551        .setOptimizedBestValue(true)
1552        .create();
1553    
1554      /**
1555       * @since 3.6
1556       */
1557      public static final String CONFIRMED_ISSUES_KEY = "confirmed_issues";
1558    
1559      /**
1560       * @since 3.6
1561       */
1562      public static final Metric<Integer> CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed issues", Metric.ValueType.INT)
1563        .setDescription("Confirmed issues")
1564        .setDirection(Metric.DIRECTION_WORST)
1565        .setQualitative(true)
1566        .setDomain(DOMAIN_ISSUES)
1567        .setBestValue(0.0)
1568        .setOptimizedBestValue(true)
1569        .create();
1570    
1571      // --------------------------------------------------------------------------------------------------------------------
1572      //
1573      // DESIGN
1574      //
1575      // --------------------------------------------------------------------------------------------------------------------
1576    
1577      /**
1578       * @deprecated since 3.7.1
1579       */
1580      @Deprecated
1581      public static final String ABSTRACTNESS_KEY = "abstractness";
1582      /**
1583       * @deprecated since 3.7.1
1584       */
1585      @Deprecated
1586      public static final Metric<Double> ABSTRACTNESS = new Metric.Builder(ABSTRACTNESS_KEY, "Abstractness", Metric.ValueType.PERCENT)
1587        .setDescription("Abstractness")
1588        .setDirection(Metric.DIRECTION_NONE)
1589        .setQualitative(false)
1590        .setDomain(DOMAIN_DESIGN)
1591        .setHidden(true)
1592        .create();
1593    
1594      /**
1595       * @deprecated since 3.7.1
1596       */
1597      @Deprecated
1598      public static final String INSTABILITY_KEY = "instability";
1599      /**
1600       * @deprecated since 3.7.1
1601       */
1602      @Deprecated
1603      public static final Metric<Double> INSTABILITY = new Metric.Builder(INSTABILITY_KEY, "Instability", Metric.ValueType.PERCENT)
1604        .setDescription("Instability")
1605        .setDirection(Metric.DIRECTION_NONE)
1606        .setQualitative(false)
1607        .setDomain(DOMAIN_DESIGN)
1608        .setHidden(true)
1609        .create();
1610    
1611      /**
1612       * @deprecated since 3.7.1
1613       */
1614      @Deprecated
1615      public static final String DISTANCE_KEY = "distance";
1616      /**
1617       * @deprecated since 3.7.1
1618       */
1619      @Deprecated
1620      public static final Metric<Double> DISTANCE = new Metric.Builder(DISTANCE_KEY, "Distance", Metric.ValueType.FLOAT)
1621        .setDescription("Distance")
1622        .setDirection(Metric.DIRECTION_NONE)
1623        .setQualitative(false)
1624        .setDomain(DOMAIN_DESIGN)
1625        .setHidden(true)
1626        .create();
1627    
1628      /**
1629       * @deprecated since 4.0. See SONAR-4643
1630       */
1631      @Deprecated
1632      public static final String DEPTH_IN_TREE_KEY = "dit";
1633      /**
1634       * @deprecated since 4.0. See SONAR-4643
1635       */
1636      @Deprecated
1637      public static final Metric<Integer> DEPTH_IN_TREE = new Metric.Builder(DEPTH_IN_TREE_KEY, "Depth in Tree", Metric.ValueType.INT)
1638        .setDescription("Depth in Inheritance Tree")
1639        .setDirection(Metric.DIRECTION_NONE)
1640        .setQualitative(false)
1641        .setDomain(DOMAIN_DESIGN)
1642        .setHidden(true)
1643        .create();
1644    
1645      /**
1646       * @deprecated since 4.0. See SONAR-4643
1647       */
1648      @Deprecated
1649      public static final String NUMBER_OF_CHILDREN_KEY = "noc";
1650      /**
1651       * @deprecated since 4.0. See SONAR-4643
1652       */
1653      @Deprecated
1654      public static final Metric<Integer> NUMBER_OF_CHILDREN = new Metric.Builder(NUMBER_OF_CHILDREN_KEY, "Number of Children", Metric.ValueType.INT)
1655        .setDescription("Number of Children")
1656        .setDirection(Metric.DIRECTION_NONE)
1657        .setQualitative(false)
1658        .setDomain(DOMAIN_DESIGN)
1659        .setHidden(true)
1660        .create();
1661    
1662      /**
1663       * @deprecated since 4.2. See SONAR-5042
1664       */
1665      @Deprecated
1666      public static final String RFC_KEY = "rfc";
1667    
1668      /**
1669       * @deprecated since 4.2. See SONAR-5042
1670       */
1671      @Deprecated
1672      public static final Metric<Integer> RFC = new Metric.Builder(RFC_KEY, "RFC", Metric.ValueType.INT)
1673        .setDescription("Response for Class")
1674        .setDirection(Metric.DIRECTION_WORST)
1675        .setQualitative(false)
1676        .setDomain(DOMAIN_DESIGN)
1677        .setFormula(new WeightedMeanAggregationFormula(CoreMetrics.FILES, false))
1678        .setHidden(true)
1679        .create();
1680    
1681      /**
1682       * @deprecated since 4.2. See SONAR-5042
1683       */
1684      @Deprecated
1685      public static final String RFC_DISTRIBUTION_KEY = "rfc_distribution";
1686    
1687      /**
1688       * @deprecated since 4.2. See SONAR-5042
1689       */
1690      @Deprecated
1691      public static final Metric<String> RFC_DISTRIBUTION = new Metric.Builder(RFC_DISTRIBUTION_KEY, "Class distribution /RFC", Metric.ValueType.DISTRIB)
1692        .setDescription("Class distribution /RFC")
1693        .setDirection(Metric.DIRECTION_NONE)
1694        .setQualitative(true)
1695        .setDomain(DOMAIN_DESIGN)
1696        .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
1697        .setHidden(true)
1698        .create();
1699    
1700      /**
1701       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1702       */
1703      @Deprecated
1704      public static final String LCOM4_KEY = "lcom4";
1705    
1706      /**
1707       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1708       */
1709      @Deprecated
1710      public static final Metric<Double> LCOM4 = new Metric.Builder(LCOM4_KEY, "LCOM4", Metric.ValueType.FLOAT)
1711        .setDescription("Lack of Cohesion of Functions")
1712        .setDirection(Metric.DIRECTION_WORST)
1713        .setQualitative(true)
1714        .setDomain(DOMAIN_DESIGN)
1715        .setBestValue(1.0)
1716        .setHidden(true)
1717        .create();
1718    
1719      /**
1720       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1721       */
1722      @Deprecated
1723      public static final String LCOM4_BLOCKS_KEY = "lcom4_blocks";
1724    
1725      /**
1726       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1727       */
1728      @Deprecated
1729      public static final Metric<String> LCOM4_BLOCKS = new Metric.Builder(LCOM4_BLOCKS_KEY, "LCOM4 blocks", Metric.ValueType.DATA)
1730        .setDescription("LCOM4 blocks")
1731        .setDirection(Metric.DIRECTION_NONE)
1732        .setQualitative(false)
1733        .setDomain(DOMAIN_DESIGN)
1734        .setDeleteHistoricalData(true)
1735        .setHidden(true)
1736        .create();
1737    
1738      /**
1739       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1740       */
1741      @Deprecated
1742      public static final String LCOM4_DISTRIBUTION_KEY = "lcom4_distribution";
1743    
1744      /**
1745       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1746       */
1747      @Deprecated
1748      public static final Metric<String> LCOM4_DISTRIBUTION = new Metric.Builder(LCOM4_DISTRIBUTION_KEY, "Class distribution /LCOM4", Metric.ValueType.DISTRIB)
1749        .setDescription("Class distribution /LCOM4")
1750        .setDirection(Metric.DIRECTION_NONE)
1751        .setQualitative(true)
1752        .setDomain(DOMAIN_DESIGN)
1753        .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
1754        .setHidden(true)
1755        .create();
1756    
1757      /**
1758       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1759       */
1760      @Deprecated
1761      public static final String SUSPECT_LCOM4_DENSITY_KEY = "suspect_lcom4_density";
1762    
1763      /**
1764       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1765       */
1766      @Deprecated
1767      public static final Metric<Double> SUSPECT_LCOM4_DENSITY = new Metric.Builder(SUSPECT_LCOM4_DENSITY_KEY, "Suspect LCOM4 density", Metric.ValueType.PERCENT)
1768        .setDescription("Density of classes having LCOM4>1")
1769        .setDirection(Metric.DIRECTION_WORST)
1770        .setQualitative(true)
1771        .setDomain(DOMAIN_DESIGN)
1772        .setHidden(true)
1773        .create();
1774    
1775      /**
1776       * @deprecated since 3.7.1
1777       */
1778      @Deprecated
1779      public static final String AFFERENT_COUPLINGS_KEY = "ca";
1780      /**
1781       * @deprecated since 3.7.1
1782       */
1783      @Deprecated
1784      public static final Metric<Integer> AFFERENT_COUPLINGS = new Metric.Builder(AFFERENT_COUPLINGS_KEY, "Afferent couplings", Metric.ValueType.INT)
1785        .setDescription("Afferent couplings")
1786        .setDirection(Metric.DIRECTION_WORST)
1787        .setQualitative(false)
1788        .setDomain(DOMAIN_DESIGN)
1789        .setHidden(true)
1790        .create();
1791    
1792      /**
1793       * @deprecated since 3.7.1
1794       */
1795      @Deprecated
1796      public static final String EFFERENT_COUPLINGS_KEY = "ce";
1797      /**
1798       * @deprecated since 3.7.1
1799       */
1800      @Deprecated
1801      public static final Metric<Integer> EFFERENT_COUPLINGS = new Metric.Builder(EFFERENT_COUPLINGS_KEY, "Efferent couplings", Metric.ValueType.INT)
1802        .setDescription("Efferent couplings")
1803        .setDirection(Metric.DIRECTION_WORST)
1804        .setQualitative(false)
1805        .setDomain(DOMAIN_DESIGN)
1806        .setHidden(true)
1807        .create();
1808    
1809      public static final String DEPENDENCY_MATRIX_KEY = "dsm";
1810      public static final Metric<String> DEPENDENCY_MATRIX = new Metric.Builder(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", Metric.ValueType.DATA)
1811        .setDescription("Dependency Matrix")
1812        .setDirection(Metric.DIRECTION_NONE)
1813        .setQualitative(false)
1814        .setDomain(DOMAIN_DESIGN)
1815        .setDeleteHistoricalData(true)
1816        .create();
1817    
1818      public static final String PACKAGE_CYCLES_KEY = "package_cycles";
1819      public static final Metric<Integer> PACKAGE_CYCLES = new Metric.Builder(PACKAGE_CYCLES_KEY, "Package cycles", Metric.ValueType.INT)
1820        .setDescription("Package cycles")
1821        .setDirection(Metric.DIRECTION_WORST)
1822        .setQualitative(true)
1823        .setDomain(DOMAIN_DESIGN)
1824        .setBestValue(0.0)
1825        .setFormula(new SumChildValuesFormula(false))
1826        .create();
1827    
1828      public static final String PACKAGE_TANGLE_INDEX_KEY = "package_tangle_index";
1829      public static final Metric<Double> PACKAGE_TANGLE_INDEX = new Metric.Builder(PACKAGE_TANGLE_INDEX_KEY, "Package tangle index", Metric.ValueType.PERCENT)
1830        .setDescription("Package tangle index")
1831        .setDirection(Metric.DIRECTION_WORST)
1832        .setQualitative(true)
1833        .setBestValue(0.0)
1834        .setDomain(DOMAIN_DESIGN)
1835        .create();
1836    
1837      public static final String PACKAGE_TANGLES_KEY = "package_tangles";
1838      public static final Metric<Integer> PACKAGE_TANGLES = new Metric.Builder(PACKAGE_TANGLES_KEY, "File dependencies to cut", Metric.ValueType.INT)
1839        .setDescription("File dependencies to cut")
1840        .setDirection(Metric.DIRECTION_WORST)
1841        .setQualitative(false)
1842        .setDomain(DOMAIN_DESIGN)
1843        .setFormula(new SumChildValuesFormula(false))
1844        .create();
1845    
1846      public static final String PACKAGE_FEEDBACK_EDGES_KEY = "package_feedback_edges";
1847      public static final Metric<Integer> PACKAGE_FEEDBACK_EDGES = new Metric.Builder(PACKAGE_FEEDBACK_EDGES_KEY, "Package dependencies to cut", Metric.ValueType.INT)
1848        .setDescription("Package dependencies to cut")
1849        .setDirection(Metric.DIRECTION_WORST)
1850        .setQualitative(false)
1851        .setDomain(DOMAIN_DESIGN)
1852        .setFormula(new SumChildValuesFormula(false))
1853        .setBestValue(0.0)
1854        .create();
1855    
1856      public static final String PACKAGE_EDGES_WEIGHT_KEY = "package_edges_weight";
1857      public static final Metric<Integer> PACKAGE_EDGES_WEIGHT = new Metric.Builder(PACKAGE_EDGES_WEIGHT_KEY, "Package edges weight", Metric.ValueType.INT)
1858        .setDescription("Package edges weight")
1859        .setDirection(Metric.DIRECTION_BETTER)
1860        .setQualitative(false)
1861        .setDomain(DOMAIN_DESIGN)
1862        .setFormula(new SumChildValuesFormula(false))
1863        .setHidden(true)
1864        .setDeleteHistoricalData(true)
1865        .create();
1866    
1867      public static final String FILE_CYCLES_KEY = "file_cycles";
1868      public static final Metric<Integer> FILE_CYCLES = new Metric.Builder(FILE_CYCLES_KEY, "File cycles", Metric.ValueType.INT)
1869        .setDescription("File cycles")
1870        .setDirection(Metric.DIRECTION_WORST)
1871        .setQualitative(true)
1872        .setDomain(DOMAIN_DESIGN)
1873        .setHidden(true)
1874        .setDeleteHistoricalData(true)
1875        .setBestValue(0.0)
1876        .create();
1877    
1878      public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index";
1879      public static final Metric<Double> FILE_TANGLE_INDEX = new Metric.Builder(FILE_TANGLE_INDEX_KEY, "File tangle index", Metric.ValueType.PERCENT)
1880        .setDescription("File tangle index")
1881        .setDirection(Metric.DIRECTION_WORST)
1882        .setQualitative(true)
1883        .setDomain(DOMAIN_DESIGN)
1884        .setHidden(true)
1885        .setDeleteHistoricalData(true)
1886        .setBestValue(0.0)
1887        .create();
1888    
1889      public static final String FILE_TANGLES_KEY = "file_tangles";
1890      public static final Metric<Integer> FILE_TANGLES = new Metric.Builder(FILE_TANGLES_KEY, "File tangles", Metric.ValueType.INT)
1891        .setDescription("Files tangles")
1892        .setDirection(Metric.DIRECTION_WORST)
1893        .setQualitative(false)
1894        .setDomain(DOMAIN_DESIGN)
1895        .setHidden(true)
1896        .setDeleteHistoricalData(true)
1897        .create();
1898    
1899      public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges";
1900      public static final Metric<Integer> FILE_FEEDBACK_EDGES = new Metric.Builder(FILE_FEEDBACK_EDGES_KEY, "Suspect file dependencies", Metric.ValueType.INT)
1901        .setDescription("Suspect file dependencies")
1902        .setDirection(Metric.DIRECTION_WORST)
1903        .setQualitative(false)
1904        .setDomain(DOMAIN_DESIGN)
1905        .setHidden(true)
1906        .setDeleteHistoricalData(true)
1907        .setBestValue(0.0)
1908        .create();
1909    
1910      public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight";
1911      public static final Metric<Integer> FILE_EDGES_WEIGHT = new Metric.Builder(FILE_EDGES_WEIGHT_KEY, "File edges weight", Metric.ValueType.INT)
1912        .setDescription("File edges weight")
1913        .setDirection(Metric.DIRECTION_BETTER)
1914        .setQualitative(false)
1915        .setDomain(DOMAIN_DESIGN)
1916        .setHidden(true)
1917        .setDeleteHistoricalData(true)
1918        .create();
1919    
1920      // --------------------------------------------------------------------------------------------------------------------
1921      //
1922      // SCM
1923      // These metrics are computed by the SCM Activity plugin, since version 1.2 and introduced here since version 2.7.
1924      //
1925      // --------------------------------------------------------------------------------------------------------------------
1926    
1927      /**
1928       * @since 2.7
1929       */
1930      public static final String SCM_AUTHORS_BY_LINE_KEY = "authors_by_line";
1931    
1932      /**
1933       * Key-value pairs, where key - is a number of line, and value - is an author for this line.
1934       *
1935       * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map)
1936       * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String)
1937       * @since 2.7
1938       */
1939      public static final Metric<String> SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by line", Metric.ValueType.DATA)
1940        .setDomain(DOMAIN_SCM)
1941        .create();
1942    
1943      /**
1944       * @since 2.7
1945       */
1946      public static final String SCM_REVISIONS_BY_LINE_KEY = "revisions_by_line";
1947    
1948      /**
1949       * Key-value pairs, where key - is a number of line, and value - is a revision for this line.
1950       *
1951       * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map)
1952       * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String)
1953       * @since 2.7
1954       */
1955      public static final Metric<String> SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by line", Metric.ValueType.DATA)
1956        .setDomain(DOMAIN_SCM)
1957        .create();
1958    
1959      /**
1960       * @since 2.7
1961       */
1962      public static final String SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY = "last_commit_datetimes_by_line";
1963    
1964      /**
1965       * Key-value pairs, where key - is a number of line, and value - is a date of last commit for this line.
1966       *
1967       * @see org.sonar.api.utils.KeyValueFormat#formatIntDateTime(java.util.Map)
1968       * @see org.sonar.api.utils.KeyValueFormat#parseIntDateTime(String)
1969       * @since 2.7
1970       */
1971      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",
1972        Metric.ValueType.DATA)
1973        .setDomain(DOMAIN_SCM)
1974        .create();
1975    
1976      // --------------------------------------------------------------------------------------------------------------------
1977      //
1978      // REVIEWS (since 2.14)
1979      //
1980      // --------------------------------------------------------------------------------------------------------------------
1981    
1982      /**
1983       * @since 2.14
1984       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
1985       */
1986      @Deprecated
1987      public static final String UNREVIEWED_VIOLATIONS_KEY = "unreviewed_violations";
1988    
1989      /**
1990       * @since 2.14
1991       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
1992       */
1993      @Deprecated
1994      public static final Metric<Integer> UNREVIEWED_VIOLATIONS = new Metric.Builder(UNREVIEWED_VIOLATIONS_KEY, "Unreviewed violations", Metric.ValueType.INT)
1995        .setDescription("Violations that have not been reviewed yet")
1996        .setDirection(Metric.DIRECTION_WORST)
1997        .setDomain(DOMAIN_REVIEWS)
1998        .setBestValue(0.0)
1999        .setOptimizedBestValue(true)
2000        .setHidden(true)
2001        .create();
2002    
2003      /**
2004       * @since 2.14
2005       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2006       */
2007      @Deprecated
2008      public static final String NEW_UNREVIEWED_VIOLATIONS_KEY = "new_unreviewed_violations";
2009    
2010      /**
2011       * @since 2.14
2012       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2013       */
2014      @Deprecated
2015      public static final Metric<Integer> NEW_UNREVIEWED_VIOLATIONS = new Metric.Builder(NEW_UNREVIEWED_VIOLATIONS_KEY, "New unreviewed violations", Metric.ValueType.INT)
2016        .setDescription("New violations that have not been reviewed yet")
2017        .setDirection(Metric.DIRECTION_WORST)
2018        .setQualitative(true)
2019        .setDomain(DOMAIN_REVIEWS)
2020        .setBestValue(0.0)
2021        .setOptimizedBestValue(true)
2022        .setDeleteHistoricalData(true)
2023        .setHidden(true)
2024        .create();
2025    
2026      /**
2027       * @since 2.14
2028       * @deprecated in 3.6. This measure is replaced by {@link #FALSE_POSITIVE_ISSUES_KEY}.
2029       */
2030      @Deprecated
2031      public static final String FALSE_POSITIVE_REVIEWS_KEY = "false_positive_reviews";
2032    
2033      /**
2034       * @since 2.14
2035       * @deprecated in 3.6. This measure is replaced by {@link #FALSE_POSITIVE_ISSUES}.
2036       */
2037      @Deprecated
2038      public static final Metric<Integer> FALSE_POSITIVE_REVIEWS = new Metric.Builder(FALSE_POSITIVE_REVIEWS_KEY, "False-positive reviews", Metric.ValueType.INT)
2039        .setDescription("Active false-positive reviews")
2040        .setDirection(Metric.DIRECTION_WORST)
2041        .setDomain(DOMAIN_REVIEWS)
2042        .setBestValue(0.0)
2043        .setOptimizedBestValue(true)
2044        .setHidden(true)
2045        .create();
2046    
2047      /**
2048       * @since 2.14
2049       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2050       */
2051      @Deprecated
2052      public static final String ACTIVE_REVIEWS_KEY = "active_reviews";
2053    
2054      /**
2055       * @since 2.14
2056       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2057       */
2058      @Deprecated
2059      public static final Metric<Integer> ACTIVE_REVIEWS = new Metric.Builder(ACTIVE_REVIEWS_KEY, "Active reviews", Metric.ValueType.INT)
2060        .setDescription("Active open and reopened reviews")
2061        .setDirection(Metric.DIRECTION_WORST)
2062        .setDomain(DOMAIN_REVIEWS)
2063        .setBestValue(0.0)
2064        .setOptimizedBestValue(true)
2065        .setHidden(true)
2066        .create();
2067    
2068      /**
2069       * @since 2.14
2070       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2071       */
2072      @Deprecated
2073      public static final String UNASSIGNED_REVIEWS_KEY = "unassigned_reviews";
2074    
2075      /**
2076       * @since 2.14
2077       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2078       */
2079      @Deprecated
2080      public static final Metric<Integer> UNASSIGNED_REVIEWS = new Metric.Builder(UNASSIGNED_REVIEWS_KEY, "Unassigned reviews", Metric.ValueType.INT)
2081        .setDescription("Active unassigned reviews")
2082        .setDirection(Metric.DIRECTION_WORST)
2083        .setDomain(DOMAIN_REVIEWS)
2084        .setBestValue(0.0)
2085        .setOptimizedBestValue(true)
2086        .setHidden(true)
2087        .create();
2088    
2089      /**
2090       * @since 2.14
2091       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2092       */
2093      @Deprecated
2094      public static final String UNPLANNED_REVIEWS_KEY = "unplanned_reviews";
2095    
2096      /**
2097       * @since 2.14
2098       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2099       */
2100      @Deprecated
2101      public static final Metric<Integer> UNPLANNED_REVIEWS = new Metric.Builder(UNPLANNED_REVIEWS_KEY, "Unplanned reviews", Metric.ValueType.INT)
2102        .setDescription("Active unplanned reviews")
2103        .setDirection(Metric.DIRECTION_WORST)
2104        .setDomain(DOMAIN_REVIEWS)
2105        .setBestValue(0.0)
2106        .setOptimizedBestValue(true)
2107        .setHidden(true)
2108        .create();
2109    
2110      // --------------------------------------------------------------------------------------------------------------------
2111      //
2112      // TECHNICAL DEBT
2113      //
2114      // --------------------------------------------------------------------------------------------------------------------
2115    
2116      /**
2117       * @since 4.0
2118       */
2119      public static final String TECHNICAL_DEBT_KEY = "sqale_index";
2120    
2121      /**
2122       * @since 4.0
2123       */
2124      public static final Metric<Long> TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR)
2125        .setDomain(DOMAIN_TECHNICAL_DEBT)
2126        .setDirection(Metric.DIRECTION_WORST)
2127        .setOptimizedBestValue(true)
2128        .setBestValue(0.0)
2129        .setQualitative(true)
2130        .create();
2131    
2132      /**
2133       * @since 4.1
2134       */
2135      public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt";
2136    
2137      /**
2138       * @since 4.1
2139       */
2140      public static final Metric<Long> NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Technical Debt on new code", Metric.ValueType.WORK_DUR)
2141        .setDescription("Technical Debt of new code")
2142        .setDomain(DOMAIN_TECHNICAL_DEBT)
2143        .setDirection(Metric.DIRECTION_WORST)
2144        .setOptimizedBestValue(true)
2145        .setBestValue(0.0)
2146        .setQualitative(true)
2147        .setDeleteHistoricalData(true)
2148        .create();
2149    
2150      /**
2151       * @since 4.5
2152       */
2153      public static final String SQALE_RATING_KEY = "sqale_rating";
2154    
2155      /**
2156       * @since 4.5
2157       */
2158      public static final Metric<String> SQALE_RATING = new Metric.Builder(SQALE_RATING_KEY, "SQALE Rating", Metric.ValueType.RATING)
2159        .setDomain(DOMAIN_TECHNICAL_DEBT)
2160        .setDirection(Metric.DIRECTION_WORST)
2161        .setQualitative(true)
2162        .setBestValue(1.0)
2163        .setWorstValue(5.0)
2164        .create();
2165    
2166      /**
2167       * @since 4.5
2168       */
2169      public static final String DEVELOPMENT_COST_KEY = "development_cost";
2170    
2171      /**
2172       * @since 4.5
2173       */
2174      public static final Metric<String> DEVELOPMENT_COST = new Metric.Builder(DEVELOPMENT_COST_KEY, "SQALE Development Cost", Metric.ValueType.STRING)
2175        .setDomain(DOMAIN_TECHNICAL_DEBT)
2176        .setDirection(Metric.DIRECTION_WORST)
2177        .setOptimizedBestValue(true)
2178        .setBestValue(0.0)
2179        .setQualitative(true)
2180        .setHidden(true)
2181        .create();
2182    
2183      /**
2184       * @since 4.5
2185       */
2186      public static final String SQALE_DEBT_RATIO_KEY = "sqale_debt_ratio";
2187    
2188      /**
2189       * @since 4.5
2190       */
2191      public static final Metric<Double> SQALE_DEBT_RATIO = new Metric.Builder(SQALE_DEBT_RATIO_KEY, "SQALE Technical Debt Ratio", Metric.ValueType.PERCENT)
2192        .setDescription("Ratio of the technical debt compared to what it would cost to develop the whole source code from scratch.")
2193        .setDomain(DOMAIN_TECHNICAL_DEBT)
2194        .setDirection(Metric.DIRECTION_WORST)
2195        .setOptimizedBestValue(true)
2196        .setBestValue(0.0)
2197        .setQualitative(true)
2198        .create();
2199    
2200      // --------------------------------------------------------------------------------------------------------------------
2201      //
2202      // FILE DATA
2203      //
2204      // --------------------------------------------------------------------------------------------------------------------
2205    
2206      /**
2207       * @since 2.14
2208       */
2209      @Beta
2210      public static final String NCLOC_DATA_KEY = "ncloc_data";
2211    
2212      /**
2213       * Information about lines of code in file.
2214       * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains code (1) or not (0).
2215       *
2216       * @see org.sonar.api.measures.FileLinesContext
2217       * @since 2.14
2218       */
2219      @Beta
2220      public static final Metric<String> NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA)
2221        .setHidden(true)
2222        .setDomain(DOMAIN_SIZE)
2223        .create();
2224    
2225      /**
2226       * @since 2.14
2227       */
2228      @Beta
2229      public static final String COMMENT_LINES_DATA_KEY = "comment_lines_data";
2230    
2231      /**
2232       * Information about comments in file.
2233       * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains comment (1) or not (0).
2234       *
2235       * @see org.sonar.api.measures.FileLinesContext
2236       * @since 2.14
2237       */
2238      @Beta
2239      public static final Metric<String> COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA)
2240        .setHidden(true)
2241        .setDomain(DOMAIN_DOCUMENTATION)
2242        .create();
2243    
2244      // --------------------------------------------------------------------------------------------------------------------
2245      //
2246      // OTHERS
2247      //
2248      // --------------------------------------------------------------------------------------------------------------------
2249    
2250      public static final String ALERT_STATUS_KEY = "alert_status";
2251      public static final Metric<Metric.Level> ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Quality Gate Status", Metric.ValueType.LEVEL)
2252        .setDescription("The project status with regard to its quality gate.")
2253        .setDirection(Metric.DIRECTION_BETTER)
2254        .setQualitative(true)
2255        .setDomain(DOMAIN_GENERAL)
2256        .create();
2257    
2258      /**
2259       * @since 4.4
2260       */
2261      public static final String QUALITY_GATE_DETAILS_KEY = "quality_gate_details";
2262      /**
2263       * The project detailed status with regard to its quality gate.
2264       * Storing the global quality gate status, along with all evaluated conditions, into a JSON object.
2265       * @since 4.4
2266       */
2267      public static final Metric<String> QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA)
2268        .setDescription("The project detailed status with regard to its quality gate.")
2269        .setDomain(DOMAIN_GENERAL)
2270        .create();
2271    
2272      /**
2273       * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY}
2274       */
2275      @Deprecated
2276      public static final String PROFILE_KEY = "profile";
2277      /**
2278       * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY}
2279       */
2280      @Deprecated
2281      public static final Metric<String> PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA)
2282        .setDescription("Selected quality profile")
2283        .setDomain(DOMAIN_GENERAL)
2284        .create();
2285    
2286      /**
2287       * @since 2.9
2288       * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY}
2289       */
2290      @Deprecated
2291      public static final String PROFILE_VERSION_KEY = "profile_version";
2292      /**
2293       * @since 2.9
2294       * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY}
2295       */
2296      @Deprecated
2297      public static final Metric<Integer> PROFILE_VERSION = new Metric.Builder(PROFILE_VERSION_KEY, "Profile version", Metric.ValueType.INT)
2298        .setDescription("Selected quality profile version")
2299        .setQualitative(false)
2300        .setDomain(DOMAIN_GENERAL)
2301        .setHidden(true)
2302        .create();
2303    
2304      /**
2305       * @since 4.4
2306       */
2307      public static final String QUALITY_PROFILES_KEY = "quality_profiles";
2308    
2309      /**
2310       * @since 4.4
2311       */
2312      public static final Metric<String> QUALITY_PROFILES = new Metric.Builder(QUALITY_PROFILES_KEY, "Profiles", Metric.ValueType.DATA)
2313        .setDescription("Details of quality profiles used during analysis")
2314        .setQualitative(false)
2315        .setDomain(DOMAIN_GENERAL)
2316        .setHidden(true)
2317        .create();
2318    
2319      private static final List<Metric> METRICS;
2320    
2321      static {
2322        METRICS = Lists.newLinkedList();
2323        for (Field field : CoreMetrics.class.getFields()) {
2324          if (Metric.class.isAssignableFrom(field.getType())) {
2325            try {
2326              Metric metric = (Metric) field.get(null);
2327              METRICS.add(metric);
2328            } catch (IllegalAccessException e) {
2329              throw new SonarException("can not introspect " + CoreMetrics.class + " to get metrics", e);
2330            }
2331          }
2332        }
2333      }
2334    
2335      private CoreMetrics() {
2336        // only static stuff
2337      }
2338    
2339      public static List<Metric> getMetrics() {
2340        return METRICS;
2341      }
2342    
2343      public static Metric getMetric(final String key) {
2344        return Iterables.find(METRICS, new Predicate<Metric>() {
2345          @Override
2346          public boolean apply(@Nullable Metric input) {
2347            return input != null && input.getKey().equals(key);
2348          }
2349        });
2350      }
2351    }