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