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