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