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