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, "Branch coverage", Metric.ValueType.PERCENT)
650        .setDescription("Branch 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, "Branch coverage on new code", Metric.ValueType.PERCENT)
660        .setDescription("Branch 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 branch coverage", Metric.ValueType.PERCENT)
926        .setDescription("IT Branch 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, "Branch coverage by IT on new code", Metric.ValueType.PERCENT)
943        .setDescription("Branch 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 branches 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 branches 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 branch coverage", Metric.ValueType.PERCENT)
1213        .setDescription("Branch 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 branch coverage on new code",
1230        Metric.ValueType.PERCENT)
1231        .setDescription("Branch 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 branches by line", Metric.ValueType.DATA)
1249        .setDescription("Overall branches 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      public static final String DUPLICATIONS_DATA_KEY = "duplications_data";
1322    
1323      /**
1324       * Information about duplications, which is represented as an XML string.
1325       * <p>
1326       * Here is the format (since Sonar 2.12):
1327       * <pre>
1328       *   <duplications>
1329       *     <!-- Multiple groups: -->
1330       *     <g>
1331       *       <!-- Multiple blocks: -->
1332       *       <b r="[resource key]" s="[first line]" l="[number of lines]" />
1333       *       ...
1334       *     </g>
1335       *     ...
1336       *   </duplications>
1337       * </pre>
1338       * </p>
1339       */
1340      public static final Metric<String> DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplications details", Metric.ValueType.DATA)
1341        .setDescription("Duplications details")
1342        .setDirection(Metric.DIRECTION_NONE)
1343        .setQualitative(false)
1344        .setDomain(DOMAIN_DUPLICATION)
1345        .setDeleteHistoricalData(true)
1346        .create();
1347    
1348      // --------------------------------------------------------------------------------------------------------------------
1349      //
1350      // CODING RULES
1351      //
1352      // --------------------------------------------------------------------------------------------------------------------
1353    
1354      public static final String WEIGHTED_VIOLATIONS_KEY = "weighted_violations";
1355    
1356      public static final Metric<Integer> WEIGHTED_VIOLATIONS = new Metric.Builder(WEIGHTED_VIOLATIONS_KEY, "Weighted issues", Metric.ValueType.INT)
1357        .setDescription("Weighted Issues")
1358        .setDirection(Metric.DIRECTION_WORST)
1359        .setQualitative(true)
1360        .setDomain(DOMAIN_ISSUES)
1361        .setBestValue(0.0)
1362        .setOptimizedBestValue(true)
1363        .create();
1364    
1365      /**
1366       * @deprecated since 4.0. See SONAR-4755
1367       */
1368      @Deprecated
1369      public static final String VIOLATIONS_DENSITY_KEY = "violations_density";
1370    
1371      /**
1372       * @deprecated since 4.0. See SONAR-4755
1373       */
1374      @Deprecated
1375      public static final Metric<Double> VIOLATIONS_DENSITY = new Metric.Builder(VIOLATIONS_DENSITY_KEY, "Rules compliance", Metric.ValueType.PERCENT)
1376        .setDescription("Rules compliance")
1377        .setDirection(Metric.DIRECTION_BETTER)
1378        .setQualitative(true)
1379        .setDomain(DOMAIN_ISSUES)
1380        .setHidden(true)
1381        .create();
1382    
1383      public static final String VIOLATIONS_KEY = "violations";
1384      public static final Metric<Integer> VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT)
1385        .setDescription("Issues")
1386        .setDirection(Metric.DIRECTION_WORST)
1387        .setQualitative(true)
1388        .setDomain(DOMAIN_ISSUES)
1389        .setBestValue(0.0)
1390        .setOptimizedBestValue(true)
1391        .create();
1392    
1393      public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations";
1394      public static final Metric<Integer> BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker issues", Metric.ValueType.INT)
1395        .setDescription("Blocker issues")
1396        .setDirection(Metric.DIRECTION_WORST)
1397        .setQualitative(true)
1398        .setDomain(DOMAIN_ISSUES)
1399        .setBestValue(0.0)
1400        .setOptimizedBestValue(true)
1401        .create();
1402    
1403      public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations";
1404      public static final Metric<Integer> CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical issues", Metric.ValueType.INT)
1405        .setDescription("Critical issues")
1406        .setDirection(Metric.DIRECTION_WORST)
1407        .setQualitative(true)
1408        .setDomain(DOMAIN_ISSUES)
1409        .setBestValue(0.0)
1410        .setOptimizedBestValue(true)
1411        .create();
1412    
1413      public static final String MAJOR_VIOLATIONS_KEY = "major_violations";
1414      public static final Metric<Integer> MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major issues", Metric.ValueType.INT)
1415        .setDescription("Major issues")
1416        .setDirection(Metric.DIRECTION_WORST)
1417        .setQualitative(true)
1418        .setDomain(DOMAIN_ISSUES)
1419        .setBestValue(0.0)
1420        .setOptimizedBestValue(true)
1421        .create();
1422    
1423      public static final String MINOR_VIOLATIONS_KEY = "minor_violations";
1424      public static final Metric<Integer> MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor issues", Metric.ValueType.INT)
1425        .setDescription("Minor issues")
1426        .setDirection(Metric.DIRECTION_WORST)
1427        .setQualitative(true)
1428        .setDomain(DOMAIN_ISSUES)
1429        .setBestValue(0.0)
1430        .setOptimizedBestValue(true)
1431        .create();
1432    
1433      public static final String INFO_VIOLATIONS_KEY = "info_violations";
1434      public static final Metric<Integer> INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info issues", Metric.ValueType.INT)
1435        .setDescription("Info issues")
1436        .setDirection(Metric.DIRECTION_WORST)
1437        .setQualitative(true)
1438        .setDomain(DOMAIN_ISSUES)
1439        .setBestValue(0.0)
1440        .setOptimizedBestValue(true)
1441        .create();
1442    
1443      public static final String NEW_VIOLATIONS_KEY = "new_violations";
1444      public static final Metric<Integer> NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New issues", Metric.ValueType.INT)
1445        .setDescription("New Issues")
1446        .setDirection(Metric.DIRECTION_WORST)
1447        .setQualitative(true)
1448        .setDomain(DOMAIN_ISSUES)
1449        .setBestValue(0.0)
1450        .setOptimizedBestValue(true)
1451        .setDeleteHistoricalData(true)
1452        .create();
1453    
1454      public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations";
1455      public static final Metric<Integer> NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker issues", Metric.ValueType.INT)
1456        .setDescription("New Blocker issues")
1457        .setDirection(Metric.DIRECTION_WORST)
1458        .setQualitative(true)
1459        .setDomain(DOMAIN_ISSUES)
1460        .setBestValue(0.0)
1461        .setOptimizedBestValue(true)
1462        .setDeleteHistoricalData(true)
1463        .create();
1464    
1465      public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations";
1466      public static final Metric<Integer> NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical issues", Metric.ValueType.INT)
1467        .setDescription("New Critical issues")
1468        .setDirection(Metric.DIRECTION_WORST)
1469        .setQualitative(true)
1470        .setDomain(DOMAIN_ISSUES)
1471        .setBestValue(0.0)
1472        .setOptimizedBestValue(true)
1473        .setDeleteHistoricalData(true)
1474        .create();
1475    
1476      public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations";
1477      public static final Metric<Integer> NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major issues", Metric.ValueType.INT)
1478        .setDescription("New Major issues")
1479        .setDirection(Metric.DIRECTION_WORST)
1480        .setQualitative(true)
1481        .setDomain(DOMAIN_ISSUES)
1482        .setBestValue(0.0)
1483        .setOptimizedBestValue(true)
1484        .setDeleteHistoricalData(true)
1485        .create();
1486    
1487      public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations";
1488      public static final Metric<Integer> NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor issues", Metric.ValueType.INT)
1489        .setDescription("New Minor issues")
1490        .setDirection(Metric.DIRECTION_WORST)
1491        .setQualitative(true)
1492        .setDomain(DOMAIN_ISSUES)
1493        .setBestValue(0.0)
1494        .setOptimizedBestValue(true)
1495        .setDeleteHistoricalData(true)
1496        .create();
1497    
1498      public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations";
1499      public static final Metric<Integer> NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info issues", Metric.ValueType.INT)
1500        .setDescription("New Info issues")
1501        .setDirection(Metric.DIRECTION_WORST)
1502        .setQualitative(true)
1503        .setDomain(DOMAIN_ISSUES)
1504        .setBestValue(0.0)
1505        .setOptimizedBestValue(true)
1506        .setDeleteHistoricalData(true)
1507        .create();
1508    
1509      /**
1510       * @since 3.6
1511       */
1512      public static final String FALSE_POSITIVE_ISSUES_KEY = "false_positive_issues";
1513    
1514      /**
1515       * @since 3.6
1516       */
1517      public static final Metric<Integer> FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False positive issues", Metric.ValueType.INT)
1518        .setDescription("False positive issues")
1519        .setDirection(Metric.DIRECTION_WORST)
1520        .setDomain(DOMAIN_ISSUES)
1521        .setBestValue(0.0)
1522        .setOptimizedBestValue(true)
1523        .create();
1524    
1525      /**
1526       * @since 3.6
1527       */
1528      public static final String OPEN_ISSUES_KEY = "open_issues";
1529    
1530      /**
1531       * @since 3.6
1532       */
1533      public static final Metric<Integer> OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open issues", Metric.ValueType.INT)
1534        .setDescription("Open issues")
1535        .setDirection(Metric.DIRECTION_WORST)
1536        .setDomain(DOMAIN_ISSUES)
1537        .setBestValue(0.0)
1538        .setOptimizedBestValue(true)
1539        .create();
1540    
1541      /**
1542       * @since 3.6
1543       */
1544      public static final String REOPENED_ISSUES_KEY = "reopened_issues";
1545    
1546      /**
1547       * @since 3.6
1548       */
1549      public static final Metric<Integer> REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened issues", Metric.ValueType.INT)
1550        .setDescription("Reopened issues")
1551        .setDirection(Metric.DIRECTION_WORST)
1552        .setQualitative(true)
1553        .setDomain(DOMAIN_ISSUES)
1554        .setBestValue(0.0)
1555        .setOptimizedBestValue(true)
1556        .create();
1557    
1558      /**
1559       * @since 3.6
1560       */
1561      public static final String CONFIRMED_ISSUES_KEY = "confirmed_issues";
1562    
1563      /**
1564       * @since 3.6
1565       */
1566      public static final Metric<Integer> CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed issues", Metric.ValueType.INT)
1567        .setDescription("Confirmed issues")
1568        .setDirection(Metric.DIRECTION_WORST)
1569        .setQualitative(true)
1570        .setDomain(DOMAIN_ISSUES)
1571        .setBestValue(0.0)
1572        .setOptimizedBestValue(true)
1573        .create();
1574    
1575      // --------------------------------------------------------------------------------------------------------------------
1576      //
1577      // DESIGN
1578      //
1579      // --------------------------------------------------------------------------------------------------------------------
1580    
1581      /**
1582       * @deprecated since 3.7.1
1583       */
1584      @Deprecated
1585      public static final String ABSTRACTNESS_KEY = "abstractness";
1586      /**
1587       * @deprecated since 3.7.1
1588       */
1589      @Deprecated
1590      public static final Metric<Double> ABSTRACTNESS = new Metric.Builder(ABSTRACTNESS_KEY, "Abstractness", Metric.ValueType.PERCENT)
1591        .setDescription("Abstractness")
1592        .setDirection(Metric.DIRECTION_NONE)
1593        .setQualitative(false)
1594        .setDomain(DOMAIN_DESIGN)
1595        .setHidden(true)
1596        .create();
1597    
1598      /**
1599       * @deprecated since 3.7.1
1600       */
1601      @Deprecated
1602      public static final String INSTABILITY_KEY = "instability";
1603      /**
1604       * @deprecated since 3.7.1
1605       */
1606      @Deprecated
1607      public static final Metric<Double> INSTABILITY = new Metric.Builder(INSTABILITY_KEY, "Instability", Metric.ValueType.PERCENT)
1608        .setDescription("Instability")
1609        .setDirection(Metric.DIRECTION_NONE)
1610        .setQualitative(false)
1611        .setDomain(DOMAIN_DESIGN)
1612        .setHidden(true)
1613        .create();
1614    
1615      /**
1616       * @deprecated since 3.7.1
1617       */
1618      @Deprecated
1619      public static final String DISTANCE_KEY = "distance";
1620      /**
1621       * @deprecated since 3.7.1
1622       */
1623      @Deprecated
1624      public static final Metric<Double> DISTANCE = new Metric.Builder(DISTANCE_KEY, "Distance", Metric.ValueType.FLOAT)
1625        .setDescription("Distance")
1626        .setDirection(Metric.DIRECTION_NONE)
1627        .setQualitative(false)
1628        .setDomain(DOMAIN_DESIGN)
1629        .setHidden(true)
1630        .create();
1631    
1632      /**
1633       * @deprecated since 4.0. See SONAR-4643
1634       */
1635      @Deprecated
1636      public static final String DEPTH_IN_TREE_KEY = "dit";
1637      /**
1638       * @deprecated since 4.0. See SONAR-4643
1639       */
1640      @Deprecated
1641      public static final Metric<Integer> DEPTH_IN_TREE = new Metric.Builder(DEPTH_IN_TREE_KEY, "Depth in Tree", Metric.ValueType.INT)
1642        .setDescription("Depth in Inheritance Tree")
1643        .setDirection(Metric.DIRECTION_NONE)
1644        .setQualitative(false)
1645        .setDomain(DOMAIN_DESIGN)
1646        .setHidden(true)
1647        .create();
1648    
1649      /**
1650       * @deprecated since 4.0. See SONAR-4643
1651       */
1652      @Deprecated
1653      public static final String NUMBER_OF_CHILDREN_KEY = "noc";
1654      /**
1655       * @deprecated since 4.0. See SONAR-4643
1656       */
1657      @Deprecated
1658      public static final Metric<Integer> NUMBER_OF_CHILDREN = new Metric.Builder(NUMBER_OF_CHILDREN_KEY, "Number of Children", Metric.ValueType.INT)
1659        .setDescription("Number of Children")
1660        .setDirection(Metric.DIRECTION_NONE)
1661        .setQualitative(false)
1662        .setDomain(DOMAIN_DESIGN)
1663        .setHidden(true)
1664        .create();
1665    
1666      /**
1667       * @deprecated since 4.2. See SONAR-5042
1668       */
1669      @Deprecated
1670      public static final String RFC_KEY = "rfc";
1671    
1672      /**
1673       * @deprecated since 4.2. See SONAR-5042
1674       */
1675      @Deprecated
1676      public static final Metric<Integer> RFC = new Metric.Builder(RFC_KEY, "RFC", Metric.ValueType.INT)
1677        .setDescription("Response for Class")
1678        .setDirection(Metric.DIRECTION_WORST)
1679        .setQualitative(false)
1680        .setDomain(DOMAIN_DESIGN)
1681        .setFormula(new WeightedMeanAggregationFormula(CoreMetrics.FILES, false))
1682        .setHidden(true)
1683        .create();
1684    
1685      /**
1686       * @deprecated since 4.2. See SONAR-5042
1687       */
1688      @Deprecated
1689      public static final String RFC_DISTRIBUTION_KEY = "rfc_distribution";
1690    
1691      /**
1692       * @deprecated since 4.2. See SONAR-5042
1693       */
1694      @Deprecated
1695      public static final Metric<String> RFC_DISTRIBUTION = new Metric.Builder(RFC_DISTRIBUTION_KEY, "Class distribution /RFC", Metric.ValueType.DISTRIB)
1696        .setDescription("Class distribution /RFC")
1697        .setDirection(Metric.DIRECTION_NONE)
1698        .setQualitative(true)
1699        .setDomain(DOMAIN_DESIGN)
1700        .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
1701        .setHidden(true)
1702        .create();
1703    
1704      /**
1705       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1706       */
1707      @Deprecated
1708      public static final String LCOM4_KEY = "lcom4";
1709    
1710      /**
1711       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1712       */
1713      @Deprecated
1714      public static final Metric<Double> LCOM4 = new Metric.Builder(LCOM4_KEY, "LCOM4", Metric.ValueType.FLOAT)
1715        .setDescription("Lack of Cohesion of Functions")
1716        .setDirection(Metric.DIRECTION_WORST)
1717        .setQualitative(true)
1718        .setDomain(DOMAIN_DESIGN)
1719        .setBestValue(1.0)
1720        .setHidden(true)
1721        .create();
1722    
1723      /**
1724       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1725       */
1726      @Deprecated
1727      public static final String LCOM4_BLOCKS_KEY = "lcom4_blocks";
1728    
1729      /**
1730       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1731       */
1732      @Deprecated
1733      public static final Metric<String> LCOM4_BLOCKS = new Metric.Builder(LCOM4_BLOCKS_KEY, "LCOM4 blocks", Metric.ValueType.DATA)
1734        .setDescription("LCOM4 blocks")
1735        .setDirection(Metric.DIRECTION_NONE)
1736        .setQualitative(false)
1737        .setDomain(DOMAIN_DESIGN)
1738        .setDeleteHistoricalData(true)
1739        .setHidden(true)
1740        .create();
1741    
1742      /**
1743       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1744       */
1745      @Deprecated
1746      public static final String LCOM4_DISTRIBUTION_KEY = "lcom4_distribution";
1747    
1748      /**
1749       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1750       */
1751      @Deprecated
1752      public static final Metric<String> LCOM4_DISTRIBUTION = new Metric.Builder(LCOM4_DISTRIBUTION_KEY, "Class distribution /LCOM4", Metric.ValueType.DISTRIB)
1753        .setDescription("Class distribution /LCOM4")
1754        .setDirection(Metric.DIRECTION_NONE)
1755        .setQualitative(true)
1756        .setDomain(DOMAIN_DESIGN)
1757        .setFormula(new SumChildDistributionFormula().setMinimumScopeToPersist(Scopes.DIRECTORY))
1758        .setHidden(true)
1759        .create();
1760    
1761      /**
1762       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1763       */
1764      @Deprecated
1765      public static final String SUSPECT_LCOM4_DENSITY_KEY = "suspect_lcom4_density";
1766    
1767      /**
1768       * @deprecated in 4.1. See http://jira.codehaus.org/browse/SONAR-4853
1769       */
1770      @Deprecated
1771      public static final Metric<Double> SUSPECT_LCOM4_DENSITY = new Metric.Builder(SUSPECT_LCOM4_DENSITY_KEY, "Suspect LCOM4 density", Metric.ValueType.PERCENT)
1772        .setDescription("Density of classes having LCOM4>1")
1773        .setDirection(Metric.DIRECTION_WORST)
1774        .setQualitative(true)
1775        .setDomain(DOMAIN_DESIGN)
1776        .setHidden(true)
1777        .create();
1778    
1779      /**
1780       * @deprecated since 3.7.1
1781       */
1782      @Deprecated
1783      public static final String AFFERENT_COUPLINGS_KEY = "ca";
1784      /**
1785       * @deprecated since 3.7.1
1786       */
1787      @Deprecated
1788      public static final Metric<Integer> AFFERENT_COUPLINGS = new Metric.Builder(AFFERENT_COUPLINGS_KEY, "Afferent couplings", Metric.ValueType.INT)
1789        .setDescription("Afferent couplings")
1790        .setDirection(Metric.DIRECTION_WORST)
1791        .setQualitative(false)
1792        .setDomain(DOMAIN_DESIGN)
1793        .setHidden(true)
1794        .create();
1795    
1796      /**
1797       * @deprecated since 3.7.1
1798       */
1799      @Deprecated
1800      public static final String EFFERENT_COUPLINGS_KEY = "ce";
1801      /**
1802       * @deprecated since 3.7.1
1803       */
1804      @Deprecated
1805      public static final Metric<Integer> EFFERENT_COUPLINGS = new Metric.Builder(EFFERENT_COUPLINGS_KEY, "Efferent couplings", Metric.ValueType.INT)
1806        .setDescription("Efferent couplings")
1807        .setDirection(Metric.DIRECTION_WORST)
1808        .setQualitative(false)
1809        .setDomain(DOMAIN_DESIGN)
1810        .setHidden(true)
1811        .create();
1812    
1813      public static final String DEPENDENCY_MATRIX_KEY = "dsm";
1814      public static final Metric<String> DEPENDENCY_MATRIX = new Metric.Builder(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", Metric.ValueType.DATA)
1815        .setDescription("Dependency Matrix")
1816        .setDirection(Metric.DIRECTION_NONE)
1817        .setQualitative(false)
1818        .setDomain(DOMAIN_DESIGN)
1819        .setDeleteHistoricalData(true)
1820        .create();
1821    
1822      public static final String PACKAGE_CYCLES_KEY = "package_cycles";
1823      public static final Metric<Integer> PACKAGE_CYCLES = new Metric.Builder(PACKAGE_CYCLES_KEY, "Package cycles", Metric.ValueType.INT)
1824        .setDescription("Package cycles")
1825        .setDirection(Metric.DIRECTION_WORST)
1826        .setQualitative(true)
1827        .setDomain(DOMAIN_DESIGN)
1828        .setBestValue(0.0)
1829        .setFormula(new SumChildValuesFormula(false))
1830        .create();
1831    
1832      public static final String PACKAGE_TANGLE_INDEX_KEY = "package_tangle_index";
1833      public static final Metric<Double> PACKAGE_TANGLE_INDEX = new Metric.Builder(PACKAGE_TANGLE_INDEX_KEY, "Package tangle index", Metric.ValueType.PERCENT)
1834        .setDescription("Package tangle index")
1835        .setDirection(Metric.DIRECTION_WORST)
1836        .setQualitative(true)
1837        .setBestValue(0.0)
1838        .setDomain(DOMAIN_DESIGN)
1839        .create();
1840    
1841      public static final String PACKAGE_TANGLES_KEY = "package_tangles";
1842      public static final Metric<Integer> PACKAGE_TANGLES = new Metric.Builder(PACKAGE_TANGLES_KEY, "File dependencies to cut", Metric.ValueType.INT)
1843        .setDescription("File dependencies to cut")
1844        .setDirection(Metric.DIRECTION_WORST)
1845        .setQualitative(false)
1846        .setDomain(DOMAIN_DESIGN)
1847        .setFormula(new SumChildValuesFormula(false))
1848        .create();
1849    
1850      public static final String PACKAGE_FEEDBACK_EDGES_KEY = "package_feedback_edges";
1851      public static final Metric<Integer> PACKAGE_FEEDBACK_EDGES = new Metric.Builder(PACKAGE_FEEDBACK_EDGES_KEY, "Package dependencies to cut", Metric.ValueType.INT)
1852        .setDescription("Package dependencies to cut")
1853        .setDirection(Metric.DIRECTION_WORST)
1854        .setQualitative(false)
1855        .setDomain(DOMAIN_DESIGN)
1856        .setFormula(new SumChildValuesFormula(false))
1857        .setBestValue(0.0)
1858        .create();
1859    
1860      public static final String PACKAGE_EDGES_WEIGHT_KEY = "package_edges_weight";
1861      public static final Metric<Integer> PACKAGE_EDGES_WEIGHT = new Metric.Builder(PACKAGE_EDGES_WEIGHT_KEY, "Package edges weight", Metric.ValueType.INT)
1862        .setDescription("Package edges weight")
1863        .setDirection(Metric.DIRECTION_BETTER)
1864        .setQualitative(false)
1865        .setDomain(DOMAIN_DESIGN)
1866        .setFormula(new SumChildValuesFormula(false))
1867        .setHidden(true)
1868        .setDeleteHistoricalData(true)
1869        .create();
1870    
1871      public static final String FILE_CYCLES_KEY = "file_cycles";
1872      public static final Metric<Integer> FILE_CYCLES = new Metric.Builder(FILE_CYCLES_KEY, "File cycles", Metric.ValueType.INT)
1873        .setDescription("File cycles")
1874        .setDirection(Metric.DIRECTION_WORST)
1875        .setQualitative(true)
1876        .setDomain(DOMAIN_DESIGN)
1877        .setHidden(true)
1878        .setDeleteHistoricalData(true)
1879        .setBestValue(0.0)
1880        .create();
1881    
1882      public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index";
1883      public static final Metric<Double> FILE_TANGLE_INDEX = new Metric.Builder(FILE_TANGLE_INDEX_KEY, "File tangle index", Metric.ValueType.PERCENT)
1884        .setDescription("File tangle index")
1885        .setDirection(Metric.DIRECTION_WORST)
1886        .setQualitative(true)
1887        .setDomain(DOMAIN_DESIGN)
1888        .setHidden(true)
1889        .setDeleteHistoricalData(true)
1890        .setBestValue(0.0)
1891        .create();
1892    
1893      public static final String FILE_TANGLES_KEY = "file_tangles";
1894      public static final Metric<Integer> FILE_TANGLES = new Metric.Builder(FILE_TANGLES_KEY, "File tangles", Metric.ValueType.INT)
1895        .setDescription("Files tangles")
1896        .setDirection(Metric.DIRECTION_WORST)
1897        .setQualitative(false)
1898        .setDomain(DOMAIN_DESIGN)
1899        .setHidden(true)
1900        .setDeleteHistoricalData(true)
1901        .create();
1902    
1903      public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges";
1904      public static final Metric<Integer> FILE_FEEDBACK_EDGES = new Metric.Builder(FILE_FEEDBACK_EDGES_KEY, "Suspect file dependencies", Metric.ValueType.INT)
1905        .setDescription("Suspect file dependencies")
1906        .setDirection(Metric.DIRECTION_WORST)
1907        .setQualitative(false)
1908        .setDomain(DOMAIN_DESIGN)
1909        .setHidden(true)
1910        .setDeleteHistoricalData(true)
1911        .setBestValue(0.0)
1912        .create();
1913    
1914      public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight";
1915      public static final Metric<Integer> FILE_EDGES_WEIGHT = new Metric.Builder(FILE_EDGES_WEIGHT_KEY, "File edges weight", Metric.ValueType.INT)
1916        .setDescription("File edges weight")
1917        .setDirection(Metric.DIRECTION_BETTER)
1918        .setQualitative(false)
1919        .setDomain(DOMAIN_DESIGN)
1920        .setHidden(true)
1921        .setDeleteHistoricalData(true)
1922        .create();
1923    
1924      // --------------------------------------------------------------------------------------------------------------------
1925      //
1926      // SCM
1927      // These metrics are computed by the SCM Activity plugin, since version 1.2 and introduced here since version 2.7.
1928      //
1929      // --------------------------------------------------------------------------------------------------------------------
1930    
1931      /**
1932       * @since 2.7
1933       */
1934      public static final String SCM_AUTHORS_BY_LINE_KEY = "authors_by_line";
1935    
1936      /**
1937       * Key-value pairs, where key - is a number of line, and value - is an author for this line.
1938       *
1939       * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map)
1940       * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String)
1941       * @since 2.7
1942       */
1943      public static final Metric<String> SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by line", Metric.ValueType.DATA)
1944        .setDomain(DOMAIN_SCM)
1945        .create();
1946    
1947      /**
1948       * @since 2.7
1949       */
1950      public static final String SCM_REVISIONS_BY_LINE_KEY = "revisions_by_line";
1951    
1952      /**
1953       * Key-value pairs, where key - is a number of line, and value - is a revision for this line.
1954       *
1955       * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map)
1956       * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String)
1957       * @since 2.7
1958       */
1959      public static final Metric<String> SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by line", Metric.ValueType.DATA)
1960        .setDomain(DOMAIN_SCM)
1961        .create();
1962    
1963      /**
1964       * @since 2.7
1965       */
1966      public static final String SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY = "last_commit_datetimes_by_line";
1967    
1968      /**
1969       * Key-value pairs, where key - is a number of line, and value - is a date of last commit for this line.
1970       *
1971       * @see org.sonar.api.utils.KeyValueFormat#formatIntDateTime(java.util.Map)
1972       * @see org.sonar.api.utils.KeyValueFormat#parseIntDateTime(String)
1973       * @since 2.7
1974       */
1975      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",
1976        Metric.ValueType.DATA)
1977        .setDomain(DOMAIN_SCM)
1978        .create();
1979    
1980      // --------------------------------------------------------------------------------------------------------------------
1981      //
1982      // REVIEWS (since 2.14)
1983      //
1984      // --------------------------------------------------------------------------------------------------------------------
1985    
1986      /**
1987       * @since 2.14
1988       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
1989       */
1990      @Deprecated
1991      public static final String UNREVIEWED_VIOLATIONS_KEY = "unreviewed_violations";
1992    
1993      /**
1994       * @since 2.14
1995       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
1996       */
1997      @Deprecated
1998      public static final Metric<Integer> UNREVIEWED_VIOLATIONS = new Metric.Builder(UNREVIEWED_VIOLATIONS_KEY, "Unreviewed violations", Metric.ValueType.INT)
1999        .setDescription("Violations that have not been reviewed yet")
2000        .setDirection(Metric.DIRECTION_WORST)
2001        .setDomain(DOMAIN_REVIEWS)
2002        .setBestValue(0.0)
2003        .setOptimizedBestValue(true)
2004        .setHidden(true)
2005        .create();
2006    
2007      /**
2008       * @since 2.14
2009       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2010       */
2011      @Deprecated
2012      public static final String NEW_UNREVIEWED_VIOLATIONS_KEY = "new_unreviewed_violations";
2013    
2014      /**
2015       * @since 2.14
2016       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2017       */
2018      @Deprecated
2019      public static final Metric<Integer> NEW_UNREVIEWED_VIOLATIONS = new Metric.Builder(NEW_UNREVIEWED_VIOLATIONS_KEY, "New unreviewed violations", Metric.ValueType.INT)
2020        .setDescription("New violations that have not been reviewed yet")
2021        .setDirection(Metric.DIRECTION_WORST)
2022        .setQualitative(true)
2023        .setDomain(DOMAIN_REVIEWS)
2024        .setBestValue(0.0)
2025        .setOptimizedBestValue(true)
2026        .setDeleteHistoricalData(true)
2027        .setHidden(true)
2028        .create();
2029    
2030      /**
2031       * @since 2.14
2032       * @deprecated in 3.6. This measure is replaced by {@link #FALSE_POSITIVE_ISSUES_KEY}.
2033       */
2034      @Deprecated
2035      public static final String FALSE_POSITIVE_REVIEWS_KEY = "false_positive_reviews";
2036    
2037      /**
2038       * @since 2.14
2039       * @deprecated in 3.6. This measure is replaced by {@link #FALSE_POSITIVE_ISSUES}.
2040       */
2041      @Deprecated
2042      public static final Metric<Integer> FALSE_POSITIVE_REVIEWS = new Metric.Builder(FALSE_POSITIVE_REVIEWS_KEY, "False-positive reviews", Metric.ValueType.INT)
2043        .setDescription("Active false-positive reviews")
2044        .setDirection(Metric.DIRECTION_WORST)
2045        .setDomain(DOMAIN_REVIEWS)
2046        .setBestValue(0.0)
2047        .setOptimizedBestValue(true)
2048        .setHidden(true)
2049        .create();
2050    
2051      /**
2052       * @since 2.14
2053       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2054       */
2055      @Deprecated
2056      public static final String ACTIVE_REVIEWS_KEY = "active_reviews";
2057    
2058      /**
2059       * @since 2.14
2060       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2061       */
2062      @Deprecated
2063      public static final Metric<Integer> ACTIVE_REVIEWS = new Metric.Builder(ACTIVE_REVIEWS_KEY, "Active reviews", Metric.ValueType.INT)
2064        .setDescription("Active open and reopened reviews")
2065        .setDirection(Metric.DIRECTION_WORST)
2066        .setDomain(DOMAIN_REVIEWS)
2067        .setBestValue(0.0)
2068        .setOptimizedBestValue(true)
2069        .setHidden(true)
2070        .create();
2071    
2072      /**
2073       * @since 2.14
2074       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2075       */
2076      @Deprecated
2077      public static final String UNASSIGNED_REVIEWS_KEY = "unassigned_reviews";
2078    
2079      /**
2080       * @since 2.14
2081       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2082       */
2083      @Deprecated
2084      public static final Metric<Integer> UNASSIGNED_REVIEWS = new Metric.Builder(UNASSIGNED_REVIEWS_KEY, "Unassigned reviews", Metric.ValueType.INT)
2085        .setDescription("Active unassigned reviews")
2086        .setDirection(Metric.DIRECTION_WORST)
2087        .setDomain(DOMAIN_REVIEWS)
2088        .setBestValue(0.0)
2089        .setOptimizedBestValue(true)
2090        .setHidden(true)
2091        .create();
2092    
2093      /**
2094       * @since 2.14
2095       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2096       */
2097      @Deprecated
2098      public static final String UNPLANNED_REVIEWS_KEY = "unplanned_reviews";
2099    
2100      /**
2101       * @since 2.14
2102       * @deprecated in 3.6. This measure is not fed anymore since introduction of issues.
2103       */
2104      @Deprecated
2105      public static final Metric<Integer> UNPLANNED_REVIEWS = new Metric.Builder(UNPLANNED_REVIEWS_KEY, "Unplanned reviews", Metric.ValueType.INT)
2106        .setDescription("Active unplanned reviews")
2107        .setDirection(Metric.DIRECTION_WORST)
2108        .setDomain(DOMAIN_REVIEWS)
2109        .setBestValue(0.0)
2110        .setOptimizedBestValue(true)
2111        .setHidden(true)
2112        .create();
2113    
2114      // --------------------------------------------------------------------------------------------------------------------
2115      //
2116      // TECHNICAL DEBT
2117      //
2118      // --------------------------------------------------------------------------------------------------------------------
2119    
2120      /**
2121       * @since 4.0
2122       */
2123      public static final String TECHNICAL_DEBT_KEY = "sqale_index";
2124    
2125      /**
2126       * @since 4.0
2127       */
2128      public static final Metric<Long> TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR)
2129        .setDomain(DOMAIN_TECHNICAL_DEBT)
2130        .setDirection(Metric.DIRECTION_WORST)
2131        .setOptimizedBestValue(true)
2132        .setBestValue(0.0)
2133        .setQualitative(true)
2134        .create();
2135    
2136      /**
2137       * @since 4.1
2138       */
2139      public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt";
2140    
2141      /**
2142       * @since 4.1
2143       */
2144      public static final Metric<Long> NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Technical Debt on new code", Metric.ValueType.WORK_DUR)
2145        .setDescription("Technical Debt of new code")
2146        .setDomain(DOMAIN_TECHNICAL_DEBT)
2147        .setDirection(Metric.DIRECTION_WORST)
2148        .setOptimizedBestValue(true)
2149        .setBestValue(0.0)
2150        .setQualitative(true)
2151        .setDeleteHistoricalData(true)
2152        .create();
2153    
2154      // --------------------------------------------------------------------------------------------------------------------
2155      //
2156      // FILE DATA
2157      //
2158      // --------------------------------------------------------------------------------------------------------------------
2159    
2160      /**
2161       * @since 2.14
2162       */
2163      @Beta
2164      public static final String NCLOC_DATA_KEY = "ncloc_data";
2165    
2166      /**
2167       * Information about lines of code in file.
2168       * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains code (1) or not (0).
2169       *
2170       * @see org.sonar.api.measures.FileLinesContext
2171       * @since 2.14
2172       */
2173      @Beta
2174      public static final Metric<String> NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA)
2175        .setHidden(true)
2176        .setDomain(DOMAIN_SIZE)
2177        .create();
2178    
2179      /**
2180       * @since 2.14
2181       */
2182      @Beta
2183      public static final String COMMENT_LINES_DATA_KEY = "comment_lines_data";
2184    
2185      /**
2186       * Information about comments in file.
2187       * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains comment (1) or not (0).
2188       *
2189       * @see org.sonar.api.measures.FileLinesContext
2190       * @since 2.14
2191       */
2192      @Beta
2193      public static final Metric<String> COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA)
2194        .setHidden(true)
2195        .setDomain(DOMAIN_DOCUMENTATION)
2196        .create();
2197    
2198      // --------------------------------------------------------------------------------------------------------------------
2199      //
2200      // OTHERS
2201      //
2202      // --------------------------------------------------------------------------------------------------------------------
2203    
2204      public static final String ALERT_STATUS_KEY = "alert_status";
2205      public static final Metric<Metric.Level> ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Quality Gate Status", Metric.ValueType.LEVEL)
2206        .setDescription("The project status with regard to its quality gate.")
2207        .setDirection(Metric.DIRECTION_BETTER)
2208        .setQualitative(true)
2209        .setDomain(DOMAIN_GENERAL)
2210        .create();
2211    
2212      /**
2213       * @since 4.4
2214       */
2215      public static final String QUALITY_GATE_DETAILS_KEY = "quality_gate_details";
2216      /**
2217       * The project detailed status with regard to its quality gate.
2218       * Storing the global quality gate status, along with all evaluated conditions, into a JSON object.
2219       * @since 4.4
2220       */
2221      public static final Metric<String> QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA)
2222        .setDescription("The project detailed status with regard to its quality gate.")
2223        .setDomain(DOMAIN_GENERAL)
2224        .create();
2225    
2226      /**
2227       * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY}
2228       */
2229      @Deprecated
2230      public static final String PROFILE_KEY = "profile";
2231      /**
2232       * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY}
2233       */
2234      @Deprecated
2235      public static final Metric<String> PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA)
2236        .setDescription("Selected quality profile")
2237        .setDomain(DOMAIN_GENERAL)
2238        .create();
2239    
2240      /**
2241       * @since 2.9
2242       * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY}
2243       */
2244      @Deprecated
2245      public static final String PROFILE_VERSION_KEY = "profile_version";
2246      /**
2247       * @since 2.9
2248       * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY}
2249       */
2250      @Deprecated
2251      public static final Metric<Integer> PROFILE_VERSION = new Metric.Builder(PROFILE_VERSION_KEY, "Profile version", Metric.ValueType.INT)
2252        .setDescription("Selected quality profile version")
2253        .setQualitative(false)
2254        .setDomain(DOMAIN_GENERAL)
2255        .setHidden(true)
2256        .create();
2257    
2258      /**
2259       * @since 4.4
2260       */
2261      public static final String QUALITY_PROFILES_KEY = "quality_profiles";
2262    
2263      /**
2264       * @since 4.4
2265       */
2266      public static final Metric<String> QUALITY_PROFILES = new Metric.Builder(QUALITY_PROFILES_KEY, "Profiles", Metric.ValueType.DATA)
2267        .setDescription("Details of quality profiles used during analysis")
2268        .setQualitative(false)
2269        .setDomain(DOMAIN_GENERAL)
2270        .setHidden(true)
2271        .create();
2272    
2273      private static final List<Metric> METRICS;
2274    
2275      static {
2276        METRICS = Lists.newLinkedList();
2277        for (Field field : CoreMetrics.class.getFields()) {
2278          if (Metric.class.isAssignableFrom(field.getType())) {
2279            try {
2280              Metric metric = (Metric) field.get(null);
2281              METRICS.add(metric);
2282            } catch (IllegalAccessException e) {
2283              throw new SonarException("can not introspect " + CoreMetrics.class + " to get metrics", e);
2284            }
2285          }
2286        }
2287      }
2288    
2289      private CoreMetrics() {
2290        // only static stuff
2291      }
2292    
2293      public static List<Metric> getMetrics() {
2294        return METRICS;
2295      }
2296    
2297      public static Metric getMetric(final String key) {
2298        return Iterables.find(METRICS, new Predicate<Metric>() {
2299          @Override
2300          public boolean apply(@Nullable Metric input) {
2301            return input != null && input.getKey().equals(key);
2302          }
2303        });
2304      }
2305    }