001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program 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 * This program 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 */
020package org.sonar.api.measures;
021
022import java.lang.reflect.Field;
023import java.lang.reflect.Modifier;
024import java.util.LinkedList;
025import java.util.List;
026import java.util.NoSuchElementException;
027import org.sonar.api.test.MutableTestPlan;
028import org.sonar.api.utils.SonarException;
029
030/**
031 * @since 1.10
032 */
033public final class CoreMetrics {
034
035  // the following fields are not final to avoid compile-time constants used by plugins
036  public static String DOMAIN_SIZE = "Size";
037  public static String DOMAIN_COVERAGE = "Coverage";
038
039  /**
040   * @deprecated in 5.5. Merged into {@link #DOMAIN_COVERAGE}
041   */
042  @Deprecated
043  public static String DOMAIN_TESTS = "Tests";
044
045  /**
046   * @deprecated in 5.5. Merged into {@link #DOMAIN_COVERAGE}
047   */
048  @Deprecated
049  public static String DOMAIN_INTEGRATION_TESTS = "Tests (Integration)";
050
051  /**
052   * @deprecated in 5.5. Merged into {@link #DOMAIN_COVERAGE}
053   */
054  @Deprecated
055  public static String DOMAIN_OVERALL_TESTS = "Tests (Overall)";
056  public static String DOMAIN_COMPLEXITY = "Complexity";
057  /**
058   * @deprecated since 6.2. Merged into {@link #DOMAIN_SIZE}
059   */
060  @Deprecated
061  public static String DOMAIN_DOCUMENTATION = "Documentation";
062  public static String DOMAIN_SCM = "SCM";
063  public static String DOMAIN_ISSUES = "Issues";
064  public static String DOMAIN_GENERAL = "General";
065  public static String DOMAIN_DUPLICATIONS = "Duplications";
066
067  /**
068   * @deprecated in 5.5. Renamed to {@link #DOMAIN_DUPLICATIONS}
069   */
070  @Deprecated
071  public static String DOMAIN_DUPLICATION = "Duplication";
072  public static String DOMAIN_DESIGN = "Design";
073
074  /**
075   * SonarQube Quality Model
076   * @since 5.5
077   */
078  public static String DOMAIN_MAINTAINABILITY = "Maintainability";
079
080  /**
081   * SonarQube Quality Model
082   * @since 5.5
083   */
084  public static String DOMAIN_RELIABILITY = "Reliability";
085
086  /**
087   * SonarQube Quality Model
088   * @since 5.5
089   */
090  public static String DOMAIN_SECURITY = "Security";
091
092  /**
093   * @since 4.0
094   *
095   * @deprecated in 5.5. Replaced by {@link #DOMAIN_MAINTAINABILITY}
096   */
097  @Deprecated
098  public static String DOMAIN_TECHNICAL_DEBT = "Technical Debt";
099
100  /**
101   * @since 5.5
102   */
103  public static String DOMAIN_RELEASABILITY = "Releasability";
104
105  /**
106   * Computed by the platform since SQ 5.1
107   */
108  public static final String LINES_KEY = "lines";
109  public static final Metric<Integer> LINES = new Metric.Builder(LINES_KEY, "Lines", Metric.ValueType.INT)
110    .setDescription("Lines")
111    .setDirection(Metric.DIRECTION_WORST)
112    .setQualitative(false)
113    .setDomain(DOMAIN_SIZE)
114    .create();
115
116  public static final String GENERATED_LINES_KEY = "generated_lines";
117  public static final Metric<Integer> GENERATED_LINES = new Metric.Builder(GENERATED_LINES_KEY, "Generated Lines", Metric.ValueType.INT)
118    .setDescription("Number of generated lines")
119    .setDirection(Metric.DIRECTION_WORST)
120    .setQualitative(false)
121    .setDomain(DOMAIN_SIZE)
122    .setBestValue(0.0)
123    .setOptimizedBestValue(true)
124    .create();
125
126  public static final String NCLOC_KEY = "ncloc";
127  public static final Metric<Integer> NCLOC = new Metric.Builder(NCLOC_KEY, "Lines of Code", Metric.ValueType.INT)
128    .setDescription("Non commenting lines of code")
129    .setDirection(Metric.DIRECTION_WORST)
130    .setQualitative(false)
131    .setDomain(DOMAIN_SIZE)
132    .create();
133
134  /**
135   * @since 6.1
136   */
137  public static final String NEW_LINES_KEY = "new_lines";
138  /**
139   * @since 6.1
140   */
141  public static final Metric<Integer> NEW_LINES = new Metric.Builder(NEW_LINES_KEY, "Lines of New Code", Metric.ValueType.INT)
142    .setDescription("Non commenting lines of new code")
143    .setDirection(Metric.DIRECTION_WORST)
144    .setQualitative(false)
145    .setDomain(DOMAIN_SIZE)
146    .setDeleteHistoricalData(true)
147    .create();
148
149  /**
150   * @since 4.4
151   */
152  public static final String NCLOC_LANGUAGE_DISTRIBUTION_KEY = "ncloc_language_distribution";
153
154  /**
155   * @since 4.4
156   */
157  public static final Metric<String> NCLOC_LANGUAGE_DISTRIBUTION = new Metric.Builder(NCLOC_LANGUAGE_DISTRIBUTION_KEY, "Lines of Code Per Language", Metric.ValueType.DATA)
158    .setDescription("Non Commenting Lines of Code Distributed By Language")
159    .setDirection(Metric.DIRECTION_WORST)
160    .setQualitative(false)
161    .setDomain(DOMAIN_SIZE)
162    .create();
163
164  public static final String GENERATED_NCLOC_KEY = "generated_ncloc";
165  public static final Metric<Integer> GENERATED_NCLOC = new Metric.Builder(GENERATED_NCLOC_KEY, "Generated Lines of Code", Metric.ValueType.INT)
166    .setDescription("Generated non Commenting Lines of Code")
167    .setDirection(Metric.DIRECTION_WORST)
168    .setQualitative(false)
169    .setDomain(DOMAIN_SIZE)
170    .setBestValue(0.0)
171    .setOptimizedBestValue(true)
172    .create();
173
174  public static final String CLASSES_KEY = "classes";
175  public static final Metric<Integer> CLASSES = new Metric.Builder(CLASSES_KEY, "Classes", Metric.ValueType.INT)
176    .setDescription("Classes")
177    .setDirection(Metric.DIRECTION_WORST)
178    .setQualitative(false)
179    .setDomain(DOMAIN_SIZE)
180    .create();
181
182  public static final String FILES_KEY = "files";
183  /**
184   * Computed by the platform.
185   */
186  public static final Metric<Integer> FILES = new Metric.Builder(FILES_KEY, "Files", Metric.ValueType.INT)
187    .setDescription("Number of files")
188    .setDirection(Metric.DIRECTION_WORST)
189    .setQualitative(false)
190    .setDomain(DOMAIN_SIZE)
191    .create();
192
193  public static final String DIRECTORIES_KEY = "directories";
194  /**
195   * Computed by the platform.
196   */
197  public static final Metric<Integer> DIRECTORIES = new Metric.Builder(DIRECTORIES_KEY, "Directories", Metric.ValueType.INT)
198    .setDescription("Directories")
199    .setDirection(Metric.DIRECTION_WORST)
200    .setQualitative(false)
201    .setDomain(DOMAIN_SIZE)
202    .create();
203
204  public static final String FUNCTIONS_KEY = "functions";
205  public static final Metric<Integer> FUNCTIONS = new Metric.Builder(FUNCTIONS_KEY, "Functions", Metric.ValueType.INT)
206    .setDescription("Functions")
207    .setDirection(Metric.DIRECTION_WORST)
208    .setQualitative(false)
209    .setDomain(DOMAIN_SIZE)
210    .create();
211
212  /**
213   * @deprecated since 5.0.
214   * @see <a href="https://jira.sonarsource.com/browse/SONAR-5224">SONAR-5224</a>
215   */
216  @Deprecated
217  public static final String ACCESSORS_KEY = "accessors";
218
219  /**
220   * @deprecated since 5.0.
221   * @see <a href="https://jira.sonarsource.com/browse/SONAR-5224">SONAR-5224</a>
222   */
223  @Deprecated
224  public static final Metric<Integer> ACCESSORS = new Metric.Builder(ACCESSORS_KEY, "Accessors", Metric.ValueType.INT)
225    .setDescription("Accessors")
226    .setDirection(Metric.DIRECTION_WORST)
227    .setQualitative(false)
228    .setDomain(DOMAIN_SIZE)
229    .setHidden(true)
230    .create();
231
232  public static final String STATEMENTS_KEY = "statements";
233  public static final Metric<Integer> STATEMENTS = new Metric.Builder(STATEMENTS_KEY, "Statements", Metric.ValueType.INT)
234    .setDescription("Number of statements")
235    .setDirection(Metric.DIRECTION_WORST)
236    .setQualitative(false)
237    .setDomain(DOMAIN_SIZE)
238    .create();
239
240  /**
241   * @deprecated since 6.2
242   * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
243   */
244  @Deprecated
245  public static final String PUBLIC_API_KEY = "public_api";
246  public static final Metric<Integer> PUBLIC_API = new Metric.Builder(PUBLIC_API_KEY, "Public API", Metric.ValueType.INT)
247    .setDescription("Public API")
248    .setDirection(Metric.DIRECTION_WORST)
249    .setQualitative(false)
250    .setDomain(DOMAIN_DOCUMENTATION)
251    .setHidden(true)
252    .create();
253
254  /**
255   * @since 3.0
256   */
257  public static final String PROJECTS_KEY = "projects";
258
259  /**
260   * @since 3.0
261   */
262  public static final Metric<Integer> PROJECTS = new Metric.Builder(PROJECTS_KEY, "Projects", Metric.ValueType.INT)
263    .setDescription("Number of projects")
264    .setDirection(Metric.DIRECTION_WORST)
265    .setQualitative(false)
266    .setDomain(DOMAIN_SIZE)
267    .create();
268
269  /**
270   * Moved to Size domain since 6.2
271   */
272  public static final String COMMENT_LINES_KEY = "comment_lines";
273  public static final Metric<Integer> COMMENT_LINES = new Metric.Builder(COMMENT_LINES_KEY, "Comment Lines", Metric.ValueType.INT)
274    .setDescription("Number of comment lines")
275    .setDirection(Metric.DIRECTION_BETTER)
276    .setQualitative(false)
277    .setDomain(DOMAIN_SIZE)
278    .create();
279
280  /**
281   * Moved to Size domain since 6.2
282   */
283  public static final String COMMENT_LINES_DENSITY_KEY = "comment_lines_density";
284  public static final Metric<Double> COMMENT_LINES_DENSITY = new Metric.Builder(COMMENT_LINES_DENSITY_KEY, "Comments (%)", Metric.ValueType.PERCENT)
285    .setDescription("Comments balanced by ncloc + comment lines")
286    .setDirection(Metric.DIRECTION_BETTER)
287    .setQualitative(true)
288    .setDomain(DOMAIN_SIZE)
289    .create();
290
291  // --------------------------------------------------------------------------------------------------------------------
292  //
293  // DOCUMENTATION
294  //
295  // --------------------------------------------------------------------------------------------------------------------
296
297  /**
298   * @deprecated since 6.2
299   * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
300   */
301  @Deprecated
302  public static final String PUBLIC_DOCUMENTED_API_DENSITY_KEY = "public_documented_api_density";
303  public static final Metric<Double> PUBLIC_DOCUMENTED_API_DENSITY = new Metric.Builder(PUBLIC_DOCUMENTED_API_DENSITY_KEY, "Public Documented API (%)", Metric.ValueType.PERCENT)
304    .setDescription("Public documented classes and functions balanced by ncloc")
305    .setDirection(Metric.DIRECTION_BETTER)
306    .setQualitative(true)
307    .setDomain(DOMAIN_DOCUMENTATION)
308    .setWorstValue(0.0)
309    .setBestValue(100.0)
310    .setOptimizedBestValue(true)
311    .setHidden(true)
312    .create();
313
314  /**
315   * @deprecated since 6.2
316   * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
317   */
318  @Deprecated
319  public static final String PUBLIC_UNDOCUMENTED_API_KEY = "public_undocumented_api";
320  public static final Metric<Integer> PUBLIC_UNDOCUMENTED_API = new Metric.Builder(PUBLIC_UNDOCUMENTED_API_KEY, "Public Undocumented API", Metric.ValueType.INT)
321    .setDescription("Public undocumented classes, functions and variables")
322    .setDirection(Metric.DIRECTION_WORST)
323    .setQualitative(true)
324    .setDomain(DOMAIN_DOCUMENTATION)
325    .setBestValue(0.0)
326    .setDirection(Metric.DIRECTION_WORST)
327    .setOptimizedBestValue(true)
328    .setHidden(true)
329    .create();
330
331  /**
332   * @deprecated since 4.2 - see SONAR-4990
333   */
334  @Deprecated
335  public static final String COMMENTED_OUT_CODE_LINES_KEY = "commented_out_code_lines";
336
337  /**
338   * @deprecated since 4.2 - see SONAR-4990
339   */
340  @Deprecated
341  public static final Metric<Integer> COMMENTED_OUT_CODE_LINES = new Metric.Builder(COMMENTED_OUT_CODE_LINES_KEY, "Commented-Out LOC", Metric.ValueType.INT)
342    .setDescription("Commented lines of code")
343    .setDirection(Metric.DIRECTION_WORST)
344    .setQualitative(true)
345    .setDomain(DOMAIN_DOCUMENTATION)
346    .setBestValue(0.0)
347    .setOptimizedBestValue(true)
348    .setHidden(true)
349    .create();
350
351  // --------------------------------------------------------------------------------------------------------------------
352  //
353  // COMPLEXITY
354  //
355  // --------------------------------------------------------------------------------------------------------------------
356
357  public static final String COMPLEXITY_KEY = "complexity";
358  public static final Metric<Integer> COMPLEXITY = new Metric.Builder(COMPLEXITY_KEY, "Complexity", Metric.ValueType.INT)
359    .setDescription("Cyclomatic complexity")
360    .setDirection(Metric.DIRECTION_WORST)
361    .setQualitative(false)
362    .setDomain(DOMAIN_COMPLEXITY)
363    .create();
364
365  public static final String FILE_COMPLEXITY_KEY = "file_complexity";
366
367  /**
368   * Information about the cyclomatic complexity per file, calculated by divided the {@link #COMPLEXITY} by the number of {@link #FILES}.
369   */
370  public static final Metric<Double> FILE_COMPLEXITY = new Metric.Builder(FILE_COMPLEXITY_KEY, "Complexity / File", Metric.ValueType.FLOAT)
371    .setDescription("Complexity average by file")
372    .setDirection(Metric.DIRECTION_WORST)
373    .setQualitative(true)
374    .setDomain(DOMAIN_COMPLEXITY)
375    .create();
376
377  /**
378   * @since 3.6
379   */
380  public static final String COMPLEXITY_IN_CLASSES_KEY = "complexity_in_classes";
381
382  /**
383   * @since 3.6
384   */
385  public static final Metric<Integer> COMPLEXITY_IN_CLASSES = new Metric.Builder(COMPLEXITY_IN_CLASSES_KEY, "Complexity in Classes", Metric.ValueType.INT)
386    .setDescription("Cyclomatic complexity in classes")
387    .setHidden(true)
388    .setDirection(Metric.DIRECTION_WORST)
389    .setQualitative(false)
390    .setDomain(DOMAIN_COMPLEXITY)
391    .setDeleteHistoricalData(true)
392    .create();
393
394  public static final String CLASS_COMPLEXITY_KEY = "class_complexity";
395
396  /**
397   * Information about the cyclomatic complexity per class, calculated by divided the {@link #COMPLEXITY_IN_CLASSES} by the number of {@link #CLASSES}.
398   */
399  public static final Metric<Double> CLASS_COMPLEXITY = new Metric.Builder(CLASS_COMPLEXITY_KEY, "Complexity / Class", Metric.ValueType.FLOAT)
400    .setDescription("Complexity average by class")
401    .setDirection(Metric.DIRECTION_WORST)
402    .setQualitative(true)
403    .setDomain(DOMAIN_COMPLEXITY)
404    .create();
405
406  /**
407   * @since 3.6
408   */
409  public static final String COMPLEXITY_IN_FUNCTIONS_KEY = "complexity_in_functions";
410
411  /**
412   * @since 3.6
413   */
414  public static final Metric<Integer> COMPLEXITY_IN_FUNCTIONS = new Metric.Builder(COMPLEXITY_IN_FUNCTIONS_KEY, "Complexity in Functions", Metric.ValueType.INT)
415    .setDescription("Cyclomatic complexity in functions")
416    .setHidden(true)
417    .setDirection(Metric.DIRECTION_WORST)
418    .setQualitative(false)
419    .setDomain(DOMAIN_COMPLEXITY)
420    .setDeleteHistoricalData(true)
421    .create();
422
423  public static final String FUNCTION_COMPLEXITY_KEY = "function_complexity";
424
425  /**
426   * Information about the cyclomatic complexity per function, calculated by divided the {@link #COMPLEXITY_IN_FUNCTIONS} by the number of {@link #FUNCTIONS}.
427   */
428  public static final Metric<Double> FUNCTION_COMPLEXITY = new Metric.Builder(FUNCTION_COMPLEXITY_KEY, "Complexity / Function", Metric.ValueType.FLOAT)
429    .setDescription("Complexity average by function")
430    .setDirection(Metric.DIRECTION_WORST)
431    .setQualitative(true)
432    .setDomain(DOMAIN_COMPLEXITY)
433    .create();
434
435  /**
436   * @deprecated in 3.0 - see SONAR-3289
437   */
438  @Deprecated
439  public static final String CLASS_COMPLEXITY_DISTRIBUTION_KEY = "class_complexity_distribution";
440
441  /**
442   * @deprecated in 3.0 - see SONAR-3289
443   */
444  @Deprecated
445  public static final Metric<String> CLASS_COMPLEXITY_DISTRIBUTION = new Metric.Builder(CLASS_COMPLEXITY_DISTRIBUTION_KEY, "Class Distribution / Complexity",
446    Metric.ValueType.DISTRIB)
447      .setDescription("Classes distribution /complexity")
448      .setDirection(Metric.DIRECTION_NONE)
449      .setQualitative(true)
450      .setDomain(DOMAIN_COMPLEXITY)
451      .setHidden(true)
452      .create();
453
454  public static final String FUNCTION_COMPLEXITY_DISTRIBUTION_KEY = "function_complexity_distribution";
455  public static final Metric<String> FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Function Distribution / Complexity",
456    Metric.ValueType.DISTRIB)
457      .setDescription("Functions distribution /complexity")
458      .setDirection(Metric.DIRECTION_NONE)
459      .setQualitative(true)
460      .setDomain(DOMAIN_COMPLEXITY)
461      .create();
462
463  public static final String FILE_COMPLEXITY_DISTRIBUTION_KEY = "file_complexity_distribution";
464  public static final Metric<String> FILE_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FILE_COMPLEXITY_DISTRIBUTION_KEY, "File Distribution / Complexity",
465    Metric.ValueType.DISTRIB)
466      .setDescription("Files distribution /complexity")
467      .setDirection(Metric.DIRECTION_NONE)
468      .setQualitative(true)
469      .setDomain(DOMAIN_COMPLEXITY)
470      .create();
471
472  public static final String COGNITIVE_COMPLEXITY_KEY = "cognitive_complexity";
473  public static final Metric<Integer> COGNITIVE_COMPLEXITY = new Metric.Builder(COGNITIVE_COMPLEXITY_KEY, "Cognitive Complexity", Metric.ValueType.INT)
474    .setDescription("Cognitive complexity")
475    .setDirection(Metric.DIRECTION_WORST)
476    .setQualitative(false)
477    .setDomain(DOMAIN_COMPLEXITY)
478    .setBestValue(0.0)
479    .setOptimizedBestValue(true)
480    .create();
481
482  // --------------------------------------------------------------------------------------------------------------------
483  //
484  // UNIT TESTS
485  //
486  // --------------------------------------------------------------------------------------------------------------------
487
488  public static final String TESTS_KEY = "tests";
489
490  /**
491   * Value of measure for this metric can be saved from Sensor, taking into account following rules:
492   * <ul>
493   * <li>Non-zero value should be saved for resources representing tests. And Sonar provides default Decorator, which will decorate parent resources.</li>
494   * <li>Should include {@link #TEST_FAILURES} and {@link #TEST_ERRORS}, but should not include {@link #SKIPPED_TESTS}.</li>
495   * </ul>
496   */
497  public static final Metric<Integer> TESTS = new Metric.Builder(TESTS_KEY, "Unit Tests", Metric.ValueType.INT)
498    .setDescription("Number of unit tests")
499    .setDirection(Metric.DIRECTION_WORST)
500    .setQualitative(false)
501    .setDomain(DOMAIN_COVERAGE)
502    .create();
503
504  public static final String TEST_EXECUTION_TIME_KEY = "test_execution_time";
505  public static final Metric<Long> TEST_EXECUTION_TIME = new Metric.Builder(TEST_EXECUTION_TIME_KEY, "Unit Test Duration", Metric.ValueType.MILLISEC)
506    .setDescription("Execution duration of unit tests")
507    .setDirection(Metric.DIRECTION_WORST)
508    .setQualitative(false)
509    .setDomain(DOMAIN_COVERAGE)
510    .create();
511
512  public static final String TEST_ERRORS_KEY = "test_errors";
513  public static final Metric<Integer> TEST_ERRORS = new Metric.Builder(TEST_ERRORS_KEY, "Unit Test Errors", Metric.ValueType.INT)
514    .setDescription("Number of unit test errors")
515    .setDirection(Metric.DIRECTION_WORST)
516    .setQualitative(true)
517    .setDomain(DOMAIN_COVERAGE)
518    .setBestValue(0.0)
519    .setOptimizedBestValue(true)
520    .create();
521
522  public static final String SKIPPED_TESTS_KEY = "skipped_tests";
523  public static final Metric<Integer> SKIPPED_TESTS = new Metric.Builder(SKIPPED_TESTS_KEY, "Skipped Unit Tests", Metric.ValueType.INT)
524    .setDescription("Number of skipped unit tests")
525    .setDirection(Metric.DIRECTION_WORST)
526    .setQualitative(true)
527    .setDomain(DOMAIN_COVERAGE)
528    .setBestValue(0.0)
529    .setOptimizedBestValue(true)
530    .create();
531
532  public static final String TEST_FAILURES_KEY = "test_failures";
533  public static final Metric<Integer> TEST_FAILURES = new Metric.Builder(TEST_FAILURES_KEY, "Unit Test Failures", Metric.ValueType.INT)
534    .setDescription("Number of unit test failures")
535    .setDirection(Metric.DIRECTION_WORST)
536    .setQualitative(true)
537    .setDomain(DOMAIN_COVERAGE)
538    .setBestValue(0.0)
539    .setOptimizedBestValue(true)
540    .create();
541
542  public static final String TEST_SUCCESS_DENSITY_KEY = "test_success_density";
543  public static final Metric<Double> TEST_SUCCESS_DENSITY = new Metric.Builder(TEST_SUCCESS_DENSITY_KEY, "Unit Test Success (%)", Metric.ValueType.PERCENT)
544    .setDescription("Density of successful unit tests")
545    .setDirection(Metric.DIRECTION_BETTER)
546    .setQualitative(true)
547    .setDomain(DOMAIN_COVERAGE)
548    .setWorstValue(0.0)
549    .setBestValue(100.0)
550    .setOptimizedBestValue(true)
551    .create();
552
553  /**
554   * @deprecated since 5.2 use {@link MutableTestPlan}
555   */
556  @Deprecated
557  public static final String TEST_DATA_KEY = "test_data";
558  /**
559   * @deprecated since 5.2 use {@link MutableTestPlan}
560   */
561  @Deprecated
562  public static final Metric<String> TEST_DATA = new Metric.Builder(TEST_DATA_KEY, "Unit Test Details", Metric.ValueType.DATA)
563    .setDescription("Unit tests details")
564    .setDirection(Metric.DIRECTION_WORST)
565    .setDomain(DOMAIN_COVERAGE)
566    .create();
567
568  public static final String COVERAGE_KEY = "coverage";
569  public static final Metric<Double> COVERAGE = new Metric.Builder(COVERAGE_KEY, "Coverage", Metric.ValueType.PERCENT)
570    .setDescription("Coverage by tests")
571    .setDirection(Metric.DIRECTION_BETTER)
572    .setQualitative(true)
573    .setDomain(DOMAIN_COVERAGE)
574    .setWorstValue(0.0)
575    .setBestValue(100.0)
576    .create();
577
578  public static final String NEW_COVERAGE_KEY = "new_coverage";
579  public static final Metric<Double> NEW_COVERAGE = new Metric.Builder(NEW_COVERAGE_KEY, "Coverage on New Code", Metric.ValueType.PERCENT)
580    .setDescription("Coverage of new/changed code")
581    .setDirection(Metric.DIRECTION_BETTER)
582    .setQualitative(true)
583    .setDomain(DOMAIN_COVERAGE)
584    .setWorstValue(0.0)
585    .setBestValue(100.0)
586    .setDeleteHistoricalData(true)
587    .create();
588
589  public static final String LINES_TO_COVER_KEY = "lines_to_cover";
590
591  /**
592   * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
593   */
594  public static final Metric<Integer> LINES_TO_COVER = new Metric.Builder(LINES_TO_COVER_KEY, "Lines to Cover", Metric.ValueType.INT)
595    .setDescription("Lines to cover")
596    .setDirection(Metric.DIRECTION_WORST)
597    .setQualitative(false)
598    .setDomain(DOMAIN_COVERAGE)
599    .create();
600
601  public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover";
602  public static final Metric<Integer> NEW_LINES_TO_COVER = new Metric.Builder(NEW_LINES_TO_COVER_KEY, "Lines to Cover on New Code", Metric.ValueType.INT)
603    .setDescription("Lines to cover on new code")
604    .setDirection(Metric.DIRECTION_WORST)
605    .setQualitative(false)
606    .setDomain(DOMAIN_COVERAGE)
607    .setDeleteHistoricalData(true)
608    .create();
609
610  public static final String UNCOVERED_LINES_KEY = "uncovered_lines";
611
612  /**
613   * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
614   */
615  public static final Metric<Integer> UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, "Uncovered Lines", Metric.ValueType.INT)
616    .setDescription("Uncovered lines")
617    .setDirection(Metric.DIRECTION_WORST)
618    .setDomain(DOMAIN_COVERAGE)
619    .setBestValue(0.0)
620    .create();
621
622  public static final String NEW_UNCOVERED_LINES_KEY = "new_uncovered_lines";
623  public static final Metric<Integer> NEW_UNCOVERED_LINES = new Metric.Builder(NEW_UNCOVERED_LINES_KEY, "Uncovered Lines on New Code", Metric.ValueType.INT)
624    .setDescription("Uncovered lines on new code")
625    .setDirection(Metric.DIRECTION_WORST)
626    .setDomain(DOMAIN_COVERAGE)
627    .setBestValue(0.0)
628    .setDeleteHistoricalData(true)
629    .create();
630
631  public static final String LINE_COVERAGE_KEY = "line_coverage";
632  public static final Metric<Double> LINE_COVERAGE = new Metric.Builder(LINE_COVERAGE_KEY, "Line Coverage", Metric.ValueType.PERCENT)
633    .setDescription("Line coverage")
634    .setDirection(Metric.DIRECTION_BETTER)
635    .setQualitative(true)
636    .setDomain(DOMAIN_COVERAGE)
637    .setWorstValue(0.0)
638    .setBestValue(100.0)
639    .create();
640
641  public static final String NEW_LINE_COVERAGE_KEY = "new_line_coverage";
642  public static final Metric<Double> NEW_LINE_COVERAGE = new Metric.Builder(NEW_LINE_COVERAGE_KEY, "Line Coverage on New Code", Metric.ValueType.PERCENT)
643    .setDescription("Line coverage of added/changed code")
644    .setDirection(Metric.DIRECTION_BETTER)
645    .setQualitative(true)
646    .setWorstValue(0.0)
647    .setBestValue(100.0)
648    .setDomain(DOMAIN_COVERAGE)
649    .setDeleteHistoricalData(true)
650    .create();
651
652  /**
653   *
654   * @deprecated since 5.2 soon to be removed
655   */
656  @Deprecated
657  public static final String COVERAGE_LINE_HITS_DATA_KEY = "coverage_line_hits_data";
658
659  /**
660   * Key-value pairs, where key - is a number of line, and value - is a number of hits for this line.
661   * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
662   * @deprecated since 5.2 soon to be removed
663   */
664  @Deprecated
665  public static final Metric<String> COVERAGE_LINE_HITS_DATA = new Metric.Builder(COVERAGE_LINE_HITS_DATA_KEY, "Coverage Hits by Line", Metric.ValueType.DATA)
666    .setDescription("Coverage hits by line")
667    .setDomain(DOMAIN_COVERAGE)
668    .setDeleteHistoricalData(true)
669    .create();
670
671  public static final String CONDITIONS_TO_COVER_KEY = "conditions_to_cover";
672
673  /**
674   * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
675   */
676  public static final Metric<Integer> CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, "Conditions to Cover", Metric.ValueType.INT)
677    .setDescription("Conditions to cover")
678    .setDomain(DOMAIN_COVERAGE)
679    .create();
680
681  public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover";
682  public static final Metric<Integer> NEW_CONDITIONS_TO_COVER = new Metric.Builder(NEW_CONDITIONS_TO_COVER_KEY, "Conditions to Cover on New Code", Metric.ValueType.INT)
683    .setDescription("Conditions to cover on new code")
684    .setDomain(DOMAIN_COVERAGE)
685    .setDeleteHistoricalData(true)
686    .create();
687
688  public static final String UNCOVERED_CONDITIONS_KEY = "uncovered_conditions";
689
690  /**
691   * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
692   */
693  public static final Metric<Integer> UNCOVERED_CONDITIONS = new Metric.Builder(UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions", Metric.ValueType.INT)
694    .setDescription("Uncovered conditions")
695    .setDirection(Metric.DIRECTION_WORST)
696    .setDomain(DOMAIN_COVERAGE)
697    .setBestValue(0.0)
698    .create();
699
700  public static final String NEW_UNCOVERED_CONDITIONS_KEY = "new_uncovered_conditions";
701  public static final Metric<Integer> NEW_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions on New Code", Metric.ValueType.INT)
702    .setDescription("Uncovered conditions on new code")
703    .setDirection(Metric.DIRECTION_WORST)
704    .setDomain(DOMAIN_COVERAGE)
705    .setBestValue(0.0)
706    .setDeleteHistoricalData(true)
707    .create();
708
709  public static final String BRANCH_COVERAGE_KEY = "branch_coverage";
710  public static final Metric<Double> BRANCH_COVERAGE = new Metric.Builder(BRANCH_COVERAGE_KEY, "Condition Coverage", Metric.ValueType.PERCENT)
711    .setDescription("Condition coverage")
712    .setDirection(Metric.DIRECTION_BETTER)
713    .setQualitative(true)
714    .setDomain(DOMAIN_COVERAGE)
715    .setWorstValue(0.0)
716    .setBestValue(100.0)
717    .create();
718
719  public static final String NEW_BRANCH_COVERAGE_KEY = "new_branch_coverage";
720  public static final Metric<Double> NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, "Condition Coverage on New Code", Metric.ValueType.PERCENT)
721    .setDescription("Condition coverage of new/changed code")
722    .setDirection(Metric.DIRECTION_BETTER)
723    .setQualitative(true)
724    .setDomain(DOMAIN_COVERAGE)
725    .setWorstValue(0.0)
726    .setBestValue(100.0)
727    .setDeleteHistoricalData(true)
728    .create();
729
730  /**
731   * @deprecated since 5.2 soon to be removed
732   */
733  @Deprecated
734  public static final String CONDITIONS_BY_LINE_KEY = "conditions_by_line";
735
736  /**
737   * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
738   *
739   * @since 2.7
740   * @deprecated since 5.2 soon to be removed
741   */
742  @Deprecated
743  public static final Metric<String> CONDITIONS_BY_LINE = new Metric.Builder(CONDITIONS_BY_LINE_KEY, "Conditions by Line", Metric.ValueType.DATA)
744    .setDescription("Conditions by line")
745    .setDomain(DOMAIN_COVERAGE)
746    .setDeleteHistoricalData(true)
747    .create();
748
749  /**
750   * @deprecated since 5.2 soon to be removed
751   */
752  @Deprecated
753  public static final String COVERED_CONDITIONS_BY_LINE_KEY = "covered_conditions_by_line";
754
755  /**
756   * Use {@link CoverageMeasuresBuilder} to build measure for this metric.
757   *
758   * @since 2.7
759   * @deprecated since 5.2 soon to be removed
760   */
761  @Deprecated
762  public static final Metric<String> COVERED_CONDITIONS_BY_LINE = new Metric.Builder(COVERED_CONDITIONS_BY_LINE_KEY, "Covered Conditions by Line", Metric.ValueType.DATA)
763    .setDescription("Covered conditions by line")
764    .setDomain(DOMAIN_COVERAGE)
765    .setDeleteHistoricalData(true)
766    .create();
767
768  // --------------------------------------------------------------------------------------------------------------------
769  //
770  // INTEGRATION TESTS
771  //
772  // --------------------------------------------------------------------------------------------------------------------
773
774  /**
775   * @since 2.12
776   * @deprecated since 6.2 all coverage reports are merged in the same measures 
777   */
778  @Deprecated
779  public static final String IT_COVERAGE_KEY = "it_coverage";
780
781  /**
782   * @since 2.12
783   * @deprecated since 6.2 all coverage reports are merged in the same measures 
784   */
785  @Deprecated
786  public static final Metric<Double> IT_COVERAGE = new Metric.Builder(IT_COVERAGE_KEY, "IT Coverage", Metric.ValueType.PERCENT)
787    .setDescription("Integration tests coverage")
788    .setDirection(Metric.DIRECTION_BETTER)
789    .setQualitative(true)
790    .setDomain(DOMAIN_COVERAGE)
791    .setWorstValue(0.0)
792    .setBestValue(100.0)
793    .setHidden(true)
794    .create();
795
796  /**
797   * @since 2.12
798   * @deprecated since 6.2 all coverage reports are merged in the same measures 
799   */
800  @Deprecated
801  public static final String NEW_IT_COVERAGE_KEY = "new_it_coverage";
802
803  /**
804   * @since 2.12
805   * @deprecated since 6.2 all coverage reports are merged in the same measures 
806   */
807  @Deprecated
808  public static final Metric<Double> NEW_IT_COVERAGE = new Metric.Builder(NEW_IT_COVERAGE_KEY, "Coverage by IT on New Code", Metric.ValueType.PERCENT)
809    .setDescription("Integration tests coverage of new/changed code")
810    .setDirection(Metric.DIRECTION_BETTER)
811    .setQualitative(true)
812    .setDomain(DOMAIN_COVERAGE)
813    .setWorstValue(0.0)
814    .setBestValue(100.0)
815    .setDeleteHistoricalData(true)
816    .setHidden(true)
817    .create();
818
819  /**
820   * @since 2.12
821   * @deprecated since 6.2 all coverage reports are merged in the same measures 
822   */
823  @Deprecated
824  public static final String IT_LINES_TO_COVER_KEY = "it_lines_to_cover";
825
826  /**
827   * @since 2.12
828   * @deprecated since 6.2 all coverage reports are merged in the same measures 
829   */
830  @Deprecated
831  public static final Metric<Integer> IT_LINES_TO_COVER = new Metric.Builder(IT_LINES_TO_COVER_KEY, "IT Lines to Cover", Metric.ValueType.INT)
832    .setDescription("Lines to cover by Integration Tests")
833    .setDirection(Metric.DIRECTION_BETTER)
834    .setDomain(DOMAIN_COVERAGE)
835    .setQualitative(false)
836    .setHidden(true)
837    .create();
838
839  /**
840   * @since 2.12
841   * @deprecated since 6.2 all coverage reports are merged in the same measures 
842   */
843  @Deprecated
844  public static final String NEW_IT_LINES_TO_COVER_KEY = "new_it_lines_to_cover";
845
846  /**
847   * @since 2.12
848   * @deprecated since 6.2 all coverage reports are merged in the same measures 
849   */
850  @Deprecated
851  public static final Metric<Integer> NEW_IT_LINES_TO_COVER = new Metric.Builder(NEW_IT_LINES_TO_COVER_KEY, "Lines to Cover by IT on New Code", Metric.ValueType.INT)
852    .setDescription("Lines to cover on new code by integration tests")
853    .setDirection(Metric.DIRECTION_WORST)
854    .setQualitative(false)
855    .setDomain(DOMAIN_COVERAGE)
856    .setDeleteHistoricalData(true)
857    .setHidden(true)
858    .create();
859
860  /**
861   * @since 2.12
862   * @deprecated since 6.2 all coverage reports are merged in the same measures 
863   */
864  @Deprecated
865  public static final String IT_UNCOVERED_LINES_KEY = "it_uncovered_lines";
866
867  /**
868   * @since 2.12
869   * @deprecated since 6.2 all coverage reports are merged in the same measures 
870   */
871  @Deprecated
872  public static final Metric<Integer> IT_UNCOVERED_LINES = new Metric.Builder(IT_UNCOVERED_LINES_KEY, "IT Uncovered Lines", Metric.ValueType.INT)
873    .setDescription("Uncovered lines by integration tests")
874    .setDirection(Metric.DIRECTION_WORST)
875    .setQualitative(false)
876    .setDomain(DOMAIN_COVERAGE)
877    .setHidden(true)
878    .create();
879
880  /**
881   * @since 2.12
882   * @deprecated since 6.2 all coverage reports are merged in the same measures 
883   */
884  @Deprecated
885  public static final String NEW_IT_UNCOVERED_LINES_KEY = "new_it_uncovered_lines";
886
887  /**
888   * @since 2.12
889   * @deprecated since 6.2 all coverage reports are merged in the same measures 
890   */
891  @Deprecated
892  public static final Metric<Integer> NEW_IT_UNCOVERED_LINES = new Metric.Builder(NEW_IT_UNCOVERED_LINES_KEY, "Uncovered Lines by IT on New Code", Metric.ValueType.INT)
893    .setDescription("New lines that are not covered by integration tests")
894    .setDirection(Metric.DIRECTION_WORST)
895    .setDomain(DOMAIN_COVERAGE)
896    .setBestValue(0.0)
897    .setDeleteHistoricalData(true)
898    .setHidden(true)
899    .create();
900
901  /**
902   * @since 2.12
903   * @deprecated since 6.2 all coverage reports are merged in the same measures 
904   */
905  @Deprecated
906  public static final String IT_LINE_COVERAGE_KEY = "it_line_coverage";
907
908  /**
909   * @since 2.12
910   * @deprecated since 6.2 all coverage reports are merged in the same measures 
911   */
912  @Deprecated
913  public static final Metric<Double> IT_LINE_COVERAGE = new Metric.Builder(IT_LINE_COVERAGE_KEY, "IT Line Coverage", Metric.ValueType.PERCENT)
914    .setDescription("Line coverage by integration tests")
915    .setDirection(Metric.DIRECTION_BETTER)
916    .setQualitative(true)
917    .setDomain(DOMAIN_COVERAGE)
918    .setHidden(true)
919    .create();
920
921  /**
922   * @since 2.12
923   * @deprecated since 6.2 all coverage reports are merged in the same measures 
924   */
925  @Deprecated
926  public static final String NEW_IT_LINE_COVERAGE_KEY = "new_it_line_coverage";
927
928  /**
929   * @since 2.12
930   * @deprecated since 6.2 all coverage reports are merged in the same measures 
931   */
932  @Deprecated
933  public static final Metric<Double> NEW_IT_LINE_COVERAGE = new Metric.Builder(NEW_IT_LINE_COVERAGE_KEY, "Line Coverage by IT on New Code", Metric.ValueType.PERCENT)
934    .setDescription("Integration tests line coverage of added/changed code")
935    .setDirection(Metric.DIRECTION_BETTER)
936    .setQualitative(true)
937    .setWorstValue(0.0)
938    .setBestValue(100.0)
939    .setDomain(DOMAIN_COVERAGE)
940    .setDeleteHistoricalData(true)
941    .setHidden(true)
942    .create();
943
944  /**
945   * @since 2.12
946   * @deprecated since 5.2 soon to be removed
947   */
948  @Deprecated
949  public static final String IT_COVERAGE_LINE_HITS_DATA_KEY = "it_coverage_line_hits_data";
950
951  /**
952   * @since 2.12
953   * @deprecated since 5.2 soon to be removed
954   */
955  @Deprecated
956  public static final Metric<String> IT_COVERAGE_LINE_HITS_DATA = new Metric.Builder(IT_COVERAGE_LINE_HITS_DATA_KEY, "IT Coverage Hits by Line", Metric.ValueType.DATA)
957    .setDescription("Coverage hits by line by integration tests")
958    .setDirection(Metric.DIRECTION_NONE)
959    .setQualitative(false)
960    .setDomain(DOMAIN_COVERAGE)
961    .setDeleteHistoricalData(true)
962    .setHidden(true)
963    .create();
964
965  /**
966   * @since 2.12
967   * @deprecated since 6.2 all coverage reports are merged in the same measures 
968   */
969  @Deprecated
970  public static final String IT_CONDITIONS_TO_COVER_KEY = "it_conditions_to_cover";
971
972  /**
973   * @since 2.12
974   * @deprecated since 6.2 all coverage reports are merged in the same measures 
975   */
976  @Deprecated
977  public static final Metric<Integer> IT_CONDITIONS_TO_COVER = new Metric.Builder(IT_CONDITIONS_TO_COVER_KEY, "IT Branches to Cover", Metric.ValueType.INT)
978    .setDescription("Integration Tests conditions to cover")
979    .setDirection(Metric.DIRECTION_BETTER)
980    .setQualitative(false)
981    .setDomain(DOMAIN_COVERAGE)
982    .setHidden(true)
983    .create();
984
985  /**
986   * @since 2.12
987   * @deprecated since 6.2 all coverage reports are merged in the same measures 
988   */
989  @Deprecated
990  public static final String NEW_IT_CONDITIONS_TO_COVER_KEY = "new_it_conditions_to_cover";
991
992  /**
993   * @since 2.12
994   * @deprecated since 6.2 all coverage reports are merged in the same measures 
995   */
996  @Deprecated
997  public static final Metric<Integer> NEW_IT_CONDITIONS_TO_COVER = new Metric.Builder(NEW_IT_CONDITIONS_TO_COVER_KEY, "Branches to Cover by IT on New Code", Metric.ValueType.INT)
998    .setDescription("Branches to cover by Integration Tests on New Code")
999    .setDomain(DOMAIN_COVERAGE)
1000    .setDeleteHistoricalData(true)
1001    .setHidden(true)
1002    .create();
1003
1004  /**
1005   * @since 2.12
1006   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1007   */
1008  @Deprecated
1009  public static final String IT_UNCOVERED_CONDITIONS_KEY = "it_uncovered_conditions";
1010
1011  /**
1012   * @since 2.12
1013   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1014   */
1015  @Deprecated
1016  public static final Metric<Integer> IT_UNCOVERED_CONDITIONS = new Metric.Builder(IT_UNCOVERED_CONDITIONS_KEY, "IT Uncovered Conditions", Metric.ValueType.INT)
1017    .setDescription("Uncovered conditions by integration tests")
1018    .setDirection(Metric.DIRECTION_WORST)
1019    .setDomain(DOMAIN_COVERAGE)
1020    .setHidden(true)
1021    .create();
1022
1023  /**
1024   * @since 2.12
1025   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1026   */
1027  @Deprecated
1028  public static final String NEW_IT_UNCOVERED_CONDITIONS_KEY = "new_it_uncovered_conditions";
1029
1030  /**
1031   * @since 2.12
1032   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1033   */
1034  @Deprecated
1035  public static final Metric<Integer> NEW_IT_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_IT_UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions by IT on New Code",
1036    Metric.ValueType.INT)
1037      .setDescription("New conditions that are not covered by integration tests")
1038      .setDirection(Metric.DIRECTION_WORST)
1039      .setDomain(DOMAIN_COVERAGE)
1040      .setBestValue(0.0)
1041      .setDeleteHistoricalData(true)
1042      .setHidden(true)
1043      .create();
1044
1045  /**
1046   * @since 2.12
1047   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1048   */
1049  @Deprecated
1050  public static final String IT_BRANCH_COVERAGE_KEY = "it_branch_coverage";
1051
1052  /**
1053   * @since 2.12
1054   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1055   */
1056  @Deprecated
1057  public static final Metric<Double> IT_BRANCH_COVERAGE = new Metric.Builder(IT_BRANCH_COVERAGE_KEY, "IT Condition Coverage", Metric.ValueType.PERCENT)
1058    .setDescription("Condition coverage by integration tests")
1059    .setDirection(Metric.DIRECTION_BETTER)
1060    .setQualitative(true)
1061    .setDomain(DOMAIN_COVERAGE)
1062    .setWorstValue(0.0)
1063    .setBestValue(100.0)
1064    .setHidden(true)
1065    .create();
1066
1067  /**
1068   * @since 2.12
1069   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1070   */
1071  @Deprecated
1072  public static final String NEW_IT_BRANCH_COVERAGE_KEY = "new_it_branch_coverage";
1073
1074  /**
1075   * @since 2.12
1076   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1077   */
1078  @Deprecated
1079  public static final Metric<Double> NEW_IT_BRANCH_COVERAGE = new Metric.Builder(NEW_IT_BRANCH_COVERAGE_KEY, "Condition Coverage by IT on New Code", Metric.ValueType.PERCENT)
1080    .setDescription("Integration tests condition coverage of new/changed code")
1081    .setDirection(Metric.DIRECTION_BETTER)
1082    .setQualitative(true)
1083    .setDomain(DOMAIN_COVERAGE)
1084    .setWorstValue(0.0)
1085    .setBestValue(100.0)
1086    .setDeleteHistoricalData(true)
1087    .setHidden(true)
1088    .create();
1089
1090  /**
1091   * @since 2.12
1092   * @deprecated since 5.2 soon to be removed
1093   */
1094  @Deprecated
1095  public static final String IT_CONDITIONS_BY_LINE_KEY = "it_conditions_by_line";
1096
1097  /**
1098   * @since 2.12
1099   * @deprecated since 5.2 soon to be removed
1100   */
1101  @Deprecated
1102  public static final Metric<String> IT_CONDITIONS_BY_LINE = new Metric.Builder(IT_CONDITIONS_BY_LINE_KEY, "IT Conditions by Line", Metric.ValueType.DATA)
1103    .setDescription("IT conditions by line")
1104    .setDomain(DOMAIN_COVERAGE)
1105    .setDeleteHistoricalData(true)
1106    .create();
1107
1108  /**
1109   * @since 2.12
1110   * @deprecated since 5.2 soon to be removed
1111   */
1112  @Deprecated
1113  public static final String IT_COVERED_CONDITIONS_BY_LINE_KEY = "it_covered_conditions_by_line";
1114
1115  /**
1116   * @since 2.12
1117   * @deprecated since 5.2 soon to be removed
1118   */
1119  @Deprecated
1120  public static final Metric<String> IT_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(IT_COVERED_CONDITIONS_BY_LINE_KEY, "IT Covered Conditions by Line", Metric.ValueType.DATA)
1121    .setDescription("IT covered conditions by line")
1122    .setDomain(DOMAIN_COVERAGE)
1123    .setDeleteHistoricalData(true)
1124    .create();
1125
1126  // --------------------------------------------------------------------------------------------------------------------
1127  //
1128  // OVERALL TESTS
1129  //
1130  // --------------------------------------------------------------------------------------------------------------------
1131
1132  /**
1133   * @since 3.3
1134   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1135   */
1136  @Deprecated
1137  public static final String OVERALL_COVERAGE_KEY = "overall_coverage";
1138
1139  /**
1140   * @since 3.3
1141   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1142   */
1143  @Deprecated
1144  public static final Metric<Double> OVERALL_COVERAGE = new Metric.Builder(OVERALL_COVERAGE_KEY, "Overall Coverage", Metric.ValueType.PERCENT)
1145    .setDescription("Overall test coverage")
1146    .setDirection(Metric.DIRECTION_BETTER)
1147    .setQualitative(true)
1148    .setDomain(DOMAIN_COVERAGE)
1149    .setWorstValue(0.0)
1150    .setBestValue(100.0)
1151    .setHidden(true)
1152    .create();
1153
1154  /**
1155   * @since 3.3
1156   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1157   */
1158  @Deprecated
1159  public static final String NEW_OVERALL_COVERAGE_KEY = "new_overall_coverage";
1160
1161  /**
1162   * @since 3.3
1163   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1164   */
1165  @Deprecated
1166  public static final Metric<Double> NEW_OVERALL_COVERAGE = new Metric.Builder(NEW_OVERALL_COVERAGE_KEY, "Overall Coverage on New Code", Metric.ValueType.PERCENT)
1167    .setDescription("Overall coverage of new/changed code")
1168    .setDirection(Metric.DIRECTION_BETTER)
1169    .setQualitative(true)
1170    .setDomain(DOMAIN_COVERAGE)
1171    .setWorstValue(0.0)
1172    .setBestValue(100.0)
1173    .setDeleteHistoricalData(true)
1174    .setHidden(true)
1175    .create();
1176
1177  /**
1178   * @since 3.3
1179   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1180   */
1181  @Deprecated
1182  public static final String OVERALL_LINES_TO_COVER_KEY = "overall_lines_to_cover";
1183
1184  /**
1185   * @since 3.3
1186   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1187   */
1188  @Deprecated
1189  public static final Metric<Integer> OVERALL_LINES_TO_COVER = new Metric.Builder(OVERALL_LINES_TO_COVER_KEY, "Overall Lines to Cover", Metric.ValueType.INT)
1190    .setDescription("Overall lines to cover by all tests")
1191    .setDirection(Metric.DIRECTION_BETTER)
1192    .setDomain(DOMAIN_COVERAGE)
1193    .setQualitative(false)
1194    .setHidden(true)
1195    .create();
1196
1197  /**
1198   * @since 3.3
1199   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1200   */
1201  @Deprecated
1202  public static final String NEW_OVERALL_LINES_TO_COVER_KEY = "new_overall_lines_to_cover";
1203
1204  /**
1205   * @since 3.3
1206   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1207   */
1208  @Deprecated
1209  public static final Metric<Integer> NEW_OVERALL_LINES_TO_COVER = new Metric.Builder(NEW_OVERALL_LINES_TO_COVER_KEY, "Overall Lines to Cover on New Code", Metric.ValueType.INT)
1210    .setDescription("New lines to cover by all tests")
1211    .setDirection(Metric.DIRECTION_WORST)
1212    .setQualitative(false)
1213    .setDomain(DOMAIN_COVERAGE)
1214    .setDeleteHistoricalData(true)
1215    .setHidden(true)
1216    .create();
1217
1218  /**
1219   * @since 3.3
1220   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1221   */
1222  @Deprecated
1223  public static final String OVERALL_UNCOVERED_LINES_KEY = "overall_uncovered_lines";
1224
1225  /**
1226   * @since 3.3
1227   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1228   */
1229  @Deprecated
1230  public static final Metric<Integer> OVERALL_UNCOVERED_LINES = new Metric.Builder(OVERALL_UNCOVERED_LINES_KEY, "Overall Uncovered Lines", Metric.ValueType.INT)
1231    .setDescription("Uncovered lines by all tests")
1232    .setDirection(Metric.DIRECTION_WORST)
1233    .setQualitative(false)
1234    .setDomain(DOMAIN_COVERAGE)
1235    .setHidden(true)
1236    .create();
1237
1238  /**
1239   * @since 3.3
1240   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1241   */
1242  @Deprecated
1243  public static final String NEW_OVERALL_UNCOVERED_LINES_KEY = "new_overall_uncovered_lines";
1244
1245  /**
1246   * @since 3.3
1247   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1248   */
1249  @Deprecated
1250  public static final Metric<Integer> NEW_OVERALL_UNCOVERED_LINES = new Metric.Builder(NEW_OVERALL_UNCOVERED_LINES_KEY, "Overall Uncovered Lines on New Code", Metric.ValueType.INT)
1251    .setDescription("New lines that are not covered by any tests")
1252    .setDirection(Metric.DIRECTION_WORST)
1253    .setDomain(DOMAIN_COVERAGE)
1254    .setBestValue(0.0)
1255    .setDeleteHistoricalData(true)
1256    .setHidden(true)
1257    .create();
1258
1259  /**
1260   * @since 3.3
1261   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1262   */
1263  @Deprecated
1264  public static final String OVERALL_LINE_COVERAGE_KEY = "overall_line_coverage";
1265
1266  /**
1267   * @since 3.3
1268   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1269   */
1270  @Deprecated
1271  public static final Metric<Double> OVERALL_LINE_COVERAGE = new Metric.Builder(OVERALL_LINE_COVERAGE_KEY, "Overall Line Coverage", Metric.ValueType.PERCENT)
1272    .setDescription("Line coverage by all tests")
1273    .setDirection(Metric.DIRECTION_BETTER)
1274    .setQualitative(true)
1275    .setDomain(DOMAIN_COVERAGE)
1276    .setHidden(true)
1277    .create();
1278
1279  /**
1280   * @since 3.3
1281   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1282   */
1283  @Deprecated
1284  public static final String NEW_OVERALL_LINE_COVERAGE_KEY = "new_overall_line_coverage";
1285
1286  /**
1287   * @since 3.3
1288   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1289   */
1290  @Deprecated
1291  public static final Metric<Double> NEW_OVERALL_LINE_COVERAGE = new Metric.Builder(NEW_OVERALL_LINE_COVERAGE_KEY, "Overall Line Coverage on New Code", Metric.ValueType.PERCENT)
1292    .setDescription("Line coverage of added/changed code by all tests")
1293    .setDirection(Metric.DIRECTION_BETTER)
1294    .setQualitative(true)
1295    .setWorstValue(0.0)
1296    .setBestValue(100.0)
1297    .setDomain(DOMAIN_COVERAGE)
1298    .setDeleteHistoricalData(true)
1299    .setHidden(true)
1300    .create();
1301
1302  /**
1303   * @since 3.3
1304   * @deprecated since 5.2 soon to be removed
1305   */
1306  @Deprecated
1307  public static final String OVERALL_COVERAGE_LINE_HITS_DATA_KEY = "overall_coverage_line_hits_data";
1308
1309  /**
1310   * @since 3.3
1311   * @deprecated since 5.2 soon to be removed
1312   */
1313  @Deprecated
1314  public static final Metric<String> OVERALL_COVERAGE_LINE_HITS_DATA = new Metric.Builder(OVERALL_COVERAGE_LINE_HITS_DATA_KEY, "Overall Coverage Hits by Line",
1315    Metric.ValueType.DATA)
1316      .setDescription("Coverage hits by all tests and by line")
1317      .setDirection(Metric.DIRECTION_NONE)
1318      .setQualitative(false)
1319      .setDomain(DOMAIN_COVERAGE)
1320      .setDeleteHistoricalData(true)
1321      .create();
1322
1323  /**
1324   * @since 3.3
1325   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1326   */
1327  @Deprecated
1328  public static final String OVERALL_CONDITIONS_TO_COVER_KEY = "overall_conditions_to_cover";
1329
1330  /**
1331   * @since 3.3
1332   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1333   */
1334  @Deprecated
1335  public static final Metric<Integer> OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(OVERALL_CONDITIONS_TO_COVER_KEY, "Overall Branches to Cover", Metric.ValueType.INT)
1336    .setDescription("Branches to cover by all tests")
1337    .setDirection(Metric.DIRECTION_BETTER)
1338    .setQualitative(false)
1339    .setDomain(DOMAIN_COVERAGE)
1340    .setHidden(true)
1341    .create();
1342
1343  /**
1344   * @since 3.3
1345   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1346   */
1347  @Deprecated
1348  public static final String NEW_OVERALL_CONDITIONS_TO_COVER_KEY = "new_overall_conditions_to_cover";
1349
1350  /**
1351   * @since 3.3
1352   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1353   */
1354  @Deprecated
1355  public static final Metric<Integer> NEW_OVERALL_CONDITIONS_TO_COVER = new Metric.Builder(NEW_OVERALL_CONDITIONS_TO_COVER_KEY, "Overall Branches to Cover on New Code",
1356    Metric.ValueType.INT)
1357      .setDescription("New branches to cover by all tests")
1358      .setDomain(DOMAIN_COVERAGE)
1359      .setDeleteHistoricalData(true)
1360      .setHidden(true)
1361      .create();
1362
1363  /**
1364   * @since 3.3
1365   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1366   */
1367  @Deprecated
1368  public static final String OVERALL_UNCOVERED_CONDITIONS_KEY = "overall_uncovered_conditions";
1369
1370  /**
1371   * @since 3.3
1372   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1373   */
1374  @Deprecated
1375  public static final Metric<Integer> OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall Uncovered Conditions", Metric.ValueType.INT)
1376    .setDescription("Uncovered conditions by all tests")
1377    .setDirection(Metric.DIRECTION_WORST)
1378    .setDomain(DOMAIN_COVERAGE)
1379    .setHidden(true)
1380    .create();
1381
1382  /**
1383   * @since 3.3
1384   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1385   */
1386  @Deprecated
1387  public static final String NEW_OVERALL_UNCOVERED_CONDITIONS_KEY = "new_overall_uncovered_conditions";
1388
1389  /**
1390   * @since 3.3
1391   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1392   */
1393  @Deprecated
1394  public static final Metric<Integer> NEW_OVERALL_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_OVERALL_UNCOVERED_CONDITIONS_KEY, "Overall Uncovered Conditions on New Code",
1395    Metric.ValueType.INT)
1396      .setDescription("New conditions that are not covered by any test")
1397      .setDirection(Metric.DIRECTION_WORST)
1398      .setDomain(DOMAIN_COVERAGE)
1399      .setBestValue(0.0)
1400      .setDeleteHistoricalData(true)
1401      .setHidden(true)
1402      .create();
1403
1404  /**
1405   * @since 3.3
1406   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1407   */
1408  @Deprecated
1409  public static final String OVERALL_BRANCH_COVERAGE_KEY = "overall_branch_coverage";
1410
1411  /**
1412   * @since 3.3
1413   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1414   */
1415  @Deprecated
1416  public static final Metric<Double> OVERALL_BRANCH_COVERAGE = new Metric.Builder(OVERALL_BRANCH_COVERAGE_KEY, "Overall Condition Coverage", Metric.ValueType.PERCENT)
1417    .setDescription("Condition coverage by all tests")
1418    .setDirection(Metric.DIRECTION_BETTER)
1419    .setQualitative(true)
1420    .setDomain(DOMAIN_COVERAGE)
1421    .setWorstValue(0.0)
1422    .setBestValue(100.0)
1423    .setHidden(true)
1424    .create();
1425
1426  /**
1427   * @since 3.3
1428   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1429   */
1430  @Deprecated
1431  public static final String NEW_OVERALL_BRANCH_COVERAGE_KEY = "new_overall_branch_coverage";
1432
1433  /**
1434   * @since 3.3
1435   * @deprecated since 6.2 all coverage reports are merged in the same measures 
1436   */
1437  @Deprecated
1438  public static final Metric<Double> NEW_OVERALL_BRANCH_COVERAGE = new Metric.Builder(NEW_OVERALL_BRANCH_COVERAGE_KEY, "Overall Condition Coverage on New Code",
1439    Metric.ValueType.PERCENT)
1440      .setDescription("Condition coverage of new/changed code by all tests")
1441      .setDirection(Metric.DIRECTION_BETTER)
1442      .setQualitative(true)
1443      .setDomain(DOMAIN_COVERAGE)
1444      .setWorstValue(0.0)
1445      .setBestValue(100.0)
1446      .setDeleteHistoricalData(true)
1447      .setHidden(true)
1448      .create();
1449
1450  /**
1451   * @since 3.3
1452   * @deprecated since 5.2 soon to be removed
1453   */
1454  @Deprecated
1455  public static final String OVERALL_CONDITIONS_BY_LINE_KEY = "overall_conditions_by_line";
1456
1457  /**
1458   * @since 3.3
1459   * @deprecated since 5.2 soon to be removed
1460   */
1461  @Deprecated
1462  public static final Metric<String> OVERALL_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_CONDITIONS_BY_LINE_KEY, "Overall Conditions by Line", Metric.ValueType.DATA)
1463    .setDescription("Overall conditions by all tests and by line")
1464    .setDomain(DOMAIN_COVERAGE)
1465    .setDeleteHistoricalData(true)
1466    .create();
1467
1468  /**
1469   * @since 3.3
1470   * @deprecated since 5.2 soon to be removed
1471   */
1472  @Deprecated
1473  public static final String OVERALL_COVERED_CONDITIONS_BY_LINE_KEY = "overall_covered_conditions_by_line";
1474
1475  /**
1476   * @since 3.3
1477   * @deprecated since 5.2 soon to be removed
1478   */
1479  @Deprecated
1480  public static final Metric<String> OVERALL_COVERED_CONDITIONS_BY_LINE = new Metric.Builder(OVERALL_COVERED_CONDITIONS_BY_LINE_KEY, "Overall Covered Conditions by Line",
1481    Metric.ValueType.DATA)
1482      .setDescription("Overall covered conditions by all tests and by line")
1483      .setDomain(DOMAIN_COVERAGE)
1484      .setDeleteHistoricalData(true)
1485      .create();
1486
1487  // --------------------------------------------------------------------------------------------------------------------
1488  //
1489  // DUPLICATIONS
1490  //
1491  // --------------------------------------------------------------------------------------------------------------------
1492
1493  public static final String DUPLICATED_LINES_KEY = "duplicated_lines";
1494  public static final Metric<Integer> DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated Lines", Metric.ValueType.INT)
1495    .setDescription("Duplicated lines")
1496    .setDirection(Metric.DIRECTION_WORST)
1497    .setQualitative(true)
1498    .setDomain(DOMAIN_DUPLICATIONS)
1499    .setBestValue(0.0)
1500    .setOptimizedBestValue(true)
1501    .create();
1502
1503  /**
1504   * @since 6.1
1505   */
1506  public static final String NEW_DUPLICATED_LINES_KEY = "new_duplicated_lines";
1507
1508  /**
1509   * @since 6.1
1510   */
1511  public static final Metric<Integer> NEW_DUPLICATED_LINES = new Metric.Builder(NEW_DUPLICATED_LINES_KEY, "Duplicated Lines on New Code", Metric.ValueType.INT)
1512    .setDescription("Duplicated Lines on New Code")
1513    .setDirection(Metric.DIRECTION_WORST)
1514    .setQualitative(true)
1515    .setDomain(DOMAIN_DUPLICATIONS)
1516    .setBestValue(0.0)
1517    .setDeleteHistoricalData(true)
1518    .create();
1519
1520  public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks";
1521  public static final Metric<Integer> DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated Blocks", Metric.ValueType.INT)
1522    .setDescription("Duplicated blocks")
1523    .setDirection(Metric.DIRECTION_WORST)
1524    .setQualitative(true)
1525    .setDomain(DOMAIN_DUPLICATIONS)
1526    .setBestValue(0.0)
1527    .setOptimizedBestValue(true)
1528    .create();
1529
1530  /**
1531   * @since 6.1
1532    */
1533  public static final String NEW_BLOCKS_DUPLICATED_KEY = "new_duplicated_blocks";
1534  /**
1535   * @since 6.1
1536   */
1537  public static final Metric<Integer> NEW_BLOCKS_DUPLICATED = new Metric.Builder(NEW_BLOCKS_DUPLICATED_KEY, "Duplicated Blocks on New Code", Metric.ValueType.INT)
1538    .setDescription("Duplicated blocks on new code")
1539    .setDirection(Metric.DIRECTION_WORST)
1540    .setQualitative(true)
1541    .setDomain(DOMAIN_DUPLICATIONS)
1542    .setBestValue(0.0)
1543    .setDeleteHistoricalData(true)
1544    .create();
1545
1546  public static final String DUPLICATED_FILES_KEY = "duplicated_files";
1547
1548  /**
1549   * For files: if it contains duplicates, then 1, otherwise 0.
1550   * For other resources: amount of files under this resource with duplicates.
1551   */
1552  public static final Metric<Integer> DUPLICATED_FILES = new Metric.Builder(DUPLICATED_FILES_KEY, "Duplicated Files", Metric.ValueType.INT)
1553    .setDescription("Duplicated files")
1554    .setDirection(Metric.DIRECTION_WORST)
1555    .setQualitative(true)
1556    .setDomain(DOMAIN_DUPLICATIONS)
1557    .setBestValue(0.0)
1558    .setOptimizedBestValue(true)
1559    .create();
1560
1561  public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density";
1562
1563  public static final Metric<Double> DUPLICATED_LINES_DENSITY = new Metric.Builder(DUPLICATED_LINES_DENSITY_KEY, "Duplicated Lines (%)", Metric.ValueType.PERCENT)
1564    .setDescription("Duplicated lines balanced by statements")
1565    .setDirection(Metric.DIRECTION_WORST)
1566    .setQualitative(true)
1567    .setDomain(DOMAIN_DUPLICATIONS)
1568    .setWorstValue(50.0)
1569    .setBestValue(0.0)
1570    .setOptimizedBestValue(true)
1571    .create();
1572
1573  /**
1574   * @since 6.1
1575   */
1576  public static final String NEW_DUPLICATED_LINES_DENSITY_KEY = "new_duplicated_lines_density";
1577
1578  /**
1579   * @since 6.1
1580   */
1581  public static final Metric<Integer> NEW_DUPLICATED_LINES_DENSITY = new Metric.Builder(NEW_DUPLICATED_LINES_DENSITY_KEY, "Duplicated Lines on New Code (%)",
1582    Metric.ValueType.PERCENT)
1583      .setDescription("Duplicated lines on new code balanced by statements")
1584      .setDirection(Metric.DIRECTION_WORST)
1585      .setQualitative(true)
1586      .setDomain(DOMAIN_DUPLICATIONS)
1587      .setBestValue(0.0)
1588      .setDeleteHistoricalData(true)
1589      .create();
1590
1591  /**
1592   * @deprecated since 4.5. Internal storage of duplication is not an API.
1593   */
1594  @Deprecated
1595  public static final String DUPLICATIONS_DATA_KEY = "duplications_data";
1596
1597  /**
1598   * Information about duplications, which is represented as an XML string.
1599   * <p>
1600   * Here is the format (since Sonar 2.12):
1601   * <pre>
1602   * {@literal
1603   * <duplications>
1604   *   <!-- Multiple groups: -->
1605   *   <g>
1606   *     <!-- Multiple blocks: -->
1607   *     <b r="[resource key]" s="[first line]" l="[number of lines]" />
1608   *     ...
1609   *   </g>
1610   *   ...
1611   * </duplications>
1612   * }
1613   * </pre>
1614   *
1615   * @deprecated since 4.5. Internal storage of duplication is not an API.
1616   */
1617  @Deprecated
1618  public static final Metric<String> DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplication Details", Metric.ValueType.DATA)
1619    .setDescription("Duplications details")
1620    .setDirection(Metric.DIRECTION_NONE)
1621    .setQualitative(false)
1622    .setDomain(DOMAIN_DUPLICATIONS)
1623    .setDeleteHistoricalData(true)
1624    .create();
1625
1626  // --------------------------------------------------------------------------------------------------------------------
1627  //
1628  // CODING RULES
1629  //
1630  // --------------------------------------------------------------------------------------------------------------------
1631
1632  public static final String VIOLATIONS_KEY = "violations";
1633  public static final Metric<Integer> VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT)
1634    .setDescription("Issues")
1635    .setDirection(Metric.DIRECTION_WORST)
1636    .setQualitative(true)
1637    .setDomain(DOMAIN_ISSUES)
1638    .setBestValue(0.0)
1639    .setOptimizedBestValue(true)
1640    .create();
1641
1642  public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations";
1643  public static final Metric<Integer> BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker Issues", Metric.ValueType.INT)
1644    .setDescription("Blocker issues")
1645    .setDirection(Metric.DIRECTION_WORST)
1646    .setQualitative(true)
1647    .setDomain(DOMAIN_ISSUES)
1648    .setBestValue(0.0)
1649    .setOptimizedBestValue(true)
1650    .create();
1651
1652  public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations";
1653  public static final Metric<Integer> CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical Issues", Metric.ValueType.INT)
1654    .setDescription("Critical issues")
1655    .setDirection(Metric.DIRECTION_WORST)
1656    .setQualitative(true)
1657    .setDomain(DOMAIN_ISSUES)
1658    .setBestValue(0.0)
1659    .setOptimizedBestValue(true)
1660    .create();
1661
1662  public static final String MAJOR_VIOLATIONS_KEY = "major_violations";
1663  public static final Metric<Integer> MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major Issues", Metric.ValueType.INT)
1664    .setDescription("Major issues")
1665    .setDirection(Metric.DIRECTION_WORST)
1666    .setQualitative(true)
1667    .setDomain(DOMAIN_ISSUES)
1668    .setBestValue(0.0)
1669    .setOptimizedBestValue(true)
1670    .create();
1671
1672  public static final String MINOR_VIOLATIONS_KEY = "minor_violations";
1673  public static final Metric<Integer> MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor Issues", Metric.ValueType.INT)
1674    .setDescription("Minor issues")
1675    .setDirection(Metric.DIRECTION_WORST)
1676    .setQualitative(true)
1677    .setDomain(DOMAIN_ISSUES)
1678    .setBestValue(0.0)
1679    .setOptimizedBestValue(true)
1680    .create();
1681
1682  public static final String INFO_VIOLATIONS_KEY = "info_violations";
1683  public static final Metric<Integer> INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info Issues", Metric.ValueType.INT)
1684    .setDescription("Info issues")
1685    .setDirection(Metric.DIRECTION_WORST)
1686    .setQualitative(true)
1687    .setDomain(DOMAIN_ISSUES)
1688    .setBestValue(0.0)
1689    .setOptimizedBestValue(true)
1690    .create();
1691
1692  public static final String NEW_VIOLATIONS_KEY = "new_violations";
1693  public static final Metric<Integer> NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New Issues", Metric.ValueType.INT)
1694    .setDescription("New issues")
1695    .setDirection(Metric.DIRECTION_WORST)
1696    .setQualitative(true)
1697    .setDomain(DOMAIN_ISSUES)
1698    .setBestValue(0.0)
1699    .setOptimizedBestValue(true)
1700    .setDeleteHistoricalData(true)
1701    .create();
1702
1703  public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations";
1704  public static final Metric<Integer> NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker Issues", Metric.ValueType.INT)
1705    .setDescription("New Blocker issues")
1706    .setDirection(Metric.DIRECTION_WORST)
1707    .setQualitative(true)
1708    .setDomain(DOMAIN_ISSUES)
1709    .setBestValue(0.0)
1710    .setOptimizedBestValue(true)
1711    .setDeleteHistoricalData(true)
1712    .create();
1713
1714  public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations";
1715  public static final Metric<Integer> NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical Issues", Metric.ValueType.INT)
1716    .setDescription("New Critical issues")
1717    .setDirection(Metric.DIRECTION_WORST)
1718    .setQualitative(true)
1719    .setDomain(DOMAIN_ISSUES)
1720    .setBestValue(0.0)
1721    .setOptimizedBestValue(true)
1722    .setDeleteHistoricalData(true)
1723    .create();
1724
1725  public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations";
1726  public static final Metric<Integer> NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major Issues", Metric.ValueType.INT)
1727    .setDescription("New Major issues")
1728    .setDirection(Metric.DIRECTION_WORST)
1729    .setQualitative(true)
1730    .setDomain(DOMAIN_ISSUES)
1731    .setBestValue(0.0)
1732    .setOptimizedBestValue(true)
1733    .setDeleteHistoricalData(true)
1734    .create();
1735
1736  public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations";
1737  public static final Metric<Integer> NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor Issues", Metric.ValueType.INT)
1738    .setDescription("New Minor issues")
1739    .setDirection(Metric.DIRECTION_WORST)
1740    .setQualitative(true)
1741    .setDomain(DOMAIN_ISSUES)
1742    .setBestValue(0.0)
1743    .setOptimizedBestValue(true)
1744    .setDeleteHistoricalData(true)
1745    .create();
1746
1747  public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations";
1748  public static final Metric<Integer> NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info Issues", Metric.ValueType.INT)
1749    .setDescription("New Info issues")
1750    .setDirection(Metric.DIRECTION_WORST)
1751    .setQualitative(true)
1752    .setDomain(DOMAIN_ISSUES)
1753    .setBestValue(0.0)
1754    .setOptimizedBestValue(true)
1755    .setDeleteHistoricalData(true)
1756    .create();
1757
1758  /**
1759   * @since 3.6
1760   */
1761  public static final String FALSE_POSITIVE_ISSUES_KEY = "false_positive_issues";
1762
1763  /**
1764   * @since 3.6
1765   */
1766  public static final Metric<Integer> FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False Positive Issues", Metric.ValueType.INT)
1767    .setDescription("False positive issues")
1768    .setDirection(Metric.DIRECTION_WORST)
1769    .setDomain(DOMAIN_ISSUES)
1770    .setBestValue(0.0)
1771    .setOptimizedBestValue(true)
1772    .create();
1773
1774  /**
1775   * @since 5.6
1776   */
1777  public static final String WONT_FIX_ISSUES_KEY = "wont_fix_issues";
1778
1779  /**
1780   * @since 5.6
1781   */
1782  public static final Metric<Integer> WONT_FIX_ISSUES = new Metric.Builder(WONT_FIX_ISSUES_KEY, "Won't Fix Issues", Metric.ValueType.INT)
1783    .setDescription("Won't fix issues")
1784    .setDirection(Metric.DIRECTION_WORST)
1785    .setDomain(DOMAIN_ISSUES)
1786    .setBestValue(0.0)
1787    .setOptimizedBestValue(true)
1788    .create();
1789
1790  /**
1791   * @since 3.6
1792   */
1793  public static final String OPEN_ISSUES_KEY = "open_issues";
1794
1795  /**
1796   * @since 3.6
1797   */
1798  public static final Metric<Integer> OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open Issues", Metric.ValueType.INT)
1799    .setDescription("Open issues")
1800    .setDirection(Metric.DIRECTION_WORST)
1801    .setDomain(DOMAIN_ISSUES)
1802    .setBestValue(0.0)
1803    .setOptimizedBestValue(true)
1804    .create();
1805
1806  /**
1807   * @since 3.6
1808   */
1809  public static final String REOPENED_ISSUES_KEY = "reopened_issues";
1810
1811  /**
1812   * @since 3.6
1813   */
1814  public static final Metric<Integer> REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened Issues", Metric.ValueType.INT)
1815    .setDescription("Reopened issues")
1816    .setDirection(Metric.DIRECTION_WORST)
1817    .setQualitative(true)
1818    .setDomain(DOMAIN_ISSUES)
1819    .setBestValue(0.0)
1820    .setOptimizedBestValue(true)
1821    .create();
1822
1823  /**
1824   * @since 3.6
1825   */
1826  public static final String CONFIRMED_ISSUES_KEY = "confirmed_issues";
1827
1828  /**
1829   * @since 3.6
1830   */
1831  public static final Metric<Integer> CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed Issues", Metric.ValueType.INT)
1832    .setDescription("Confirmed issues")
1833    .setDirection(Metric.DIRECTION_WORST)
1834    .setQualitative(true)
1835    .setDomain(DOMAIN_ISSUES)
1836    .setBestValue(0.0)
1837    .setOptimizedBestValue(true)
1838    .create();
1839
1840  /**
1841   * SonarQube Quality Model
1842   * @since 5.5
1843   */
1844  public static final String CODE_SMELLS_KEY = "code_smells";
1845
1846  /**
1847   * SonarQube Quality Model
1848   * @since 5.5
1849   */
1850  public static final Metric<Integer> CODE_SMELLS = new Metric.Builder(CODE_SMELLS_KEY, "Code Smells", Metric.ValueType.INT)
1851    .setDescription("Code Smells")
1852    .setDirection(Metric.DIRECTION_WORST)
1853    .setQualitative(false)
1854    .setDomain(DOMAIN_MAINTAINABILITY)
1855    .setBestValue(0.0)
1856    .setOptimizedBestValue(true)
1857    .create();
1858
1859  /**
1860   * SonarQube Quality Model
1861   * @since 5.5
1862   */
1863  public static final String NEW_CODE_SMELLS_KEY = "new_code_smells";
1864
1865  /**
1866   * SonarQube Quality Model
1867   * @since 5.5
1868   */
1869  public static final Metric<Integer> NEW_CODE_SMELLS = new Metric.Builder(NEW_CODE_SMELLS_KEY, "New Code Smells", Metric.ValueType.INT)
1870    .setDescription("New Code Smells")
1871    .setDirection(Metric.DIRECTION_WORST)
1872    .setQualitative(true)
1873    .setDomain(DOMAIN_MAINTAINABILITY)
1874    .setBestValue(0.0)
1875    .setOptimizedBestValue(true)
1876    .setDeleteHistoricalData(true)
1877    .create();
1878
1879  /**
1880   * SonarQube Quality Model
1881   * @since 5.5
1882   */
1883  public static final String BUGS_KEY = "bugs";
1884
1885  /**
1886   * SonarQube Quality Model
1887   * @since 5.5
1888   */
1889  public static final Metric<Integer> BUGS = new Metric.Builder(BUGS_KEY, "Bugs", Metric.ValueType.INT)
1890    .setDescription("Bugs")
1891    .setDirection(Metric.DIRECTION_WORST)
1892    .setQualitative(false)
1893    .setDomain(DOMAIN_RELIABILITY)
1894    .setBestValue(0.0)
1895    .setOptimizedBestValue(true)
1896    .create();
1897
1898  /**
1899   * SonarQube Quality Model
1900   * @since 5.5
1901   */
1902  public static final String NEW_BUGS_KEY = "new_bugs";
1903
1904  /**
1905   * SonarQube Quality Model
1906   * @since 5.5
1907   */
1908  public static final Metric<Integer> NEW_BUGS = new Metric.Builder(NEW_BUGS_KEY, "New Bugs", Metric.ValueType.INT)
1909    .setDescription("New Bugs")
1910    .setDirection(Metric.DIRECTION_WORST)
1911    .setQualitative(true)
1912    .setDomain(DOMAIN_RELIABILITY)
1913    .setBestValue(0.0)
1914    .setOptimizedBestValue(true)
1915    .setDeleteHistoricalData(true)
1916    .create();
1917
1918  /**
1919   * SonarQube Quality Model
1920   * @since 5.5
1921   */
1922  public static final String VULNERABILITIES_KEY = "vulnerabilities";
1923
1924  /**
1925   * SonarQube Quality Model
1926   * @since 5.5
1927   */
1928  public static final Metric<Integer> VULNERABILITIES = new Metric.Builder(VULNERABILITIES_KEY, "Vulnerabilities", Metric.ValueType.INT)
1929    .setDescription("Vulnerabilities")
1930    .setDirection(Metric.DIRECTION_WORST)
1931    .setQualitative(false)
1932    .setDomain(DOMAIN_SECURITY)
1933    .setBestValue(0.0)
1934    .setOptimizedBestValue(true)
1935    .create();
1936
1937  /**
1938   * SonarQube Quality Model
1939   * @since 5.5
1940   */
1941  public static final String NEW_VULNERABILITIES_KEY = "new_vulnerabilities";
1942
1943  /**
1944   * SonarQube Quality Model
1945   * @since 5.5
1946   */
1947  public static final Metric<Integer> NEW_VULNERABILITIES = new Metric.Builder(NEW_VULNERABILITIES_KEY, "New Vulnerabilities", Metric.ValueType.INT)
1948    .setDescription("New Vulnerabilities")
1949    .setDirection(Metric.DIRECTION_WORST)
1950    .setQualitative(true)
1951    .setDomain(DOMAIN_SECURITY)
1952    .setBestValue(0.0)
1953    .setOptimizedBestValue(true)
1954    .setDeleteHistoricalData(true)
1955    .create();
1956
1957  // --------------------------------------------------------------------------------------------------------------------
1958  //
1959  // DESIGN
1960  //
1961  // --------------------------------------------------------------------------------------------------------------------
1962
1963  /**
1964   * @deprecated since 5.0 this is an internal metric that should not be accessed by plugins
1965   */
1966  @Deprecated
1967  public static final String DEPENDENCY_MATRIX_KEY = "dsm";
1968  /**
1969   * @deprecated since 5.0 this is an internal metric that should not be accessed by plugins
1970   */
1971  @Deprecated
1972  public static final transient Metric<String> DEPENDENCY_MATRIX = new Metric.Builder(DEPENDENCY_MATRIX_KEY, "Dependency Matrix", Metric.ValueType.DATA)
1973    .setDescription("Dependency Matrix")
1974    .setDirection(Metric.DIRECTION_NONE)
1975    .setQualitative(false)
1976    .setDomain(DOMAIN_DESIGN)
1977    .setDeleteHistoricalData(true)
1978    .create();
1979
1980  /**
1981   * @deprecated since 5.2 No more design features
1982   */
1983  @Deprecated
1984  public static final String DIRECTORY_CYCLES_KEY = "package_cycles";
1985  /**
1986   * @deprecated since 5.2 No more design features
1987   */
1988  @Deprecated
1989  public static final transient Metric<Integer> DIRECTORY_CYCLES = new Metric.Builder(DIRECTORY_CYCLES_KEY, "Directory Cycles", Metric.ValueType.INT)
1990    .setDescription("Directory cycles")
1991    .setDirection(Metric.DIRECTION_WORST)
1992    .setQualitative(true)
1993    .setDomain(DOMAIN_DESIGN)
1994    .setBestValue(0.0)
1995    .create();
1996
1997  /**
1998   * @deprecated since 5.0 use {@link #DIRECTORY_CYCLES_KEY}
1999   */
2000  @Deprecated
2001  public static final String PACKAGE_CYCLES_KEY = DIRECTORY_CYCLES_KEY;
2002  /**
2003   * @deprecated since 5.0 use {@link #DIRECTORY_CYCLES}
2004   */
2005  @Deprecated
2006  public static final transient Metric<Integer> PACKAGE_CYCLES = DIRECTORY_CYCLES;
2007
2008  /**
2009   * @deprecated since 5.2 No more design features
2010   */
2011  @Deprecated
2012  public static final String DIRECTORY_TANGLE_INDEX_KEY = "package_tangle_index";
2013  /**
2014   * @deprecated since 5.2 No more design features
2015   */
2016  @Deprecated
2017  public static final transient Metric<Double> DIRECTORY_TANGLE_INDEX = new Metric.Builder(DIRECTORY_TANGLE_INDEX_KEY, "Directory Tangle Index", Metric.ValueType.PERCENT)
2018    .setDescription("Directory tangle index")
2019    .setDirection(Metric.DIRECTION_WORST)
2020    .setQualitative(true)
2021    .setBestValue(0.0)
2022    .setDomain(DOMAIN_DESIGN)
2023    .create();
2024
2025  /**
2026   * @deprecated since 5.0 use {@link #DIRECTORY_TANGLE_INDEX_KEY}
2027   */
2028  @Deprecated
2029  public static final String PACKAGE_TANGLE_INDEX_KEY = DIRECTORY_TANGLE_INDEX_KEY;
2030  /**
2031   * @deprecated since 5.0 use {@link #DIRECTORY_TANGLE_INDEX}
2032   */
2033  @Deprecated
2034  public static final transient Metric<Double> PACKAGE_TANGLE_INDEX = DIRECTORY_TANGLE_INDEX;
2035
2036  /**
2037   * @deprecated since 5.2 No more design features
2038   */
2039  @Deprecated
2040  public static final String DIRECTORY_TANGLES_KEY = "package_tangles";
2041  /**
2042   * @deprecated since 5.2 No more design features
2043   */
2044  @Deprecated
2045  public static final transient Metric<Integer> DIRECTORY_TANGLES = new Metric.Builder(DIRECTORY_TANGLES_KEY, "File Dependencies to Cut", Metric.ValueType.INT)
2046    .setDescription("File dependencies to cut")
2047    .setDirection(Metric.DIRECTION_WORST)
2048    .setQualitative(false)
2049    .setDomain(DOMAIN_DESIGN)
2050    .create();
2051
2052  /**
2053   * @deprecated since 5.0 use {@link #DIRECTORY_TANGLES_KEY}
2054   */
2055  @Deprecated
2056  public static final String PACKAGE_TANGLES_KEY = DIRECTORY_TANGLES_KEY;
2057  /**
2058   * @deprecated since 5.0 use {@link #DIRECTORY_TANGLES}
2059   */
2060  @Deprecated
2061  public static final transient Metric<Integer> PACKAGE_TANGLES = DIRECTORY_TANGLES;
2062
2063  /**
2064   * @deprecated since 5.2 No more design features
2065   */
2066  @Deprecated
2067  public static final String DIRECTORY_FEEDBACK_EDGES_KEY = "package_feedback_edges";
2068  /**
2069   * @deprecated since 5.2 No more design features
2070   */
2071  @Deprecated
2072  public static final transient Metric<Integer> DIRECTORY_FEEDBACK_EDGES = new Metric.Builder(DIRECTORY_FEEDBACK_EDGES_KEY, "Package Dependencies to Cut", Metric.ValueType.INT)
2073    .setDescription("Package dependencies to cut")
2074    .setDirection(Metric.DIRECTION_WORST)
2075    .setQualitative(false)
2076    .setDomain(DOMAIN_DESIGN)
2077    .setBestValue(0.0)
2078    .create();
2079
2080  /**
2081   * @deprecated since 5.0 use {@link #DIRECTORY_FEEDBACK_EDGES_KEY}
2082   */
2083  @Deprecated
2084  public static final String PACKAGE_FEEDBACK_EDGES_KEY = DIRECTORY_FEEDBACK_EDGES_KEY;
2085  /**
2086   * @deprecated since 5.0 use {@link #DIRECTORY_FEEDBACK_EDGES}
2087   */
2088  @Deprecated
2089  public static final transient Metric<Integer> PACKAGE_FEEDBACK_EDGES = DIRECTORY_FEEDBACK_EDGES;
2090
2091  /**
2092   * @deprecated since 5.2 No more design features
2093   */
2094  @Deprecated
2095  public static final String DIRECTORY_EDGES_WEIGHT_KEY = "package_edges_weight";
2096  /**
2097   * @deprecated since 5.2 No more design features
2098   */
2099  @Deprecated
2100  public static final transient Metric<Integer> DIRECTORY_EDGES_WEIGHT = new Metric.Builder(DIRECTORY_EDGES_WEIGHT_KEY, "Directory Edges Weight", Metric.ValueType.INT)
2101    .setDescription("Directory edges weight")
2102    .setDirection(Metric.DIRECTION_BETTER)
2103    .setQualitative(false)
2104    .setDomain(DOMAIN_DESIGN)
2105    .setHidden(true)
2106    .setDeleteHistoricalData(true)
2107    .create();
2108
2109  /**
2110   * @deprecated since 5.0 use {@link #DIRECTORY_EDGES_WEIGHT_KEY}
2111   */
2112  @Deprecated
2113  public static final String PACKAGE_EDGES_WEIGHT_KEY = DIRECTORY_EDGES_WEIGHT_KEY;
2114  /**
2115   * @deprecated since 5.0 use {@link #DIRECTORY_EDGES_WEIGHT}
2116   */
2117  @Deprecated
2118  public static final transient Metric<Integer> PACKAGE_EDGES_WEIGHT = DIRECTORY_EDGES_WEIGHT;
2119
2120  /**
2121   * @deprecated since 5.2 No more design features
2122   */
2123  @Deprecated
2124  public static final String FILE_CYCLES_KEY = "file_cycles";
2125  /**
2126   * @deprecated since 5.2 No more design features
2127   */
2128  @Deprecated
2129  public static final transient Metric<Integer> FILE_CYCLES = new Metric.Builder(FILE_CYCLES_KEY, "File Cycles", Metric.ValueType.INT)
2130    .setDescription("File cycles")
2131    .setDirection(Metric.DIRECTION_WORST)
2132    .setQualitative(true)
2133    .setDomain(DOMAIN_DESIGN)
2134    .setHidden(true)
2135    .setDeleteHistoricalData(true)
2136    .setBestValue(0.0)
2137    .create();
2138
2139  /**
2140   * @deprecated since 5.2 No more design features
2141   */
2142  @Deprecated
2143  public static final String FILE_TANGLE_INDEX_KEY = "file_tangle_index";
2144  /**
2145   * @deprecated since 5.2 No more design features
2146   */
2147  @Deprecated
2148  public static final transient Metric<Double> FILE_TANGLE_INDEX = new Metric.Builder(FILE_TANGLE_INDEX_KEY, "File Tangle Index", Metric.ValueType.PERCENT)
2149    .setDescription("File tangle index")
2150    .setDirection(Metric.DIRECTION_WORST)
2151    .setQualitative(true)
2152    .setDomain(DOMAIN_DESIGN)
2153    .setHidden(true)
2154    .setDeleteHistoricalData(true)
2155    .setBestValue(0.0)
2156    .create();
2157
2158  /**
2159   * @deprecated since 5.2 No more design features
2160   */
2161  @Deprecated
2162  public static final String FILE_TANGLES_KEY = "file_tangles";
2163  /**
2164   * @deprecated since 5.2 No more design features
2165   */
2166  @Deprecated
2167  public static final transient Metric<Integer> FILE_TANGLES = new Metric.Builder(FILE_TANGLES_KEY, "File Tangles", Metric.ValueType.INT)
2168    .setDescription("Files tangles")
2169    .setDirection(Metric.DIRECTION_WORST)
2170    .setQualitative(false)
2171    .setDomain(DOMAIN_DESIGN)
2172    .setHidden(true)
2173    .setDeleteHistoricalData(true)
2174    .create();
2175
2176  /**
2177   * @deprecated since 5.2 No more design features
2178   */
2179  @Deprecated
2180  public static final String FILE_FEEDBACK_EDGES_KEY = "file_feedback_edges";
2181  /**
2182   * @deprecated since 5.2 No more design features
2183   */
2184  @Deprecated
2185  public static final transient Metric<Integer> FILE_FEEDBACK_EDGES = new Metric.Builder(FILE_FEEDBACK_EDGES_KEY, "Suspect File Dependencies", Metric.ValueType.INT)
2186    .setDescription("Suspect file dependencies")
2187    .setDirection(Metric.DIRECTION_WORST)
2188    .setQualitative(false)
2189    .setDomain(DOMAIN_DESIGN)
2190    .setHidden(true)
2191    .setDeleteHistoricalData(true)
2192    .setBestValue(0.0)
2193    .create();
2194
2195  /**
2196   * @deprecated since 5.2 No more design features
2197   */
2198  @Deprecated
2199  public static final String FILE_EDGES_WEIGHT_KEY = "file_edges_weight";
2200  /**
2201   * @deprecated since 5.2 No more design features
2202   */
2203  @Deprecated
2204  public static final transient Metric<Integer> FILE_EDGES_WEIGHT = new Metric.Builder(FILE_EDGES_WEIGHT_KEY, "File Edges Weight", Metric.ValueType.INT)
2205    .setDescription("File edges weight")
2206    .setDirection(Metric.DIRECTION_BETTER)
2207    .setQualitative(false)
2208    .setDomain(DOMAIN_DESIGN)
2209    .setHidden(true)
2210    .setDeleteHistoricalData(true)
2211    .create();
2212
2213  // --------------------------------------------------------------------------------------------------------------------
2214  //
2215  // SCM
2216  //
2217  // --------------------------------------------------------------------------------------------------------------------
2218
2219  /**
2220   * @since 2.7
2221   * @deprecated since 5.0 SCM data will no more be stored as measures
2222   */
2223  @Deprecated
2224  public static final String SCM_AUTHORS_BY_LINE_KEY = "authors_by_line";
2225
2226  /**
2227   * Key-value pairs, where key - is a number of line, and value - is an author for this line.
2228   *
2229   * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map)
2230   * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String)
2231   * @since 2.7
2232   * @deprecated since 5.0 SCM data will no more be stored as measures
2233   */
2234  @Deprecated
2235  public static final transient Metric<String> SCM_AUTHORS_BY_LINE = new Metric.Builder(SCM_AUTHORS_BY_LINE_KEY, "Authors by Line", Metric.ValueType.DATA)
2236    .setDomain(DOMAIN_SCM)
2237    .create();
2238
2239  /**
2240   * @since 2.7
2241   * @deprecated since 5.0 SCM data will no more be stored as measures
2242   */
2243  @Deprecated
2244  public static final String SCM_REVISIONS_BY_LINE_KEY = "revisions_by_line";
2245
2246  /**
2247   * Key-value pairs, where key - is a number of line, and value - is a revision for this line.
2248   *
2249   * @see org.sonar.api.utils.KeyValueFormat#formatIntString(java.util.Map)
2250   * @see org.sonar.api.utils.KeyValueFormat#parseIntString(String)
2251   * @since 2.7
2252   * @deprecated since 5.0 SCM data will no more be stored as measures
2253   */
2254  @Deprecated
2255  public static final transient Metric<String> SCM_REVISIONS_BY_LINE = new Metric.Builder(SCM_REVISIONS_BY_LINE_KEY, "Revisions by Line", Metric.ValueType.DATA)
2256    .setDomain(DOMAIN_SCM)
2257    .create();
2258
2259  /**
2260   * @since 2.7
2261   * @deprecated since 5.0 SCM data will no more be stored as measures
2262   */
2263  @Deprecated
2264  public static final String SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY = "last_commit_datetimes_by_line";
2265
2266  /**
2267   * Key-value pairs, where key - is a number of line, and value - is a date of last commit for this line.
2268   *
2269   * @see org.sonar.api.utils.KeyValueFormat#formatIntDateTime(java.util.Map)
2270   * @see org.sonar.api.utils.KeyValueFormat#parseIntDateTime(String)
2271   * @since 2.7
2272   * @deprecated since 5.0 SCM data will no more be stored as measures
2273   */
2274  @Deprecated
2275  public static final transient Metric<String> SCM_LAST_COMMIT_DATETIMES_BY_LINE = new Metric.Builder(SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY, "Last Commit Dates by Line",
2276    Metric.ValueType.DATA)
2277      .setDomain(DOMAIN_SCM)
2278      .create();
2279
2280  // --------------------------------------------------------------------------------------------------------------------
2281  //
2282  // MAINTAINABILITY CHARACTERISTIC
2283  //
2284  // --------------------------------------------------------------------------------------------------------------------
2285
2286  /**
2287   * @since 4.0
2288   */
2289  // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "maintainability_remediation_effort"
2290  public static final String TECHNICAL_DEBT_KEY = "sqale_index";
2291
2292  /**
2293   * @since 4.0
2294   */
2295  // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT
2296  public static final Metric<Long> TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR)
2297    .setDescription("Total effort (in days) to fix all the issues on the component and therefore to comply to all the requirements.")
2298    .setDomain(DOMAIN_MAINTAINABILITY)
2299    .setDirection(Metric.DIRECTION_WORST)
2300    .setOptimizedBestValue(true)
2301    .setBestValue(0.0)
2302    .setQualitative(true)
2303    .create();
2304
2305  /**
2306   * @since 4.1
2307   */
2308  // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "new_maintainability_remediation_effort"
2309  public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt";
2310
2311  /**
2312   * @since 4.1
2313   */
2314  // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT
2315  public static final Metric<Long> NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Added Technical Debt", Metric.ValueType.WORK_DUR)
2316    .setDescription("Added technical debt")
2317    .setDomain(DOMAIN_MAINTAINABILITY)
2318    .setDirection(Metric.DIRECTION_WORST)
2319    .setOptimizedBestValue(true)
2320    .setBestValue(0.0)
2321    .setQualitative(true)
2322    .setDeleteHistoricalData(true)
2323    .create();
2324
2325  /**
2326   * @since 4.5
2327   */
2328  // TODO should be renamed to MAINTAINABILITY_RATING_KEY = "maintainability_rating"
2329  public static final String SQALE_RATING_KEY = "sqale_rating";
2330
2331  /**
2332   * @since 4.5
2333   */
2334  // TODO should be renamed to MAINTAINABILITY_RATING
2335  public static final Metric<Integer> SQALE_RATING = new Metric.Builder(SQALE_RATING_KEY, "Maintainability Rating", Metric.ValueType.RATING)
2336    .setDescription("A-to-E rating based on the technical debt ratio")
2337    .setDomain(DOMAIN_MAINTAINABILITY)
2338    .setDirection(Metric.DIRECTION_WORST)
2339    .setQualitative(true)
2340    .setBestValue(1.0)
2341    .setWorstValue(5.0)
2342    .create();
2343
2344  /**
2345   * @since 6.2
2346   */
2347  public static final String NEW_MAINTAINABILITY_RATING_KEY = "new_maintainability_rating";
2348
2349  /**
2350   * @since 6.2
2351   */
2352  public static final Metric<Integer> NEW_MAINTAINABILITY_RATING = new Metric.Builder(NEW_MAINTAINABILITY_RATING_KEY, "Maintainability Rating on New Code", Metric.ValueType.RATING)
2353    .setDescription("Maintainability rating on new code")
2354    .setDomain(DOMAIN_MAINTAINABILITY)
2355    .setDirection(Metric.DIRECTION_WORST)
2356    .setDeleteHistoricalData(true)
2357    .setOptimizedBestValue(true)
2358    .setQualitative(true)
2359    .setBestValue(1.0)
2360    .setWorstValue(5.0)
2361    .create();
2362
2363  /**
2364   * @since 4.5
2365   */
2366  public static final String DEVELOPMENT_COST_KEY = "development_cost";
2367
2368  /**
2369   * @since 4.5
2370   */
2371  public static final Metric<String> DEVELOPMENT_COST = new Metric.Builder(DEVELOPMENT_COST_KEY, "SQALE Development Cost", Metric.ValueType.STRING)
2372    .setDescription("SQALE development cost")
2373    .setDomain(DOMAIN_MAINTAINABILITY)
2374    .setDirection(Metric.DIRECTION_WORST)
2375    .setOptimizedBestValue(true)
2376    .setBestValue(0.0)
2377    .setQualitative(true)
2378    .setHidden(true)
2379    .create();
2380
2381  /**
2382   * @since 4.5
2383   */
2384  // TODO should be renamed to TECHNICALDEBT_RATIO_KEY = "technicaldebt_ratio"
2385  public static final String SQALE_DEBT_RATIO_KEY = "sqale_debt_ratio";
2386
2387  /**
2388   * @since 4.5
2389   */
2390  // TODO should be renamed to TECHNICALDEBT_RATIO
2391  public static final Metric<Double> SQALE_DEBT_RATIO = new Metric.Builder(SQALE_DEBT_RATIO_KEY, "Technical Debt Ratio", Metric.ValueType.PERCENT)
2392    .setDescription("Ratio of the actual technical debt compared to the estimated cost to develop the whole source code from scratch")
2393    .setDomain(DOMAIN_MAINTAINABILITY)
2394    .setDirection(Metric.DIRECTION_WORST)
2395    .setOptimizedBestValue(true)
2396    .setBestValue(0.0)
2397    .setQualitative(true)
2398    .create();
2399
2400  /**
2401   * @since 5.2
2402   */
2403  // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE_KEY = "technicaldebt_ratio_on_new_code"
2404  public static final String NEW_SQALE_DEBT_RATIO_KEY = "new_sqale_debt_ratio";
2405
2406  /**
2407   * @since 5.2
2408   */
2409  // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE
2410  public static final Metric<Double> NEW_SQALE_DEBT_RATIO = new Metric.Builder(NEW_SQALE_DEBT_RATIO_KEY, "Technical Debt Ratio on New Code", Metric.ValueType.PERCENT)
2411    .setDescription("Technical Debt Ratio of new/changed code.")
2412    .setDomain(DOMAIN_MAINTAINABILITY)
2413    .setDirection(Metric.DIRECTION_WORST)
2414    .setOptimizedBestValue(true)
2415    .setBestValue(0.0)
2416    .setQualitative(true)
2417    .create();
2418
2419  /**
2420   * @since 5.5
2421   */
2422  public static final String EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY = "effort_to_reach_maintainability_rating_a";
2423
2424  /**
2425   * @since 5.5
2426   */
2427  public static final Metric<Long> EFFORT_TO_REACH_MAINTAINABILITY_RATING_A = new Metric.Builder(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY,
2428    "Effort to Reach Maintainability Rating A", Metric.ValueType.WORK_DUR)
2429      .setDescription("Effort to reach maintainability rating A")
2430      .setDomain(DOMAIN_MAINTAINABILITY)
2431      .setDirection(Metric.DIRECTION_WORST)
2432      .setQualitative(true)
2433      .setBestValue(0.0)
2434      .setOptimizedBestValue(true)
2435      .create();
2436
2437  // --------------------------------------------------------------------------------------------------------------------
2438  //
2439  // RELIABILITY CHARACTERISTIC
2440  //
2441  // --------------------------------------------------------------------------------------------------------------------
2442
2443  /**
2444   * @since 5.5
2445   */
2446  public static final String RELIABILITY_REMEDIATION_EFFORT_KEY = "reliability_remediation_effort";
2447
2448  /**
2449   * @since 5.5
2450   */
2451  public static final Metric<Long> RELIABILITY_REMEDIATION_EFFORT = new Metric.Builder(RELIABILITY_REMEDIATION_EFFORT_KEY, "Reliability Remediation Effort",
2452    Metric.ValueType.WORK_DUR)
2453      .setDescription("Reliability Remediation Effort")
2454      .setDomain(DOMAIN_RELIABILITY)
2455      .setDirection(Metric.DIRECTION_WORST)
2456      .setOptimizedBestValue(true)
2457      .setBestValue(0.0)
2458      .setQualitative(true)
2459      .create();
2460
2461  /**
2462   * @since 5.5
2463   */
2464  public static final String NEW_RELIABILITY_REMEDIATION_EFFORT_KEY = "new_reliability_remediation_effort";
2465
2466  /**
2467   * @since 5.5
2468   */
2469  public static final Metric<Long> NEW_RELIABILITY_REMEDIATION_EFFORT = new Metric.Builder(NEW_RELIABILITY_REMEDIATION_EFFORT_KEY, "Reliability Remediation Effort on New Code",
2470    Metric.ValueType.WORK_DUR)
2471      .setDescription("Reliability remediation effort on new code")
2472      .setDomain(DOMAIN_RELIABILITY)
2473      .setDirection(Metric.DIRECTION_WORST)
2474      .setOptimizedBestValue(true)
2475      .setBestValue(0.0)
2476      .setQualitative(true)
2477      .setDeleteHistoricalData(true)
2478      .create();
2479
2480  /**
2481   * @since 5.5
2482   */
2483  public static final String RELIABILITY_RATING_KEY = "reliability_rating";
2484
2485  /**
2486   * @since 5.5
2487   */
2488  public static final Metric<Integer> RELIABILITY_RATING = new Metric.Builder(RELIABILITY_RATING_KEY, "Reliability Rating", Metric.ValueType.RATING)
2489    .setDescription("Reliability rating")
2490    .setDomain(DOMAIN_RELIABILITY)
2491    .setDirection(Metric.DIRECTION_WORST)
2492    .setQualitative(true)
2493    .setBestValue(1.0)
2494    .setWorstValue(5.0)
2495    .create();
2496
2497  /**
2498   * @since 6.2
2499   */
2500  public static final String NEW_RELIABILITY_RATING_KEY = "new_reliability_rating";
2501
2502  /**
2503   * @since 6.2
2504   */
2505  public static final Metric<Integer> NEW_RELIABILITY_RATING = new Metric.Builder(NEW_RELIABILITY_RATING_KEY, "Reliability Rating on New Code", Metric.ValueType.RATING)
2506    .setDescription("Reliability rating on new code")
2507    .setDomain(DOMAIN_RELIABILITY)
2508    .setDirection(Metric.DIRECTION_WORST)
2509    .setDeleteHistoricalData(true)
2510    .setOptimizedBestValue(true)
2511    .setQualitative(true)
2512    .setBestValue(1.0)
2513    .setWorstValue(5.0)
2514    .create();
2515
2516  // --------------------------------------------------------------------------------------------------------------------
2517  //
2518  // SECURITY CHARACTERISTIC
2519  //
2520  // --------------------------------------------------------------------------------------------------------------------
2521
2522  /**
2523   * @since 5.5
2524   */
2525  public static final String SECURITY_REMEDIATION_EFFORT_KEY = "security_remediation_effort";
2526
2527  /**
2528   * @since 5.5
2529   */
2530  public static final Metric<Long> SECURITY_REMEDIATION_EFFORT = new Metric.Builder(SECURITY_REMEDIATION_EFFORT_KEY, "Security Remediation Effort", Metric.ValueType.WORK_DUR)
2531    .setDescription("Security remediation effort")
2532    .setDomain(DOMAIN_SECURITY)
2533    .setDirection(Metric.DIRECTION_WORST)
2534    .setOptimizedBestValue(true)
2535    .setBestValue(0.0)
2536    .setQualitative(true)
2537    .create();
2538
2539  /**
2540   * @since 5.5
2541   */
2542  public static final String NEW_SECURITY_REMEDIATION_EFFORT_KEY = "new_security_remediation_effort";
2543
2544  /**
2545   * @since 5.5
2546   */
2547  public static final Metric<Long> NEW_SECURITY_REMEDIATION_EFFORT = new Metric.Builder(NEW_SECURITY_REMEDIATION_EFFORT_KEY, "Security Remediation Effort on New Code",
2548    Metric.ValueType.WORK_DUR)
2549      .setDescription("Security remediation effort on new code")
2550      .setDomain(DOMAIN_SECURITY)
2551      .setDirection(Metric.DIRECTION_WORST)
2552      .setOptimizedBestValue(true)
2553      .setBestValue(0.0)
2554      .setQualitative(true)
2555      .setDeleteHistoricalData(true)
2556      .create();
2557
2558  /**
2559   * @since 5.5
2560   */
2561  public static final String SECURITY_RATING_KEY = "security_rating";
2562
2563  /**
2564   * @since 5.5
2565   */
2566  public static final Metric<Integer> SECURITY_RATING = new Metric.Builder(SECURITY_RATING_KEY, "Security Rating", Metric.ValueType.RATING)
2567    .setDescription("Security rating")
2568    .setDomain(DOMAIN_SECURITY)
2569    .setDirection(Metric.DIRECTION_WORST)
2570    .setQualitative(true)
2571    .setBestValue(1.0)
2572    .setWorstValue(5.0)
2573    .create();
2574
2575  /**
2576   * @since 6.2
2577   */
2578  public static final String NEW_SECURITY_RATING_KEY = "new_security_rating";
2579
2580  /**
2581   * @since 6.2
2582   */
2583  public static final Metric<Integer> NEW_SECURITY_RATING = new Metric.Builder(NEW_SECURITY_RATING_KEY, "Security Rating on New Code", Metric.ValueType.RATING)
2584    .setDescription("Security rating on new code")
2585    .setDomain(DOMAIN_SECURITY)
2586    .setDirection(Metric.DIRECTION_WORST)
2587    .setDeleteHistoricalData(true)
2588    .setOptimizedBestValue(true)
2589    .setQualitative(true)
2590    .setBestValue(1.0)
2591    .setWorstValue(5.0)
2592    .create();
2593
2594  // --------------------------------------------------------------------------------------------------------------------
2595  //
2596  // FILE DATA
2597  //
2598  // --------------------------------------------------------------------------------------------------------------------
2599
2600  /**
2601   * @since 2.14
2602   */
2603  public static final String NCLOC_DATA_KEY = "ncloc_data";
2604
2605  /**
2606   * Information about lines of code in file.
2607   * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains code (1) or not (0).
2608   * If a line number is missing in the map it is equivalent to the default value (0).
2609   *
2610   * @see org.sonar.api.measures.FileLinesContext
2611   * @since 2.14
2612   */
2613  public static final Metric<String> NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA)
2614    .setHidden(true)
2615    .setDomain(DOMAIN_SIZE)
2616    .create();
2617
2618  /**
2619   * @since 2.14
2620   */
2621  public static final String COMMENT_LINES_DATA_KEY = "comment_lines_data";
2622
2623  /**
2624   * Information about comments in file.
2625   * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains comment (1) or not (0).
2626   * If a line number is missing in the map it is equivalent to the default value (0).
2627   *
2628   * @see org.sonar.api.measures.FileLinesContext
2629   * @since 2.14
2630   */
2631  public static final Metric<String> COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA)
2632    .setHidden(true)
2633    .setDomain(DOMAIN_SIZE)
2634    .create();
2635
2636  /**
2637   * @since 5.5
2638   */
2639  public static final String EXECUTABLE_LINES_DATA_KEY = "executable_lines_data";
2640
2641  /**
2642   * Information about executable lines of code in file.
2643   * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains executable code (1) or not (0).
2644   * If a line number is missing in the map it is equivalent to the default value (0).
2645   *
2646   * @see org.sonar.api.measures.FileLinesContext
2647   * @since 5.5
2648   */
2649  public static final Metric<String> EXECUTABLE_LINES_DATA = new Metric.Builder(EXECUTABLE_LINES_DATA_KEY, "executable_lines_data", Metric.ValueType.DATA)
2650    .setHidden(true)
2651    .setDomain(DOMAIN_COVERAGE)
2652    .create();
2653
2654  // --------------------------------------------------------------------------------------------------------------------
2655  //
2656  // OTHERS
2657  //
2658  // --------------------------------------------------------------------------------------------------------------------
2659
2660  public static final String ALERT_STATUS_KEY = "alert_status";
2661  public static final Metric<Metric.Level> ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Quality Gate Status", Metric.ValueType.LEVEL)
2662    .setDescription("The project status with regard to its quality gate.")
2663    .setDirection(Metric.DIRECTION_BETTER)
2664    .setQualitative(true)
2665    .setDomain(DOMAIN_RELEASABILITY)
2666    .create();
2667
2668  /**
2669   * @since 4.4
2670   */
2671  public static final String QUALITY_GATE_DETAILS_KEY = "quality_gate_details";
2672  /**
2673   * The project detailed status with regard to its quality gate.
2674   * Storing the global quality gate status, along with all evaluated conditions, into a JSON object.
2675   * @since 4.4
2676   */
2677  public static final Metric<String> QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA)
2678    .setDescription("The project detailed status with regard to its quality gate")
2679    .setDomain(DOMAIN_GENERAL)
2680    .create();
2681
2682  /**
2683   * @since 4.4
2684   * @deprecated since 5.5
2685   */
2686  @Deprecated
2687  public static final String QUALITY_PROFILES_KEY = "quality_profiles";
2688
2689  /**
2690   * @since 4.4
2691   * @deprecated since 5.5
2692   */
2693  @Deprecated
2694  public static final Metric<String> QUALITY_PROFILES = new Metric.Builder(QUALITY_PROFILES_KEY, "Profiles", Metric.ValueType.DATA)
2695    .setDescription("Details of quality profiles used during analysis")
2696    .setQualitative(false)
2697    .setDomain(DOMAIN_GENERAL)
2698    .setHidden(true)
2699    .create();
2700
2701  /**
2702   * @since 5.2
2703   */
2704  public static final String LAST_COMMIT_DATE_KEY = "last_commit_date";
2705
2706  /**
2707   * Date of the most recent commit. Current implementation is based on commits touching lines of source code. It
2708   * ignores other changes like file renaming or file deletion.
2709   * @since 5.2
2710   */
2711  public static final Metric LAST_COMMIT_DATE = new Metric.Builder(LAST_COMMIT_DATE_KEY, "Date of Last Commit", Metric.ValueType.MILLISEC)
2712    .setDomain(CoreMetrics.DOMAIN_SCM)
2713    // waiting for type "datetime" to be correctly handled
2714    .setHidden(true)
2715    .create();
2716
2717  private static final List<Metric> METRICS;
2718
2719  static {
2720    METRICS = new LinkedList<>();
2721    for (Field field : CoreMetrics.class.getFields()) {
2722      if (!Modifier.isTransient(field.getModifiers()) && Metric.class.isAssignableFrom(field.getType())) {
2723        try {
2724          Metric metric = (Metric) field.get(null);
2725          METRICS.add(metric);
2726        } catch (IllegalAccessException e) {
2727          throw new SonarException("can not introspect " + CoreMetrics.class + " to get metrics", e);
2728        }
2729      }
2730    }
2731  }
2732
2733  private CoreMetrics() {
2734    // only static stuff
2735  }
2736
2737  public static List<Metric> getMetrics() {
2738    return METRICS;
2739  }
2740
2741  public static Metric getMetric(final String key) {
2742    return METRICS.stream().filter(metric -> metric != null && metric.getKey().equals(key)).findFirst().orElseThrow(NoSuchElementException::new);
2743  }
2744}