123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839 |
- /*
- * SonarQube
- * Copyright (C) 2009-2021 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
- package org.sonar.api.measures;
-
- import java.lang.reflect.Field;
- import java.lang.reflect.Modifier;
- import java.util.LinkedList;
- import java.util.List;
- import java.util.NoSuchElementException;
- import org.sonar.api.utils.SonarException;
-
- /**
- * @since 1.10
- */
- public final class CoreMetrics {
-
- // the following fields are not final to avoid compile-time constants used by plugins
- public static String DOMAIN_SIZE = "Size";
- public static String DOMAIN_COVERAGE = "Coverage";
-
- public static String DOMAIN_COMPLEXITY = "Complexity";
- /**
- * @deprecated since 6.2. Merged into {@link #DOMAIN_SIZE}
- */
- @Deprecated
- public static String DOMAIN_DOCUMENTATION = "Documentation";
- public static String DOMAIN_SCM = "SCM";
- public static String DOMAIN_ISSUES = "Issues";
- public static String DOMAIN_GENERAL = "General";
- public static String DOMAIN_DUPLICATIONS = "Duplications";
-
- /**
- * @deprecated in 5.5. Renamed to {@link #DOMAIN_DUPLICATIONS}
- */
- @Deprecated
- public static String DOMAIN_DUPLICATION = "Duplication";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static String DOMAIN_MAINTAINABILITY = "Maintainability";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static String DOMAIN_RELIABILITY = "Reliability";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static String DOMAIN_SECURITY = "Security";
-
- /**
- * @since 8.2
- */
- public static String DOMAIN_SECURITY_REVIEW = "SecurityReview";
-
- /**
- * @since 5.5
- */
- public static String DOMAIN_RELEASABILITY = "Releasability";
-
- /**
- * Computed by the platform since SQ 5.1
- */
- public static final String LINES_KEY = "lines";
- public static final Metric<Integer> LINES = new Metric.Builder(LINES_KEY, "Lines", Metric.ValueType.INT)
- .setDescription("Lines")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- public static final String GENERATED_LINES_KEY = "generated_lines";
- public static final Metric<Integer> GENERATED_LINES = new Metric.Builder(GENERATED_LINES_KEY, "Generated Lines", Metric.ValueType.INT)
- .setDescription("Number of generated lines")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String NCLOC_KEY = "ncloc";
- public static final Metric<Integer> NCLOC = new Metric.Builder(NCLOC_KEY, "Lines of Code", Metric.ValueType.INT)
- .setDescription("Non commenting lines of code")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- /**
- * @since 6.1
- */
- public static final String NEW_LINES_KEY = "new_lines";
- /**
- * @since 6.1
- */
- public static final Metric<Integer> NEW_LINES = new Metric.Builder(NEW_LINES_KEY, "New Lines", Metric.ValueType.INT)
- .setDescription("New lines")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * @since 4.4
- */
- public static final String NCLOC_LANGUAGE_DISTRIBUTION_KEY = "ncloc_language_distribution";
-
- /**
- * @since 4.4
- */
- public static final Metric<String> NCLOC_LANGUAGE_DISTRIBUTION = new Metric.Builder(NCLOC_LANGUAGE_DISTRIBUTION_KEY, "Lines of Code Per Language", Metric.ValueType.DATA)
- .setDescription("Non Commenting Lines of Code Distributed By Language")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- public static final String GENERATED_NCLOC_KEY = "generated_ncloc";
- public static final Metric<Integer> GENERATED_NCLOC = new Metric.Builder(GENERATED_NCLOC_KEY, "Generated Lines of Code", Metric.ValueType.INT)
- .setDescription("Generated non Commenting Lines of Code")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String CLASSES_KEY = "classes";
- public static final Metric<Integer> CLASSES = new Metric.Builder(CLASSES_KEY, "Classes", Metric.ValueType.INT)
- .setDescription("Classes")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- public static final String FILES_KEY = "files";
- /**
- * Computed by the platform.
- */
- public static final Metric<Integer> FILES = new Metric.Builder(FILES_KEY, "Files", Metric.ValueType.INT)
- .setDescription("Number of files")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- /**
- * @deprecated since 7.7 - no longer computed
- */
- @Deprecated
- public static final String DIRECTORIES_KEY = "directories";
-
- /**
- * @deprecated since 7.7 - no longer computed
- */
- @Deprecated
- public static final Metric<Integer> DIRECTORIES = new Metric.Builder(DIRECTORIES_KEY, "Directories", Metric.ValueType.INT)
- .setDescription("Directories")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- /**
- * Computed by the platform.
- */
- public static final String FUNCTIONS_KEY = "functions";
- public static final Metric<Integer> FUNCTIONS = new Metric.Builder(FUNCTIONS_KEY, "Functions", Metric.ValueType.INT)
- .setDescription("Functions")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- public static final String STATEMENTS_KEY = "statements";
- public static final Metric<Integer> STATEMENTS = new Metric.Builder(STATEMENTS_KEY, "Statements", Metric.ValueType.INT)
- .setDescription("Number of statements")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- /**
- * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
- * @deprecated since 6.2
- */
- @Deprecated
- public static final String PUBLIC_API_KEY = "public_api";
- public static final Metric<Integer> PUBLIC_API = new Metric.Builder(PUBLIC_API_KEY, "Public API", Metric.ValueType.INT)
- .setDescription("Public API")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_DOCUMENTATION)
- .setHidden(true)
- .create();
-
- /**
- * @since 3.0
- */
- public static final String PROJECTS_KEY = "projects";
-
- /**
- * @since 3.0
- */
- public static final Metric<Integer> PROJECTS = new Metric.Builder(PROJECTS_KEY, "Project branches", Metric.ValueType.INT)
- .setDescription("Number of project branches")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- /**
- * Moved to Size domain since 6.2
- */
- public static final String COMMENT_LINES_KEY = "comment_lines";
- public static final Metric<Integer> COMMENT_LINES = new Metric.Builder(COMMENT_LINES_KEY, "Comment Lines", Metric.ValueType.INT)
- .setDescription("Number of comment lines")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(false)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- /**
- * Moved to Size domain since 6.2
- */
- public static final String COMMENT_LINES_DENSITY_KEY = "comment_lines_density";
- public static final Metric<Double> COMMENT_LINES_DENSITY = new Metric.Builder(COMMENT_LINES_DENSITY_KEY, "Comments (%)", Metric.ValueType.PERCENT)
- .setDescription("Comments balanced by ncloc + comment lines")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // DOCUMENTATION
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- /**
- * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
- * @deprecated since 6.2
- */
- @Deprecated
- public static final String PUBLIC_DOCUMENTED_API_DENSITY_KEY = "public_documented_api_density";
- public static final Metric<Double> PUBLIC_DOCUMENTED_API_DENSITY = new Metric.Builder(PUBLIC_DOCUMENTED_API_DENSITY_KEY, "Public Documented API (%)", Metric.ValueType.PERCENT)
- .setDescription("Public documented classes and functions balanced by ncloc")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_DOCUMENTATION)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .setOptimizedBestValue(true)
- .setHidden(true)
- .create();
-
- /**
- * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
- * @deprecated since 6.2
- */
- @Deprecated
- public static final String PUBLIC_UNDOCUMENTED_API_KEY = "public_undocumented_api";
- public static final Metric<Integer> PUBLIC_UNDOCUMENTED_API = new Metric.Builder(PUBLIC_UNDOCUMENTED_API_KEY, "Public Undocumented API", Metric.ValueType.INT)
- .setDescription("Public undocumented classes, functions and variables")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_DOCUMENTATION)
- .setBestValue(0.0)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setHidden(true)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // COMPLEXITY
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- public static final String COMPLEXITY_KEY = "complexity";
- public static final Metric<Integer> COMPLEXITY = new Metric.Builder(COMPLEXITY_KEY, "Cyclomatic Complexity", Metric.ValueType.INT)
- .setDescription("Cyclomatic complexity")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_COMPLEXITY)
- .create();
-
- /**
- * @deprecated since 6.7
- */
- @Deprecated
- public static final String FILE_COMPLEXITY_KEY = "file_complexity";
- /**
- * Information about the cyclomatic complexity per file, calculated by divided the {@link #COMPLEXITY} by the number of {@link #FILES}.
- *
- * @deprecated since 6.7
- */
- @Deprecated
- public static final Metric<Double> FILE_COMPLEXITY = new Metric.Builder(FILE_COMPLEXITY_KEY, "Complexity / File", Metric.ValueType.FLOAT)
- .setDescription("Complexity average by file")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_COMPLEXITY)
- .setHidden(true)
- .create();
-
- /**
- * @since 3.6
- * @deprecated since 6.7
- */
- @Deprecated
- public static final String COMPLEXITY_IN_CLASSES_KEY = "complexity_in_classes";
-
- /**
- * @since 3.6
- * @deprecated since 6.7
- */
- @Deprecated
- public static final Metric<Integer> COMPLEXITY_IN_CLASSES = new Metric.Builder(COMPLEXITY_IN_CLASSES_KEY, "Complexity in Classes", Metric.ValueType.INT)
- .setDescription("Cyclomatic complexity in classes")
- .setHidden(true)
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_COMPLEXITY)
- .setDeleteHistoricalData(true)
- .setHidden(true)
- .create();
-
- /**
- * @deprecated since 6.7
- */
- @Deprecated
- public static final String CLASS_COMPLEXITY_KEY = "class_complexity";
- /**
- * Information about the cyclomatic complexity per class, calculated by divided the {@link #COMPLEXITY_IN_CLASSES} by the number of {@link #CLASSES}.
- *
- * @deprecated since 6.7
- */
- @Deprecated
- public static final Metric<Double> CLASS_COMPLEXITY = new Metric.Builder(CLASS_COMPLEXITY_KEY, "Complexity / Class", Metric.ValueType.FLOAT)
- .setDescription("Complexity average by class")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_COMPLEXITY)
- .setHidden(true)
- .create();
-
- /**
- * @since 3.6
- * @deprecated since 6.7
- */
- @Deprecated
- public static final String COMPLEXITY_IN_FUNCTIONS_KEY = "complexity_in_functions";
- /**
- * @since 3.6
- * @deprecated since 6.7
- */
- @Deprecated
- public static final Metric<Integer> COMPLEXITY_IN_FUNCTIONS = new Metric.Builder(COMPLEXITY_IN_FUNCTIONS_KEY, "Complexity in Functions", Metric.ValueType.INT)
- .setDescription("Cyclomatic complexity in functions")
- .setHidden(true)
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_COMPLEXITY)
- .setDeleteHistoricalData(true)
- .setHidden(true)
- .create();
-
- /**
- * @deprecated since 6.7
- */
- @Deprecated
- public static final String FUNCTION_COMPLEXITY_KEY = "function_complexity";
- /**
- * Information about the cyclomatic complexity per function, calculated by divided the {@link #COMPLEXITY_IN_FUNCTIONS} by the number of {@link #FUNCTIONS}.
- *
- * @deprecated since 6.7
- */
- @Deprecated
- public static final Metric<Double> FUNCTION_COMPLEXITY = new Metric.Builder(FUNCTION_COMPLEXITY_KEY, "Complexity / Function", Metric.ValueType.FLOAT)
- .setDescription("Complexity average by function")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_COMPLEXITY)
- .setHidden(true)
- .create();
-
- /**
- * @deprecated since 6.7
- */
- @Deprecated
- public static final String FUNCTION_COMPLEXITY_DISTRIBUTION_KEY = "function_complexity_distribution";
- /**
- * @deprecated since 6.7
- */
- @Deprecated
- public static final Metric<String> FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Function Distribution / Complexity",
- Metric.ValueType.DISTRIB)
- .setDescription("Functions distribution /complexity")
- .setDirection(Metric.DIRECTION_NONE)
- .setQualitative(true)
- .setDomain(DOMAIN_COMPLEXITY)
- .setHidden(true)
- .create();
-
- /**
- * @deprecated since 6.7
- */
- @Deprecated
- public static final String FILE_COMPLEXITY_DISTRIBUTION_KEY = "file_complexity_distribution";
- /**
- * @deprecated since 6.7
- */
- @Deprecated
- public static final Metric<String> FILE_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FILE_COMPLEXITY_DISTRIBUTION_KEY, "File Distribution / Complexity",
- Metric.ValueType.DISTRIB)
- .setDescription("Files distribution /complexity")
- .setDirection(Metric.DIRECTION_NONE)
- .setQualitative(true)
- .setDomain(DOMAIN_COMPLEXITY)
- .setHidden(true)
- .create();
-
- public static final String COGNITIVE_COMPLEXITY_KEY = "cognitive_complexity";
- public static final Metric<Integer> COGNITIVE_COMPLEXITY = new Metric.Builder(COGNITIVE_COMPLEXITY_KEY, "Cognitive Complexity", Metric.ValueType.INT)
- .setDescription("Cognitive complexity")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_COMPLEXITY)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // UNIT TESTS
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- public static final String TESTS_KEY = "tests";
-
- /**
- * Value of measure for this metric can be saved from Sensor, taking into account following rules:
- * <ul>
- * <li>Non-zero value should be saved for resources representing tests. And Sonar provides default Decorator, which will decorate parent resources.</li>
- * <li>Should include {@link #TEST_FAILURES} and {@link #TEST_ERRORS}, but should not include {@link #SKIPPED_TESTS}.</li>
- * </ul>
- */
- public static final Metric<Integer> TESTS = new Metric.Builder(TESTS_KEY, "Unit Tests", Metric.ValueType.INT)
- .setDescription("Number of unit tests")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(false)
- .setDomain(DOMAIN_COVERAGE)
- .create();
-
- public static final String TEST_EXECUTION_TIME_KEY = "test_execution_time";
- public static final Metric<Long> TEST_EXECUTION_TIME = new Metric.Builder(TEST_EXECUTION_TIME_KEY, "Unit Test Duration", Metric.ValueType.MILLISEC)
- .setDescription("Execution duration of unit tests")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_COVERAGE)
- .create();
-
- public static final String TEST_ERRORS_KEY = "test_errors";
- public static final Metric<Integer> TEST_ERRORS = new Metric.Builder(TEST_ERRORS_KEY, "Unit Test Errors", Metric.ValueType.INT)
- .setDescription("Number of unit test errors")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String SKIPPED_TESTS_KEY = "skipped_tests";
- public static final Metric<Integer> SKIPPED_TESTS = new Metric.Builder(SKIPPED_TESTS_KEY, "Skipped Unit Tests", Metric.ValueType.INT)
- .setDescription("Number of skipped unit tests")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String TEST_FAILURES_KEY = "test_failures";
- public static final Metric<Integer> TEST_FAILURES = new Metric.Builder(TEST_FAILURES_KEY, "Unit Test Failures", Metric.ValueType.INT)
- .setDescription("Number of unit test failures")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String TEST_SUCCESS_DENSITY_KEY = "test_success_density";
- public static final Metric<Double> TEST_SUCCESS_DENSITY = new Metric.Builder(TEST_SUCCESS_DENSITY_KEY, "Unit Test Success (%)", Metric.ValueType.PERCENT)
- .setDescription("Density of successful unit tests")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String COVERAGE_KEY = "coverage";
- public static final Metric<Double> COVERAGE = new Metric.Builder(COVERAGE_KEY, "Coverage", Metric.ValueType.PERCENT)
- .setDescription("Coverage by tests")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .create();
-
- public static final String NEW_COVERAGE_KEY = "new_coverage";
- public static final Metric<Double> NEW_COVERAGE = new Metric.Builder(NEW_COVERAGE_KEY, "Coverage on New Code", Metric.ValueType.PERCENT)
- .setDescription("Coverage of new/changed code")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String LINES_TO_COVER_KEY = "lines_to_cover";
-
- public static final Metric<Integer> LINES_TO_COVER = new Metric.Builder(LINES_TO_COVER_KEY, "Lines to Cover", Metric.ValueType.INT)
- .setDescription("Lines to cover")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_COVERAGE)
- .create();
-
- public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover";
- 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)
- .setDescription("Lines to cover on new code")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_COVERAGE)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String UNCOVERED_LINES_KEY = "uncovered_lines";
-
- public static final Metric<Integer> UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, "Uncovered Lines", Metric.ValueType.INT)
- .setDescription("Uncovered lines")
- .setDirection(Metric.DIRECTION_WORST)
- .setDomain(DOMAIN_COVERAGE)
- .setBestValue(0.0)
- .create();
-
- public static final String NEW_UNCOVERED_LINES_KEY = "new_uncovered_lines";
- public static final Metric<Integer> NEW_UNCOVERED_LINES = new Metric.Builder(NEW_UNCOVERED_LINES_KEY, "Uncovered Lines on New Code", Metric.ValueType.INT)
- .setDescription("Uncovered lines on new code")
- .setDirection(Metric.DIRECTION_WORST)
- .setDomain(DOMAIN_COVERAGE)
- .setBestValue(0.0)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String LINE_COVERAGE_KEY = "line_coverage";
- public static final Metric<Double> LINE_COVERAGE = new Metric.Builder(LINE_COVERAGE_KEY, "Line Coverage", Metric.ValueType.PERCENT)
- .setDescription("Line coverage")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .create();
-
- public static final String NEW_LINE_COVERAGE_KEY = "new_line_coverage";
- public static final Metric<Double> NEW_LINE_COVERAGE = new Metric.Builder(NEW_LINE_COVERAGE_KEY, "Line Coverage on New Code", Metric.ValueType.PERCENT)
- .setDescription("Line coverage of added/changed code")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .setDomain(DOMAIN_COVERAGE)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String CONDITIONS_TO_COVER_KEY = "conditions_to_cover";
-
- public static final Metric<Integer> CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, "Conditions to Cover", Metric.ValueType.INT)
- .setDescription("Conditions to cover")
- .setDomain(DOMAIN_COVERAGE)
- .setDirection(Metric.DIRECTION_WORST)
- .create();
-
- public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover";
- public static final Metric<Integer> NEW_CONDITIONS_TO_COVER = new Metric.Builder(NEW_CONDITIONS_TO_COVER_KEY, "Conditions to Cover on New Code", Metric.ValueType.INT)
- .setDescription("Conditions to cover on new code")
- .setDomain(DOMAIN_COVERAGE)
- .setDirection(Metric.DIRECTION_WORST)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String UNCOVERED_CONDITIONS_KEY = "uncovered_conditions";
-
- public static final Metric<Integer> UNCOVERED_CONDITIONS = new Metric.Builder(UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions", Metric.ValueType.INT)
- .setDescription("Uncovered conditions")
- .setDirection(Metric.DIRECTION_WORST)
- .setDomain(DOMAIN_COVERAGE)
- .setBestValue(0.0)
- .create();
-
- public static final String NEW_UNCOVERED_CONDITIONS_KEY = "new_uncovered_conditions";
- public static final Metric<Integer> NEW_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions on New Code", Metric.ValueType.INT)
- .setDescription("Uncovered conditions on new code")
- .setDirection(Metric.DIRECTION_WORST)
- .setDomain(DOMAIN_COVERAGE)
- .setBestValue(0.0)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String BRANCH_COVERAGE_KEY = "branch_coverage";
- public static final Metric<Double> BRANCH_COVERAGE = new Metric.Builder(BRANCH_COVERAGE_KEY, "Condition Coverage", Metric.ValueType.PERCENT)
- .setDescription("Condition coverage")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .create();
-
- public static final String NEW_BRANCH_COVERAGE_KEY = "new_branch_coverage";
- public static final Metric<Double> NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, "Condition Coverage on New Code", Metric.ValueType.PERCENT)
- .setDescription("Condition coverage of new/changed code")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_COVERAGE)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .setDeleteHistoricalData(true)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // DUPLICATIONS
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- public static final String DUPLICATED_LINES_KEY = "duplicated_lines";
- public static final Metric<Integer> DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated Lines", Metric.ValueType.INT)
- .setDescription("Duplicated lines")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_DUPLICATIONS)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @since 6.1
- */
- public static final String NEW_DUPLICATED_LINES_KEY = "new_duplicated_lines";
-
- /**
- * @since 6.1
- */
- public static final Metric<Integer> NEW_DUPLICATED_LINES = new Metric.Builder(NEW_DUPLICATED_LINES_KEY, "Duplicated Lines on New Code", Metric.ValueType.INT)
- .setDescription("Duplicated Lines on New Code")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_DUPLICATIONS)
- .setBestValue(0.0)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks";
- public static final Metric<Integer> DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated Blocks", Metric.ValueType.INT)
- .setDescription("Duplicated blocks")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_DUPLICATIONS)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @since 6.1
- */
- public static final String NEW_BLOCKS_DUPLICATED_KEY = "new_duplicated_blocks";
- /**
- * @since 6.1
- */
- public static final Metric<Integer> NEW_BLOCKS_DUPLICATED = new Metric.Builder(NEW_BLOCKS_DUPLICATED_KEY, "Duplicated Blocks on New Code", Metric.ValueType.INT)
- .setDescription("Duplicated blocks on new code")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_DUPLICATIONS)
- .setBestValue(0.0)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String DUPLICATED_FILES_KEY = "duplicated_files";
-
- /**
- * For files: if it contains duplicates, then 1, otherwise 0.
- * For other resources: amount of files under this resource with duplicates.
- */
- public static final Metric<Integer> DUPLICATED_FILES = new Metric.Builder(DUPLICATED_FILES_KEY, "Duplicated Files", Metric.ValueType.INT)
- .setDescription("Duplicated files")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_DUPLICATIONS)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density";
-
- public static final Metric<Double> DUPLICATED_LINES_DENSITY = new Metric.Builder(DUPLICATED_LINES_DENSITY_KEY, "Duplicated Lines (%)", Metric.ValueType.PERCENT)
- .setDescription("Duplicated lines balanced by statements")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_DUPLICATIONS)
- .setWorstValue(50.0)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @since 6.1
- */
- public static final String NEW_DUPLICATED_LINES_DENSITY_KEY = "new_duplicated_lines_density";
-
- /**
- * @since 6.1
- */
- public static final Metric<Integer> NEW_DUPLICATED_LINES_DENSITY = new Metric.Builder(NEW_DUPLICATED_LINES_DENSITY_KEY, "Duplicated Lines (%) on New Code",
- Metric.ValueType.PERCENT)
- .setDescription("Duplicated lines (%) on new code balanced by statements")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_DUPLICATIONS)
- .setBestValue(0.0)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * @deprecated since 4.5. Internal storage of duplication is not an API.
- */
- @Deprecated
- public static final String DUPLICATIONS_DATA_KEY = "duplications_data";
-
- /**
- * Information about duplications, which is represented as an XML string.
- * <p>
- * Here is the format (since Sonar 2.12):
- * <pre>
- * {@literal
- * <duplications>
- * <!-- Multiple groups: -->
- * <g>
- * <!-- Multiple blocks: -->
- * <b r="[resource key]" s="[first line]" l="[number of lines]" />
- * ...
- * </g>
- * ...
- * </duplications>
- * }
- * </pre>
- *
- * @deprecated since 4.5. Internal storage of duplication is not an API.
- */
- @Deprecated
- public static final Metric<String> DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplication Details", Metric.ValueType.DATA)
- .setDescription("Duplications details")
- .setDirection(Metric.DIRECTION_NONE)
- .setQualitative(false)
- .setDomain(DOMAIN_DUPLICATIONS)
- .setDeleteHistoricalData(true)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // CODING RULES
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- public static final String VIOLATIONS_KEY = "violations";
- public static final Metric<Integer> VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT)
- .setDescription("Issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations";
- public static final Metric<Integer> BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker Issues", Metric.ValueType.INT)
- .setDescription("Blocker issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations";
- public static final Metric<Integer> CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical Issues", Metric.ValueType.INT)
- .setDescription("Critical issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String MAJOR_VIOLATIONS_KEY = "major_violations";
- public static final Metric<Integer> MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major Issues", Metric.ValueType.INT)
- .setDescription("Major issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String MINOR_VIOLATIONS_KEY = "minor_violations";
- public static final Metric<Integer> MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor Issues", Metric.ValueType.INT)
- .setDescription("Minor issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String INFO_VIOLATIONS_KEY = "info_violations";
- public static final Metric<Integer> INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info Issues", Metric.ValueType.INT)
- .setDescription("Info issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- public static final String NEW_VIOLATIONS_KEY = "new_violations";
- public static final Metric<Integer> NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New Issues", Metric.ValueType.INT)
- .setDescription("New issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations";
- public static final Metric<Integer> NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker Issues", Metric.ValueType.INT)
- .setDescription("New Blocker issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations";
- public static final Metric<Integer> NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical Issues", Metric.ValueType.INT)
- .setDescription("New Critical issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations";
- public static final Metric<Integer> NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major Issues", Metric.ValueType.INT)
- .setDescription("New Major issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations";
- public static final Metric<Integer> NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor Issues", Metric.ValueType.INT)
- .setDescription("New Minor issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations";
- public static final Metric<Integer> NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info Issues", Metric.ValueType.INT)
- .setDescription("New Info issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * @since 3.6
- */
- public static final String FALSE_POSITIVE_ISSUES_KEY = "false_positive_issues";
-
- /**
- * @since 3.6
- */
- public static final Metric<Integer> FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False Positive Issues", Metric.ValueType.INT)
- .setDescription("False positive issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @since 5.6
- */
- public static final String WONT_FIX_ISSUES_KEY = "wont_fix_issues";
-
- /**
- * @since 5.6
- */
- public static final Metric<Integer> WONT_FIX_ISSUES = new Metric.Builder(WONT_FIX_ISSUES_KEY, "Won't Fix Issues", Metric.ValueType.INT)
- .setDescription("Won't fix issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @since 3.6
- */
- public static final String OPEN_ISSUES_KEY = "open_issues";
-
- /**
- * @since 3.6
- */
- public static final Metric<Integer> OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open Issues", Metric.ValueType.INT)
- .setDescription("Open issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @since 3.6
- */
- public static final String REOPENED_ISSUES_KEY = "reopened_issues";
-
- /**
- * @since 3.6
- */
- public static final Metric<Integer> REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened Issues", Metric.ValueType.INT)
- .setDescription("Reopened issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @since 3.6
- */
- public static final String CONFIRMED_ISSUES_KEY = "confirmed_issues";
-
- /**
- * @since 3.6
- */
- public static final Metric<Integer> CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed Issues", Metric.ValueType.INT)
- .setDescription("Confirmed issues")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_ISSUES)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final String CODE_SMELLS_KEY = "code_smells";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final Metric<Integer> CODE_SMELLS = new Metric.Builder(CODE_SMELLS_KEY, "Code Smells", Metric.ValueType.INT)
- .setDescription("Code Smells")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final String NEW_CODE_SMELLS_KEY = "new_code_smells";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final Metric<Integer> NEW_CODE_SMELLS = new Metric.Builder(NEW_CODE_SMELLS_KEY, "New Code Smells", Metric.ValueType.INT)
- .setDescription("New Code Smells")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final String BUGS_KEY = "bugs";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final Metric<Integer> BUGS = new Metric.Builder(BUGS_KEY, "Bugs", Metric.ValueType.INT)
- .setDescription("Bugs")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_RELIABILITY)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final String NEW_BUGS_KEY = "new_bugs";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final Metric<Integer> NEW_BUGS = new Metric.Builder(NEW_BUGS_KEY, "New Bugs", Metric.ValueType.INT)
- .setDescription("New Bugs")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_RELIABILITY)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final String VULNERABILITIES_KEY = "vulnerabilities";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final Metric<Integer> VULNERABILITIES = new Metric.Builder(VULNERABILITIES_KEY, "Vulnerabilities", Metric.ValueType.INT)
- .setDescription("Vulnerabilities")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SECURITY)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final String NEW_VULNERABILITIES_KEY = "new_vulnerabilities";
-
- /**
- * SonarQube Quality Model
- *
- * @since 5.5
- */
- public static final Metric<Integer> NEW_VULNERABILITIES = new Metric.Builder(NEW_VULNERABILITIES_KEY, "New Vulnerabilities", Metric.ValueType.INT)
- .setDescription("New Vulnerabilities")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_SECURITY)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * @since 7.8
- */
- public static final String SECURITY_HOTSPOTS_KEY = "security_hotspots";
-
- /**
- * @since 7.8
- */
- public static final Metric<Integer> SECURITY_HOTSPOTS = new Metric.Builder(SECURITY_HOTSPOTS_KEY, "Security Hotspots", Metric.ValueType.INT)
- .setDescription("Security Hotspots")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- /**
- * @since 7.8
- */
- public static final String NEW_SECURITY_HOTSPOTS_KEY = "new_security_hotspots";
-
- /**
- * @since 7.8
- */
- public static final Metric<Integer> NEW_SECURITY_HOTSPOTS = new Metric.Builder(NEW_SECURITY_HOTSPOTS_KEY, "New Security Hotspots", Metric.ValueType.INT)
- .setDescription("New Security Hotspots")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // MAINTAINABILITY CHARACTERISTIC
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- /**
- * @since 4.0
- */
- // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "maintainability_remediation_effort"
- public static final String TECHNICAL_DEBT_KEY = "sqale_index";
-
- /**
- * @since 4.0
- */
- // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT
- public static final Metric<Long> TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR)
- .setDescription("Total effort (in hours) to fix all the issues on the component and therefore to comply to all the requirements.")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .create();
-
- /**
- * @since 4.1
- */
- // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "new_maintainability_remediation_effort"
- public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt";
-
- /**
- * @since 4.1
- */
- // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT
- public static final Metric<Long> NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Added Technical Debt", Metric.ValueType.WORK_DUR)
- .setDescription("Added technical debt")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * @since 4.5
- */
- // TODO should be renamed to MAINTAINABILITY_RATING_KEY = "maintainability_rating"
- public static final String SQALE_RATING_KEY = "sqale_rating";
-
- /**
- * @since 4.5
- */
- // TODO should be renamed to MAINTAINABILITY_RATING
- public static final Metric<Integer> SQALE_RATING = new Metric.Builder(SQALE_RATING_KEY, "Maintainability Rating", Metric.ValueType.RATING)
- .setDescription("A-to-E rating based on the technical debt ratio")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setBestValue(1.0)
- .setWorstValue(5.0)
- .create();
-
- /**
- * @since 6.2
- */
- public static final String NEW_MAINTAINABILITY_RATING_KEY = "new_maintainability_rating";
-
- /**
- * @since 6.2
- */
- public static final Metric<Integer> NEW_MAINTAINABILITY_RATING = new Metric.Builder(NEW_MAINTAINABILITY_RATING_KEY, "Maintainability Rating on New Code", Metric.ValueType.RATING)
- .setDescription("Maintainability rating on new code")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setDeleteHistoricalData(true)
- .setOptimizedBestValue(true)
- .setQualitative(true)
- .setBestValue(1.0)
- .setWorstValue(5.0)
- .create();
-
- /**
- * @since 4.5
- */
- public static final String DEVELOPMENT_COST_KEY = "development_cost";
-
- /**
- * @since 4.5
- */
- public static final Metric<String> DEVELOPMENT_COST = new Metric.Builder(DEVELOPMENT_COST_KEY, "Development Cost", Metric.ValueType.STRING)
- .setDescription("Development cost")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .setHidden(true)
- .create();
-
- /**
- * @since 7.0
- */
- public static final String NEW_DEVELOPMENT_COST_KEY = "new_development_cost";
-
- /**
- * @since 7.0
- */
- public static final Metric<String> NEW_DEVELOPMENT_COST = new Metric.Builder(NEW_DEVELOPMENT_COST_KEY, "Development Cost on New Code", Metric.ValueType.FLOAT)
- .setDescription("Development cost on new code")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .setHidden(true)
- .create();
-
- /**
- * @since 4.5
- */
- // TODO should be renamed to TECHNICALDEBT_RATIO_KEY = "technicaldebt_ratio"
- public static final String SQALE_DEBT_RATIO_KEY = "sqale_debt_ratio";
-
- /**
- * @since 4.5
- */
- // TODO should be renamed to TECHNICALDEBT_RATIO
- public static final Metric<Double> SQALE_DEBT_RATIO = new Metric.Builder(SQALE_DEBT_RATIO_KEY, "Technical Debt Ratio", Metric.ValueType.PERCENT)
- .setDescription("Ratio of the actual technical debt compared to the estimated cost to develop the whole source code from scratch")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .create();
-
- /**
- * @since 5.2
- */
- // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE_KEY = "technicaldebt_ratio_on_new_code"
- public static final String NEW_SQALE_DEBT_RATIO_KEY = "new_sqale_debt_ratio";
-
- /**
- * @since 5.2
- */
- // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE
- 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)
- .setDescription("Technical Debt Ratio of new/changed code.")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .create();
-
- /**
- * @since 5.5
- */
- public static final String EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY = "effort_to_reach_maintainability_rating_a";
-
- /**
- * @since 5.5
- */
- public static final Metric<Long> EFFORT_TO_REACH_MAINTAINABILITY_RATING_A = new Metric.Builder(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY,
- "Effort to Reach Maintainability Rating A", Metric.ValueType.WORK_DUR)
- .setDescription("Effort to reach maintainability rating A")
- .setDomain(DOMAIN_MAINTAINABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // RELIABILITY CHARACTERISTIC
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- /**
- * @since 5.5
- */
- public static final String RELIABILITY_REMEDIATION_EFFORT_KEY = "reliability_remediation_effort";
-
- /**
- * @since 5.5
- */
- public static final Metric<Long> RELIABILITY_REMEDIATION_EFFORT = new Metric.Builder(RELIABILITY_REMEDIATION_EFFORT_KEY, "Reliability Remediation Effort",
- Metric.ValueType.WORK_DUR)
- .setDescription("Reliability Remediation Effort")
- .setDomain(DOMAIN_RELIABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .create();
-
- /**
- * @since 5.5
- */
- public static final String NEW_RELIABILITY_REMEDIATION_EFFORT_KEY = "new_reliability_remediation_effort";
-
- /**
- * @since 5.5
- */
- public static final Metric<Long> NEW_RELIABILITY_REMEDIATION_EFFORT = new Metric.Builder(NEW_RELIABILITY_REMEDIATION_EFFORT_KEY, "Reliability Remediation Effort on New Code",
- Metric.ValueType.WORK_DUR)
- .setDescription("Reliability remediation effort on new code")
- .setDomain(DOMAIN_RELIABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * @since 5.5
- */
- public static final String RELIABILITY_RATING_KEY = "reliability_rating";
-
- /**
- * @since 5.5
- */
- public static final Metric<Integer> RELIABILITY_RATING = new Metric.Builder(RELIABILITY_RATING_KEY, "Reliability Rating", Metric.ValueType.RATING)
- .setDescription("Reliability rating")
- .setDomain(DOMAIN_RELIABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setBestValue(1.0)
- .setWorstValue(5.0)
- .create();
-
- /**
- * @since 6.2
- */
- public static final String NEW_RELIABILITY_RATING_KEY = "new_reliability_rating";
-
- /**
- * @since 6.2
- */
- public static final Metric<Integer> NEW_RELIABILITY_RATING = new Metric.Builder(NEW_RELIABILITY_RATING_KEY, "Reliability Rating on New Code", Metric.ValueType.RATING)
- .setDescription("Reliability rating on new code")
- .setDomain(DOMAIN_RELIABILITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setDeleteHistoricalData(true)
- .setOptimizedBestValue(true)
- .setQualitative(true)
- .setBestValue(1.0)
- .setWorstValue(5.0)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // SECURITY CHARACTERISTIC
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- /**
- * @since 5.5
- */
- public static final String SECURITY_REMEDIATION_EFFORT_KEY = "security_remediation_effort";
-
- /**
- * @since 5.5
- */
- public static final Metric<Long> SECURITY_REMEDIATION_EFFORT = new Metric.Builder(SECURITY_REMEDIATION_EFFORT_KEY, "Security Remediation Effort", Metric.ValueType.WORK_DUR)
- .setDescription("Security remediation effort")
- .setDomain(DOMAIN_SECURITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .create();
-
- /**
- * @since 5.5
- */
- public static final String NEW_SECURITY_REMEDIATION_EFFORT_KEY = "new_security_remediation_effort";
-
- /**
- * @since 5.5
- */
- public static final Metric<Long> NEW_SECURITY_REMEDIATION_EFFORT = new Metric.Builder(NEW_SECURITY_REMEDIATION_EFFORT_KEY, "Security Remediation Effort on New Code",
- Metric.ValueType.WORK_DUR)
- .setDescription("Security remediation effort on new code")
- .setDomain(DOMAIN_SECURITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setOptimizedBestValue(true)
- .setBestValue(0.0)
- .setQualitative(true)
- .setDeleteHistoricalData(true)
- .create();
-
- /**
- * @since 5.5
- */
- public static final String SECURITY_RATING_KEY = "security_rating";
-
- /**
- * @since 5.5
- */
- public static final Metric<Integer> SECURITY_RATING = new Metric.Builder(SECURITY_RATING_KEY, "Security Rating", Metric.ValueType.RATING)
- .setDescription("Security rating")
- .setDomain(DOMAIN_SECURITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setBestValue(1.0)
- .setWorstValue(5.0)
- .create();
-
- /**
- * @since 6.2
- */
- public static final String NEW_SECURITY_RATING_KEY = "new_security_rating";
-
- /**
- * @since 6.2
- */
- public static final Metric<Integer> NEW_SECURITY_RATING = new Metric.Builder(NEW_SECURITY_RATING_KEY, "Security Rating on New Code", Metric.ValueType.RATING)
- .setDescription("Security rating on new code")
- .setDomain(DOMAIN_SECURITY)
- .setDirection(Metric.DIRECTION_WORST)
- .setDeleteHistoricalData(true)
- .setOptimizedBestValue(true)
- .setQualitative(true)
- .setBestValue(1.0)
- .setWorstValue(5.0)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // SECURITY REVIEW
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- /**
- * @since 7.8
- */
- public static final String SECURITY_REVIEW_RATING_KEY = "security_review_rating";
-
- /**
- * @since 7.8
- */
- public static final Metric<Integer> SECURITY_REVIEW_RATING = new Metric.Builder(SECURITY_REVIEW_RATING_KEY, "Security Review Rating", Metric.ValueType.RATING)
- .setDescription("Security Review Rating")
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(true)
- .setBestValue(1.0)
- .setWorstValue(5.0)
- .create();
-
- /**
- * @since 8.2
- */
- public static final String NEW_SECURITY_REVIEW_RATING_KEY = "new_security_review_rating";
-
- /**
- * @since 8.2
- */
- public static final Metric<Integer> NEW_SECURITY_REVIEW_RATING = new Metric.Builder(NEW_SECURITY_REVIEW_RATING_KEY, "Security Review Rating on New Code",
- Metric.ValueType.RATING)
- .setDescription("Security Review Rating on New Code")
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setDirection(Metric.DIRECTION_WORST)
- .setDeleteHistoricalData(true)
- .setOptimizedBestValue(true)
- .setQualitative(true)
- .setBestValue(1.0)
- .setWorstValue(5.0)
- .create();
-
- /**
- * @since 8.2
- */
- public static final String SECURITY_HOTSPOTS_REVIEWED_KEY = "security_hotspots_reviewed";
-
- /**
- * @since 8.2
- */
- public static final Metric<Integer> SECURITY_HOTSPOTS_REVIEWED = new Metric.Builder(SECURITY_HOTSPOTS_REVIEWED_KEY, "Security Hotspots Reviewed", Metric.ValueType.PERCENT)
- .setDescription("Percentage of Security Hotspots Reviewed")
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .create();
-
- /**
- * @since 8.2
- */
- public static final String NEW_SECURITY_HOTSPOTS_REVIEWED_KEY = "new_security_hotspots_reviewed";
-
- /**
- * @since 8.2
- */
- public static final Metric<Integer> NEW_SECURITY_HOTSPOTS_REVIEWED = new Metric.Builder(NEW_SECURITY_HOTSPOTS_REVIEWED_KEY, "Security Hotspots Reviewed on New Code",
- Metric.ValueType.PERCENT)
- .setDescription("Percentage of Security Hotspots Reviewed on New Code")
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setDirection(Metric.DIRECTION_BETTER)
- .setDeleteHistoricalData(true)
- .setQualitative(true)
- .setWorstValue(0.0)
- .setBestValue(100.0)
- .create();
-
- /**
- * @since 8.2
- */
- public static final String SECURITY_HOTSPOTS_REVIEWED_STATUS_KEY = "security_hotspots_reviewed_status";
-
- /**
- * @since 8.2
- *
- * This hidden metric is only needed to compute 'security_review_rating' and 'security_hotspots_reviewed' on Applications.
- */
- public static final Metric<Integer> SECURITY_HOTSPOTS_REVIEWED_STATUS = new Metric.Builder(SECURITY_HOTSPOTS_REVIEWED_STATUS_KEY, "Security Review Reviewed Status",
- Metric.ValueType.INT)
- .setDescription("Security Review Reviewed Status")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .setHidden(true)
- .create();
-
- /**
- * @since 8.2
- */
- public static final String SECURITY_HOTSPOTS_TO_REVIEW_STATUS_KEY = "security_hotspots_to_review_status";
-
- /**
- * @since 8.2
- *
- * This hidden metric is only needed to compute 'security_review_rating' and 'security_hotspots_reviewed' on Applications.
- */
- public static final Metric<Integer> SECURITY_HOTSPOTS_TO_REVIEW_STATUS = new Metric.Builder(SECURITY_HOTSPOTS_TO_REVIEW_STATUS_KEY, "Security Review To Review Status",
- Metric.ValueType.INT)
- .setDescription("Security Review To Review Status")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .setHidden(true)
- .create();
-
- /**
- * @since 8.2
- */
- public static final String NEW_SECURITY_HOTSPOTS_REVIEWED_STATUS_KEY = "new_security_hotspots_reviewed_status";
-
- /**
- * @since 8.2
- *
- * This hidden metric is only needed to compute 'new_security_review_rating' and 'new_security_hotspots_reviewed' on Applications.
- */
- public static final Metric<Integer> NEW_SECURITY_HOTSPOTS_REVIEWED_STATUS = new Metric.Builder(NEW_SECURITY_HOTSPOTS_REVIEWED_STATUS_KEY,
- "Security Review Reviewed Status on New Code", Metric.ValueType.INT)
- .setDescription("Security Review Reviewed Status on New Code")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .setHidden(true)
- .create();
-
- /**
- * @since 8.2
- */
- public static final String NEW_SECURITY_HOTSPOTS_TO_REVIEW_STATUS_KEY = "new_security_hotspots_to_review_status";
-
- /**
- * @since 8.2
- *
- * This hidden metric is only needed to compute 'new_security_review_rating' and 'new_security_hotspots_reviewed' on Applications.
- */
- public static final Metric<Integer> NEW_SECURITY_HOTSPOTS_TO_REVIEW_STATUS = new Metric.Builder(NEW_SECURITY_HOTSPOTS_TO_REVIEW_STATUS_KEY,
- "Security Review To Review Status on New Code", Metric.ValueType.INT)
- .setDescription("Security Review To Review Status on New Code")
- .setDirection(Metric.DIRECTION_WORST)
- .setQualitative(false)
- .setDomain(DOMAIN_SECURITY_REVIEW)
- .setBestValue(0.0)
- .setOptimizedBestValue(true)
- .setDeleteHistoricalData(true)
- .setHidden(true)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // FILE DATA
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- /**
- * @since 2.14
- */
- public static final String NCLOC_DATA_KEY = "ncloc_data";
-
- /**
- * Information about lines of code in file.
- * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains code (1) or not (0).
- * If a line number is missing in the map it is equivalent to the default value (0).
- *
- * @see org.sonar.api.measures.FileLinesContext
- * @since 2.14
- */
- public static final Metric<String> NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA)
- .setHidden(true)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- /**
- * @since 2.14
- * @deprecated in 7.3. Measures are no longer sent within analysis reports, and by consequence no
- * longer persisted nor available from web API.
- */
- @Deprecated
- public static final String COMMENT_LINES_DATA_KEY = "comment_lines_data";
-
- /**
- * Information about comments in file.
- * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains comment (1) or not (0).
- * If a line number is missing in the map it is equivalent to the default value (0).
- *
- * @see org.sonar.api.measures.FileLinesContext
- * @since 2.14
- * @deprecated in 7.3. Measures are no longer sent within analysis reports, and by consequence no
- * longer persisted nor available from web API.
- */
- @Deprecated
- public static final Metric<String> COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA)
- .setHidden(true)
- .setDomain(DOMAIN_SIZE)
- .create();
-
- /**
- * @since 5.5
- */
- public static final String EXECUTABLE_LINES_DATA_KEY = "executable_lines_data";
-
- /**
- * Information about executable lines of code in file.
- * 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).
- * If a line number is missing in the map it is equivalent to the default value (0).
- *
- * @see org.sonar.api.measures.FileLinesContext
- * @since 5.5
- */
- public static final Metric<String> EXECUTABLE_LINES_DATA = new Metric.Builder(EXECUTABLE_LINES_DATA_KEY, "executable_lines_data", Metric.ValueType.DATA)
- .setHidden(true)
- .setDomain(DOMAIN_COVERAGE)
- .create();
-
- // --------------------------------------------------------------------------------------------------------------------
- //
- // OTHERS
- //
- // --------------------------------------------------------------------------------------------------------------------
-
- public static final String ALERT_STATUS_KEY = "alert_status";
- public static final Metric<Metric.Level> ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Quality Gate Status", Metric.ValueType.LEVEL)
- .setDescription("The project status with regard to its quality gate.")
- .setDirection(Metric.DIRECTION_BETTER)
- .setQualitative(true)
- .setDomain(DOMAIN_RELEASABILITY)
- .create();
-
- /**
- * @since 4.4
- */
- public static final String QUALITY_GATE_DETAILS_KEY = "quality_gate_details";
- /**
- * The project detailed status with regard to its quality gate.
- * Storing the global quality gate status, along with all evaluated conditions, into a JSON object.
- *
- * @since 4.4
- */
- public static final Metric<String> QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA)
- .setDescription("The project detailed status with regard to its quality gate")
- .setDomain(DOMAIN_GENERAL)
- .create();
-
- /**
- * @since 4.4
- * @deprecated since 5.5
- */
- @Deprecated
- public static final String QUALITY_PROFILES_KEY = "quality_profiles";
-
- /**
- * @since 4.4
- * @deprecated since 5.5
- */
- @Deprecated
- public static final Metric<String> QUALITY_PROFILES = new Metric.Builder(QUALITY_PROFILES_KEY, "Profiles", Metric.ValueType.DATA)
- .setDescription("Details of quality profiles used during analysis")
- .setQualitative(false)
- .setDomain(DOMAIN_GENERAL)
- .setHidden(true)
- .create();
-
- /**
- * @since 5.2
- */
- public static final String LAST_COMMIT_DATE_KEY = "last_commit_date";
-
- /**
- * Date of the most recent commit. Current implementation is based on commits touching lines of source code. It
- * ignores other changes like file renaming or file deletion.
- *
- * @since 5.2
- */
- public static final Metric LAST_COMMIT_DATE = new Metric.Builder(LAST_COMMIT_DATE_KEY, "Date of Last Commit", Metric.ValueType.MILLISEC)
- .setDomain(CoreMetrics.DOMAIN_SCM)
- // waiting for type "datetime" to be correctly handled
- .setHidden(true)
- .create();
-
- private static final List<Metric> METRICS;
-
- static {
- METRICS = new LinkedList<>();
- for (Field field : CoreMetrics.class.getFields()) {
- if (!Modifier.isTransient(field.getModifiers()) && Metric.class.isAssignableFrom(field.getType())) {
- try {
- Metric metric = (Metric) field.get(null);
- METRICS.add(metric);
- } catch (IllegalAccessException e) {
- throw new SonarException("can not introspect " + CoreMetrics.class + " to get metrics", e);
- }
- }
- }
- }
-
- private CoreMetrics() {
- // only static stuff
- }
-
- public static List<Metric> getMetrics() {
- return METRICS;
- }
-
- public static Metric getMetric(final String key) {
- return METRICS.stream().filter(metric -> metric != null && metric.getKey().equals(key)).findFirst().orElseThrow(NoSuchElementException::new);
- }
- }
|