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