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