Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

11 лет назад
7 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
11 лет назад
10 лет назад
12 лет назад
12 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
13 лет назад
8 лет назад
8 лет назад
7 лет назад
8 лет назад
8 лет назад
8 лет назад
7 лет назад
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.api.measures;
  21. import java.lang.reflect.Field;
  22. import java.lang.reflect.Modifier;
  23. import java.util.LinkedList;
  24. import java.util.List;
  25. import java.util.NoSuchElementException;
  26. import org.sonar.api.utils.SonarException;
  27. /**
  28. * @since 1.10
  29. */
  30. public final class CoreMetrics {
  31. // the following fields are not final to avoid compile-time constants used by plugins
  32. public static String DOMAIN_SIZE = "Size";
  33. public static String DOMAIN_COVERAGE = "Coverage";
  34. public static String DOMAIN_COMPLEXITY = "Complexity";
  35. /**
  36. * @deprecated since 6.2. Merged into {@link #DOMAIN_SIZE}
  37. */
  38. @Deprecated
  39. public static String DOMAIN_DOCUMENTATION = "Documentation";
  40. public static String DOMAIN_SCM = "SCM";
  41. public static String DOMAIN_ISSUES = "Issues";
  42. public static String DOMAIN_GENERAL = "General";
  43. public static String DOMAIN_DUPLICATIONS = "Duplications";
  44. /**
  45. * @deprecated in 5.5. Renamed to {@link #DOMAIN_DUPLICATIONS}
  46. */
  47. @Deprecated
  48. public static String DOMAIN_DUPLICATION = "Duplication";
  49. /**
  50. * SonarQube Quality Model
  51. *
  52. * @since 5.5
  53. */
  54. public static String DOMAIN_MAINTAINABILITY = "Maintainability";
  55. /**
  56. * SonarQube Quality Model
  57. *
  58. * @since 5.5
  59. */
  60. public static String DOMAIN_RELIABILITY = "Reliability";
  61. /**
  62. * SonarQube Quality Model
  63. *
  64. * @since 5.5
  65. */
  66. public static String DOMAIN_SECURITY = "Security";
  67. /**
  68. * @since 5.5
  69. */
  70. public static String DOMAIN_RELEASABILITY = "Releasability";
  71. /**
  72. * Computed by the platform since SQ 5.1
  73. */
  74. public static final String LINES_KEY = "lines";
  75. public static final Metric<Integer> LINES = new Metric.Builder(LINES_KEY, "Lines", Metric.ValueType.INT)
  76. .setDescription("Lines")
  77. .setDirection(Metric.DIRECTION_WORST)
  78. .setQualitative(false)
  79. .setDomain(DOMAIN_SIZE)
  80. .create();
  81. public static final String GENERATED_LINES_KEY = "generated_lines";
  82. public static final Metric<Integer> GENERATED_LINES = new Metric.Builder(GENERATED_LINES_KEY, "Generated Lines", Metric.ValueType.INT)
  83. .setDescription("Number of generated lines")
  84. .setDirection(Metric.DIRECTION_WORST)
  85. .setQualitative(false)
  86. .setDomain(DOMAIN_SIZE)
  87. .setBestValue(0.0)
  88. .setOptimizedBestValue(true)
  89. .create();
  90. public static final String NCLOC_KEY = "ncloc";
  91. public static final Metric<Integer> NCLOC = new Metric.Builder(NCLOC_KEY, "Lines of Code", Metric.ValueType.INT)
  92. .setDescription("Non commenting lines of code")
  93. .setDirection(Metric.DIRECTION_WORST)
  94. .setQualitative(false)
  95. .setDomain(DOMAIN_SIZE)
  96. .create();
  97. /**
  98. * @since 6.1
  99. */
  100. public static final String NEW_LINES_KEY = "new_lines";
  101. /**
  102. * @since 6.1
  103. */
  104. public static final Metric<Integer> NEW_LINES = new Metric.Builder(NEW_LINES_KEY, "New Lines", Metric.ValueType.INT)
  105. .setDescription("New lines")
  106. .setDirection(Metric.DIRECTION_WORST)
  107. .setQualitative(false)
  108. .setDomain(DOMAIN_SIZE)
  109. .setDeleteHistoricalData(true)
  110. .create();
  111. /**
  112. * @since 4.4
  113. */
  114. public static final String NCLOC_LANGUAGE_DISTRIBUTION_KEY = "ncloc_language_distribution";
  115. /**
  116. * @since 4.4
  117. */
  118. public static final Metric<String> NCLOC_LANGUAGE_DISTRIBUTION = new Metric.Builder(NCLOC_LANGUAGE_DISTRIBUTION_KEY, "Lines of Code Per Language", Metric.ValueType.DATA)
  119. .setDescription("Non Commenting Lines of Code Distributed By Language")
  120. .setDirection(Metric.DIRECTION_WORST)
  121. .setQualitative(false)
  122. .setDomain(DOMAIN_SIZE)
  123. .create();
  124. public static final String GENERATED_NCLOC_KEY = "generated_ncloc";
  125. public static final Metric<Integer> GENERATED_NCLOC = new Metric.Builder(GENERATED_NCLOC_KEY, "Generated Lines of Code", Metric.ValueType.INT)
  126. .setDescription("Generated non Commenting Lines of Code")
  127. .setDirection(Metric.DIRECTION_WORST)
  128. .setQualitative(false)
  129. .setDomain(DOMAIN_SIZE)
  130. .setBestValue(0.0)
  131. .setOptimizedBestValue(true)
  132. .create();
  133. public static final String CLASSES_KEY = "classes";
  134. public static final Metric<Integer> CLASSES = new Metric.Builder(CLASSES_KEY, "Classes", Metric.ValueType.INT)
  135. .setDescription("Classes")
  136. .setDirection(Metric.DIRECTION_WORST)
  137. .setQualitative(false)
  138. .setDomain(DOMAIN_SIZE)
  139. .create();
  140. public static final String FILES_KEY = "files";
  141. /**
  142. * Computed by the platform.
  143. */
  144. public static final Metric<Integer> FILES = new Metric.Builder(FILES_KEY, "Files", Metric.ValueType.INT)
  145. .setDescription("Number of files")
  146. .setDirection(Metric.DIRECTION_WORST)
  147. .setQualitative(false)
  148. .setDomain(DOMAIN_SIZE)
  149. .create();
  150. /**
  151. * @deprecated since 7.7 - no longer computed
  152. */
  153. @Deprecated
  154. public static final String DIRECTORIES_KEY = "directories";
  155. /**
  156. * @deprecated since 7.7 - no longer computed
  157. */
  158. @Deprecated
  159. public static final Metric<Integer> DIRECTORIES = new Metric.Builder(DIRECTORIES_KEY, "Directories", Metric.ValueType.INT)
  160. .setDescription("Directories")
  161. .setDirection(Metric.DIRECTION_WORST)
  162. .setQualitative(false)
  163. .setDomain(DOMAIN_SIZE)
  164. .create();
  165. /**
  166. * Computed by the platform.
  167. */
  168. public static final String FUNCTIONS_KEY = "functions";
  169. public static final Metric<Integer> FUNCTIONS = new Metric.Builder(FUNCTIONS_KEY, "Functions", Metric.ValueType.INT)
  170. .setDescription("Functions")
  171. .setDirection(Metric.DIRECTION_WORST)
  172. .setQualitative(false)
  173. .setDomain(DOMAIN_SIZE)
  174. .create();
  175. public static final String STATEMENTS_KEY = "statements";
  176. public static final Metric<Integer> STATEMENTS = new Metric.Builder(STATEMENTS_KEY, "Statements", Metric.ValueType.INT)
  177. .setDescription("Number of statements")
  178. .setDirection(Metric.DIRECTION_WORST)
  179. .setQualitative(false)
  180. .setDomain(DOMAIN_SIZE)
  181. .create();
  182. /**
  183. * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
  184. * @deprecated since 6.2
  185. */
  186. @Deprecated
  187. public static final String PUBLIC_API_KEY = "public_api";
  188. public static final Metric<Integer> PUBLIC_API = new Metric.Builder(PUBLIC_API_KEY, "Public API", Metric.ValueType.INT)
  189. .setDescription("Public API")
  190. .setDirection(Metric.DIRECTION_WORST)
  191. .setQualitative(false)
  192. .setDomain(DOMAIN_DOCUMENTATION)
  193. .setHidden(true)
  194. .create();
  195. /**
  196. * @since 3.0
  197. */
  198. public static final String PROJECTS_KEY = "projects";
  199. /**
  200. * @since 3.0
  201. */
  202. public static final Metric<Integer> PROJECTS = new Metric.Builder(PROJECTS_KEY, "Projects", Metric.ValueType.INT)
  203. .setDescription("Number of projects")
  204. .setDirection(Metric.DIRECTION_WORST)
  205. .setQualitative(false)
  206. .setDomain(DOMAIN_SIZE)
  207. .create();
  208. /**
  209. * Moved to Size domain since 6.2
  210. */
  211. public static final String COMMENT_LINES_KEY = "comment_lines";
  212. public static final Metric<Integer> COMMENT_LINES = new Metric.Builder(COMMENT_LINES_KEY, "Comment Lines", Metric.ValueType.INT)
  213. .setDescription("Number of comment lines")
  214. .setDirection(Metric.DIRECTION_BETTER)
  215. .setQualitative(false)
  216. .setDomain(DOMAIN_SIZE)
  217. .create();
  218. /**
  219. * Moved to Size domain since 6.2
  220. */
  221. public static final String COMMENT_LINES_DENSITY_KEY = "comment_lines_density";
  222. public static final Metric<Double> COMMENT_LINES_DENSITY = new Metric.Builder(COMMENT_LINES_DENSITY_KEY, "Comments (%)", Metric.ValueType.PERCENT)
  223. .setDescription("Comments balanced by ncloc + comment lines")
  224. .setDirection(Metric.DIRECTION_BETTER)
  225. .setQualitative(true)
  226. .setDomain(DOMAIN_SIZE)
  227. .create();
  228. // --------------------------------------------------------------------------------------------------------------------
  229. //
  230. // DOCUMENTATION
  231. //
  232. // --------------------------------------------------------------------------------------------------------------------
  233. /**
  234. * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
  235. * @deprecated since 6.2
  236. */
  237. @Deprecated
  238. public static final String PUBLIC_DOCUMENTED_API_DENSITY_KEY = "public_documented_api_density";
  239. public static final Metric<Double> PUBLIC_DOCUMENTED_API_DENSITY = new Metric.Builder(PUBLIC_DOCUMENTED_API_DENSITY_KEY, "Public Documented API (%)", Metric.ValueType.PERCENT)
  240. .setDescription("Public documented classes and functions balanced by ncloc")
  241. .setDirection(Metric.DIRECTION_BETTER)
  242. .setQualitative(true)
  243. .setDomain(DOMAIN_DOCUMENTATION)
  244. .setWorstValue(0.0)
  245. .setBestValue(100.0)
  246. .setOptimizedBestValue(true)
  247. .setHidden(true)
  248. .create();
  249. /**
  250. * @see <a href="https://jira.sonarsource.com/browse/SONAR-8328">SONAR-8328</a>
  251. * @deprecated since 6.2
  252. */
  253. @Deprecated
  254. public static final String PUBLIC_UNDOCUMENTED_API_KEY = "public_undocumented_api";
  255. public static final Metric<Integer> PUBLIC_UNDOCUMENTED_API = new Metric.Builder(PUBLIC_UNDOCUMENTED_API_KEY, "Public Undocumented API", Metric.ValueType.INT)
  256. .setDescription("Public undocumented classes, functions and variables")
  257. .setDirection(Metric.DIRECTION_WORST)
  258. .setQualitative(true)
  259. .setDomain(DOMAIN_DOCUMENTATION)
  260. .setBestValue(0.0)
  261. .setDirection(Metric.DIRECTION_WORST)
  262. .setOptimizedBestValue(true)
  263. .setHidden(true)
  264. .create();
  265. // --------------------------------------------------------------------------------------------------------------------
  266. //
  267. // COMPLEXITY
  268. //
  269. // --------------------------------------------------------------------------------------------------------------------
  270. public static final String COMPLEXITY_KEY = "complexity";
  271. public static final Metric<Integer> COMPLEXITY = new Metric.Builder(COMPLEXITY_KEY, "Cyclomatic Complexity", Metric.ValueType.INT)
  272. .setDescription("Cyclomatic complexity")
  273. .setDirection(Metric.DIRECTION_WORST)
  274. .setQualitative(false)
  275. .setDomain(DOMAIN_COMPLEXITY)
  276. .create();
  277. /**
  278. * @deprecated since 6.7
  279. */
  280. @Deprecated
  281. public static final String FILE_COMPLEXITY_KEY = "file_complexity";
  282. /**
  283. * Information about the cyclomatic complexity per file, calculated by divided the {@link #COMPLEXITY} by the number of {@link #FILES}.
  284. *
  285. * @deprecated since 6.7
  286. */
  287. @Deprecated
  288. public static final Metric<Double> FILE_COMPLEXITY = new Metric.Builder(FILE_COMPLEXITY_KEY, "Complexity / File", Metric.ValueType.FLOAT)
  289. .setDescription("Complexity average by file")
  290. .setDirection(Metric.DIRECTION_WORST)
  291. .setQualitative(true)
  292. .setDomain(DOMAIN_COMPLEXITY)
  293. .setHidden(true)
  294. .create();
  295. /**
  296. * @since 3.6
  297. * @deprecated since 6.7
  298. */
  299. @Deprecated
  300. public static final String COMPLEXITY_IN_CLASSES_KEY = "complexity_in_classes";
  301. /**
  302. * @since 3.6
  303. * @deprecated since 6.7
  304. */
  305. @Deprecated
  306. public static final Metric<Integer> COMPLEXITY_IN_CLASSES = new Metric.Builder(COMPLEXITY_IN_CLASSES_KEY, "Complexity in Classes", Metric.ValueType.INT)
  307. .setDescription("Cyclomatic complexity in classes")
  308. .setHidden(true)
  309. .setDirection(Metric.DIRECTION_WORST)
  310. .setQualitative(false)
  311. .setDomain(DOMAIN_COMPLEXITY)
  312. .setDeleteHistoricalData(true)
  313. .setHidden(true)
  314. .create();
  315. /**
  316. * @deprecated since 6.7
  317. */
  318. @Deprecated
  319. public static final String CLASS_COMPLEXITY_KEY = "class_complexity";
  320. /**
  321. * Information about the cyclomatic complexity per class, calculated by divided the {@link #COMPLEXITY_IN_CLASSES} by the number of {@link #CLASSES}.
  322. *
  323. * @deprecated since 6.7
  324. */
  325. @Deprecated
  326. public static final Metric<Double> CLASS_COMPLEXITY = new Metric.Builder(CLASS_COMPLEXITY_KEY, "Complexity / Class", Metric.ValueType.FLOAT)
  327. .setDescription("Complexity average by class")
  328. .setDirection(Metric.DIRECTION_WORST)
  329. .setQualitative(true)
  330. .setDomain(DOMAIN_COMPLEXITY)
  331. .setHidden(true)
  332. .create();
  333. /**
  334. * @since 3.6
  335. * @deprecated since 6.7
  336. */
  337. @Deprecated
  338. public static final String COMPLEXITY_IN_FUNCTIONS_KEY = "complexity_in_functions";
  339. /**
  340. * @since 3.6
  341. * @deprecated since 6.7
  342. */
  343. @Deprecated
  344. public static final Metric<Integer> COMPLEXITY_IN_FUNCTIONS = new Metric.Builder(COMPLEXITY_IN_FUNCTIONS_KEY, "Complexity in Functions", Metric.ValueType.INT)
  345. .setDescription("Cyclomatic complexity in functions")
  346. .setHidden(true)
  347. .setDirection(Metric.DIRECTION_WORST)
  348. .setQualitative(false)
  349. .setDomain(DOMAIN_COMPLEXITY)
  350. .setDeleteHistoricalData(true)
  351. .setHidden(true)
  352. .create();
  353. /**
  354. * @deprecated since 6.7
  355. */
  356. @Deprecated
  357. public static final String FUNCTION_COMPLEXITY_KEY = "function_complexity";
  358. /**
  359. * Information about the cyclomatic complexity per function, calculated by divided the {@link #COMPLEXITY_IN_FUNCTIONS} by the number of {@link #FUNCTIONS}.
  360. *
  361. * @deprecated since 6.7
  362. */
  363. @Deprecated
  364. public static final Metric<Double> FUNCTION_COMPLEXITY = new Metric.Builder(FUNCTION_COMPLEXITY_KEY, "Complexity / Function", Metric.ValueType.FLOAT)
  365. .setDescription("Complexity average by function")
  366. .setDirection(Metric.DIRECTION_WORST)
  367. .setQualitative(true)
  368. .setDomain(DOMAIN_COMPLEXITY)
  369. .setHidden(true)
  370. .create();
  371. /**
  372. * @deprecated since 6.7
  373. */
  374. @Deprecated
  375. public static final String FUNCTION_COMPLEXITY_DISTRIBUTION_KEY = "function_complexity_distribution";
  376. /**
  377. * @deprecated since 6.7
  378. */
  379. @Deprecated
  380. public static final Metric<String> FUNCTION_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, "Function Distribution / Complexity",
  381. Metric.ValueType.DISTRIB)
  382. .setDescription("Functions distribution /complexity")
  383. .setDirection(Metric.DIRECTION_NONE)
  384. .setQualitative(true)
  385. .setDomain(DOMAIN_COMPLEXITY)
  386. .setHidden(true)
  387. .create();
  388. /**
  389. * @deprecated since 6.7
  390. */
  391. @Deprecated
  392. public static final String FILE_COMPLEXITY_DISTRIBUTION_KEY = "file_complexity_distribution";
  393. /**
  394. * @deprecated since 6.7
  395. */
  396. @Deprecated
  397. public static final Metric<String> FILE_COMPLEXITY_DISTRIBUTION = new Metric.Builder(FILE_COMPLEXITY_DISTRIBUTION_KEY, "File Distribution / Complexity",
  398. Metric.ValueType.DISTRIB)
  399. .setDescription("Files distribution /complexity")
  400. .setDirection(Metric.DIRECTION_NONE)
  401. .setQualitative(true)
  402. .setDomain(DOMAIN_COMPLEXITY)
  403. .setHidden(true)
  404. .create();
  405. public static final String COGNITIVE_COMPLEXITY_KEY = "cognitive_complexity";
  406. public static final Metric<Integer> COGNITIVE_COMPLEXITY = new Metric.Builder(COGNITIVE_COMPLEXITY_KEY, "Cognitive Complexity", Metric.ValueType.INT)
  407. .setDescription("Cognitive complexity")
  408. .setDirection(Metric.DIRECTION_WORST)
  409. .setQualitative(false)
  410. .setDomain(DOMAIN_COMPLEXITY)
  411. .setBestValue(0.0)
  412. .setOptimizedBestValue(true)
  413. .create();
  414. // --------------------------------------------------------------------------------------------------------------------
  415. //
  416. // UNIT TESTS
  417. //
  418. // --------------------------------------------------------------------------------------------------------------------
  419. public static final String TESTS_KEY = "tests";
  420. /**
  421. * Value of measure for this metric can be saved from Sensor, taking into account following rules:
  422. * <ul>
  423. * <li>Non-zero value should be saved for resources representing tests. And Sonar provides default Decorator, which will decorate parent resources.</li>
  424. * <li>Should include {@link #TEST_FAILURES} and {@link #TEST_ERRORS}, but should not include {@link #SKIPPED_TESTS}.</li>
  425. * </ul>
  426. */
  427. public static final Metric<Integer> TESTS = new Metric.Builder(TESTS_KEY, "Unit Tests", Metric.ValueType.INT)
  428. .setDescription("Number of unit tests")
  429. .setDirection(Metric.DIRECTION_BETTER)
  430. .setQualitative(false)
  431. .setDomain(DOMAIN_COVERAGE)
  432. .create();
  433. public static final String TEST_EXECUTION_TIME_KEY = "test_execution_time";
  434. public static final Metric<Long> TEST_EXECUTION_TIME = new Metric.Builder(TEST_EXECUTION_TIME_KEY, "Unit Test Duration", Metric.ValueType.MILLISEC)
  435. .setDescription("Execution duration of unit tests")
  436. .setDirection(Metric.DIRECTION_WORST)
  437. .setQualitative(false)
  438. .setDomain(DOMAIN_COVERAGE)
  439. .create();
  440. public static final String TEST_ERRORS_KEY = "test_errors";
  441. public static final Metric<Integer> TEST_ERRORS = new Metric.Builder(TEST_ERRORS_KEY, "Unit Test Errors", Metric.ValueType.INT)
  442. .setDescription("Number of unit test errors")
  443. .setDirection(Metric.DIRECTION_WORST)
  444. .setQualitative(true)
  445. .setDomain(DOMAIN_COVERAGE)
  446. .setBestValue(0.0)
  447. .setOptimizedBestValue(true)
  448. .create();
  449. public static final String SKIPPED_TESTS_KEY = "skipped_tests";
  450. public static final Metric<Integer> SKIPPED_TESTS = new Metric.Builder(SKIPPED_TESTS_KEY, "Skipped Unit Tests", Metric.ValueType.INT)
  451. .setDescription("Number of skipped unit tests")
  452. .setDirection(Metric.DIRECTION_WORST)
  453. .setQualitative(true)
  454. .setDomain(DOMAIN_COVERAGE)
  455. .setBestValue(0.0)
  456. .setOptimizedBestValue(true)
  457. .create();
  458. public static final String TEST_FAILURES_KEY = "test_failures";
  459. public static final Metric<Integer> TEST_FAILURES = new Metric.Builder(TEST_FAILURES_KEY, "Unit Test Failures", Metric.ValueType.INT)
  460. .setDescription("Number of unit test failures")
  461. .setDirection(Metric.DIRECTION_WORST)
  462. .setQualitative(true)
  463. .setDomain(DOMAIN_COVERAGE)
  464. .setBestValue(0.0)
  465. .setOptimizedBestValue(true)
  466. .create();
  467. public static final String TEST_SUCCESS_DENSITY_KEY = "test_success_density";
  468. public static final Metric<Double> TEST_SUCCESS_DENSITY = new Metric.Builder(TEST_SUCCESS_DENSITY_KEY, "Unit Test Success (%)", Metric.ValueType.PERCENT)
  469. .setDescription("Density of successful unit tests")
  470. .setDirection(Metric.DIRECTION_BETTER)
  471. .setQualitative(true)
  472. .setDomain(DOMAIN_COVERAGE)
  473. .setWorstValue(0.0)
  474. .setBestValue(100.0)
  475. .setOptimizedBestValue(true)
  476. .create();
  477. public static final String COVERAGE_KEY = "coverage";
  478. public static final Metric<Double> COVERAGE = new Metric.Builder(COVERAGE_KEY, "Coverage", Metric.ValueType.PERCENT)
  479. .setDescription("Coverage by tests")
  480. .setDirection(Metric.DIRECTION_BETTER)
  481. .setQualitative(true)
  482. .setDomain(DOMAIN_COVERAGE)
  483. .setWorstValue(0.0)
  484. .setBestValue(100.0)
  485. .create();
  486. public static final String NEW_COVERAGE_KEY = "new_coverage";
  487. public static final Metric<Double> NEW_COVERAGE = new Metric.Builder(NEW_COVERAGE_KEY, "Coverage on New Code", Metric.ValueType.PERCENT)
  488. .setDescription("Coverage of new/changed code")
  489. .setDirection(Metric.DIRECTION_BETTER)
  490. .setQualitative(true)
  491. .setDomain(DOMAIN_COVERAGE)
  492. .setWorstValue(0.0)
  493. .setBestValue(100.0)
  494. .setDeleteHistoricalData(true)
  495. .create();
  496. public static final String LINES_TO_COVER_KEY = "lines_to_cover";
  497. public static final Metric<Integer> LINES_TO_COVER = new Metric.Builder(LINES_TO_COVER_KEY, "Lines to Cover", Metric.ValueType.INT)
  498. .setDescription("Lines to cover")
  499. .setDirection(Metric.DIRECTION_WORST)
  500. .setQualitative(false)
  501. .setDomain(DOMAIN_COVERAGE)
  502. .create();
  503. public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover";
  504. 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)
  505. .setDescription("Lines to cover on new code")
  506. .setDirection(Metric.DIRECTION_WORST)
  507. .setQualitative(false)
  508. .setDomain(DOMAIN_COVERAGE)
  509. .setDeleteHistoricalData(true)
  510. .create();
  511. public static final String UNCOVERED_LINES_KEY = "uncovered_lines";
  512. public static final Metric<Integer> UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, "Uncovered Lines", Metric.ValueType.INT)
  513. .setDescription("Uncovered lines")
  514. .setDirection(Metric.DIRECTION_WORST)
  515. .setDomain(DOMAIN_COVERAGE)
  516. .setBestValue(0.0)
  517. .create();
  518. public static final String NEW_UNCOVERED_LINES_KEY = "new_uncovered_lines";
  519. public static final Metric<Integer> NEW_UNCOVERED_LINES = new Metric.Builder(NEW_UNCOVERED_LINES_KEY, "Uncovered Lines on New Code", Metric.ValueType.INT)
  520. .setDescription("Uncovered lines on new code")
  521. .setDirection(Metric.DIRECTION_WORST)
  522. .setDomain(DOMAIN_COVERAGE)
  523. .setBestValue(0.0)
  524. .setDeleteHistoricalData(true)
  525. .create();
  526. public static final String LINE_COVERAGE_KEY = "line_coverage";
  527. public static final Metric<Double> LINE_COVERAGE = new Metric.Builder(LINE_COVERAGE_KEY, "Line Coverage", Metric.ValueType.PERCENT)
  528. .setDescription("Line coverage")
  529. .setDirection(Metric.DIRECTION_BETTER)
  530. .setQualitative(true)
  531. .setDomain(DOMAIN_COVERAGE)
  532. .setWorstValue(0.0)
  533. .setBestValue(100.0)
  534. .create();
  535. public static final String NEW_LINE_COVERAGE_KEY = "new_line_coverage";
  536. public static final Metric<Double> NEW_LINE_COVERAGE = new Metric.Builder(NEW_LINE_COVERAGE_KEY, "Line Coverage on New Code", Metric.ValueType.PERCENT)
  537. .setDescription("Line coverage of added/changed code")
  538. .setDirection(Metric.DIRECTION_BETTER)
  539. .setQualitative(true)
  540. .setWorstValue(0.0)
  541. .setBestValue(100.0)
  542. .setDomain(DOMAIN_COVERAGE)
  543. .setDeleteHistoricalData(true)
  544. .create();
  545. public static final String CONDITIONS_TO_COVER_KEY = "conditions_to_cover";
  546. public static final Metric<Integer> CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, "Conditions to Cover", Metric.ValueType.INT)
  547. .setDescription("Conditions to cover")
  548. .setDomain(DOMAIN_COVERAGE)
  549. .setDirection(Metric.DIRECTION_WORST)
  550. .create();
  551. public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover";
  552. 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)
  553. .setDescription("Conditions to cover on new code")
  554. .setDomain(DOMAIN_COVERAGE)
  555. .setDirection(Metric.DIRECTION_WORST)
  556. .setDeleteHistoricalData(true)
  557. .create();
  558. public static final String UNCOVERED_CONDITIONS_KEY = "uncovered_conditions";
  559. public static final Metric<Integer> UNCOVERED_CONDITIONS = new Metric.Builder(UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions", Metric.ValueType.INT)
  560. .setDescription("Uncovered conditions")
  561. .setDirection(Metric.DIRECTION_WORST)
  562. .setDomain(DOMAIN_COVERAGE)
  563. .setBestValue(0.0)
  564. .create();
  565. public static final String NEW_UNCOVERED_CONDITIONS_KEY = "new_uncovered_conditions";
  566. public static final Metric<Integer> NEW_UNCOVERED_CONDITIONS = new Metric.Builder(NEW_UNCOVERED_CONDITIONS_KEY, "Uncovered Conditions on New Code", Metric.ValueType.INT)
  567. .setDescription("Uncovered conditions on new code")
  568. .setDirection(Metric.DIRECTION_WORST)
  569. .setDomain(DOMAIN_COVERAGE)
  570. .setBestValue(0.0)
  571. .setDeleteHistoricalData(true)
  572. .create();
  573. public static final String BRANCH_COVERAGE_KEY = "branch_coverage";
  574. public static final Metric<Double> BRANCH_COVERAGE = new Metric.Builder(BRANCH_COVERAGE_KEY, "Condition Coverage", Metric.ValueType.PERCENT)
  575. .setDescription("Condition coverage")
  576. .setDirection(Metric.DIRECTION_BETTER)
  577. .setQualitative(true)
  578. .setDomain(DOMAIN_COVERAGE)
  579. .setWorstValue(0.0)
  580. .setBestValue(100.0)
  581. .create();
  582. public static final String NEW_BRANCH_COVERAGE_KEY = "new_branch_coverage";
  583. public static final Metric<Double> NEW_BRANCH_COVERAGE = new Metric.Builder(NEW_BRANCH_COVERAGE_KEY, "Condition Coverage on New Code", Metric.ValueType.PERCENT)
  584. .setDescription("Condition coverage of new/changed code")
  585. .setDirection(Metric.DIRECTION_BETTER)
  586. .setQualitative(true)
  587. .setDomain(DOMAIN_COVERAGE)
  588. .setWorstValue(0.0)
  589. .setBestValue(100.0)
  590. .setDeleteHistoricalData(true)
  591. .create();
  592. // --------------------------------------------------------------------------------------------------------------------
  593. //
  594. // DUPLICATIONS
  595. //
  596. // --------------------------------------------------------------------------------------------------------------------
  597. public static final String DUPLICATED_LINES_KEY = "duplicated_lines";
  598. public static final Metric<Integer> DUPLICATED_LINES = new Metric.Builder(DUPLICATED_LINES_KEY, "Duplicated Lines", Metric.ValueType.INT)
  599. .setDescription("Duplicated lines")
  600. .setDirection(Metric.DIRECTION_WORST)
  601. .setQualitative(true)
  602. .setDomain(DOMAIN_DUPLICATIONS)
  603. .setBestValue(0.0)
  604. .setOptimizedBestValue(true)
  605. .create();
  606. /**
  607. * @since 6.1
  608. */
  609. public static final String NEW_DUPLICATED_LINES_KEY = "new_duplicated_lines";
  610. /**
  611. * @since 6.1
  612. */
  613. public static final Metric<Integer> NEW_DUPLICATED_LINES = new Metric.Builder(NEW_DUPLICATED_LINES_KEY, "Duplicated Lines on New Code", Metric.ValueType.INT)
  614. .setDescription("Duplicated Lines on New Code")
  615. .setDirection(Metric.DIRECTION_WORST)
  616. .setQualitative(true)
  617. .setDomain(DOMAIN_DUPLICATIONS)
  618. .setBestValue(0.0)
  619. .setDeleteHistoricalData(true)
  620. .create();
  621. public static final String DUPLICATED_BLOCKS_KEY = "duplicated_blocks";
  622. public static final Metric<Integer> DUPLICATED_BLOCKS = new Metric.Builder(DUPLICATED_BLOCKS_KEY, "Duplicated Blocks", Metric.ValueType.INT)
  623. .setDescription("Duplicated blocks")
  624. .setDirection(Metric.DIRECTION_WORST)
  625. .setQualitative(true)
  626. .setDomain(DOMAIN_DUPLICATIONS)
  627. .setBestValue(0.0)
  628. .setOptimizedBestValue(true)
  629. .create();
  630. /**
  631. * @since 6.1
  632. */
  633. public static final String NEW_BLOCKS_DUPLICATED_KEY = "new_duplicated_blocks";
  634. /**
  635. * @since 6.1
  636. */
  637. public static final Metric<Integer> NEW_BLOCKS_DUPLICATED = new Metric.Builder(NEW_BLOCKS_DUPLICATED_KEY, "Duplicated Blocks on New Code", Metric.ValueType.INT)
  638. .setDescription("Duplicated blocks on new code")
  639. .setDirection(Metric.DIRECTION_WORST)
  640. .setQualitative(true)
  641. .setDomain(DOMAIN_DUPLICATIONS)
  642. .setBestValue(0.0)
  643. .setDeleteHistoricalData(true)
  644. .create();
  645. public static final String DUPLICATED_FILES_KEY = "duplicated_files";
  646. /**
  647. * For files: if it contains duplicates, then 1, otherwise 0.
  648. * For other resources: amount of files under this resource with duplicates.
  649. */
  650. public static final Metric<Integer> DUPLICATED_FILES = new Metric.Builder(DUPLICATED_FILES_KEY, "Duplicated Files", Metric.ValueType.INT)
  651. .setDescription("Duplicated files")
  652. .setDirection(Metric.DIRECTION_WORST)
  653. .setQualitative(true)
  654. .setDomain(DOMAIN_DUPLICATIONS)
  655. .setBestValue(0.0)
  656. .setOptimizedBestValue(true)
  657. .create();
  658. public static final String DUPLICATED_LINES_DENSITY_KEY = "duplicated_lines_density";
  659. public static final Metric<Double> DUPLICATED_LINES_DENSITY = new Metric.Builder(DUPLICATED_LINES_DENSITY_KEY, "Duplicated Lines (%)", Metric.ValueType.PERCENT)
  660. .setDescription("Duplicated lines balanced by statements")
  661. .setDirection(Metric.DIRECTION_WORST)
  662. .setQualitative(true)
  663. .setDomain(DOMAIN_DUPLICATIONS)
  664. .setWorstValue(50.0)
  665. .setBestValue(0.0)
  666. .setOptimizedBestValue(true)
  667. .create();
  668. /**
  669. * @since 6.1
  670. */
  671. public static final String NEW_DUPLICATED_LINES_DENSITY_KEY = "new_duplicated_lines_density";
  672. /**
  673. * @since 6.1
  674. */
  675. public static final Metric<Integer> NEW_DUPLICATED_LINES_DENSITY = new Metric.Builder(NEW_DUPLICATED_LINES_DENSITY_KEY, "Duplicated Lines on New Code",
  676. Metric.ValueType.PERCENT)
  677. .setDescription("Duplicated lines on new code balanced by statements")
  678. .setDirection(Metric.DIRECTION_WORST)
  679. .setQualitative(true)
  680. .setDomain(DOMAIN_DUPLICATIONS)
  681. .setBestValue(0.0)
  682. .setDeleteHistoricalData(true)
  683. .create();
  684. /**
  685. * @deprecated since 4.5. Internal storage of duplication is not an API.
  686. */
  687. @Deprecated
  688. public static final String DUPLICATIONS_DATA_KEY = "duplications_data";
  689. /**
  690. * Information about duplications, which is represented as an XML string.
  691. * <p>
  692. * Here is the format (since Sonar 2.12):
  693. * <pre>
  694. * {@literal
  695. * <duplications>
  696. * <!-- Multiple groups: -->
  697. * <g>
  698. * <!-- Multiple blocks: -->
  699. * <b r="[resource key]" s="[first line]" l="[number of lines]" />
  700. * ...
  701. * </g>
  702. * ...
  703. * </duplications>
  704. * }
  705. * </pre>
  706. *
  707. * @deprecated since 4.5. Internal storage of duplication is not an API.
  708. */
  709. @Deprecated
  710. public static final Metric<String> DUPLICATIONS_DATA = new Metric.Builder(DUPLICATIONS_DATA_KEY, "Duplication Details", Metric.ValueType.DATA)
  711. .setDescription("Duplications details")
  712. .setDirection(Metric.DIRECTION_NONE)
  713. .setQualitative(false)
  714. .setDomain(DOMAIN_DUPLICATIONS)
  715. .setDeleteHistoricalData(true)
  716. .create();
  717. // --------------------------------------------------------------------------------------------------------------------
  718. //
  719. // CODING RULES
  720. //
  721. // --------------------------------------------------------------------------------------------------------------------
  722. public static final String VIOLATIONS_KEY = "violations";
  723. public static final Metric<Integer> VIOLATIONS = new Metric.Builder(VIOLATIONS_KEY, "Issues", Metric.ValueType.INT)
  724. .setDescription("Issues")
  725. .setDirection(Metric.DIRECTION_WORST)
  726. .setQualitative(true)
  727. .setDomain(DOMAIN_ISSUES)
  728. .setBestValue(0.0)
  729. .setOptimizedBestValue(true)
  730. .create();
  731. public static final String BLOCKER_VIOLATIONS_KEY = "blocker_violations";
  732. public static final Metric<Integer> BLOCKER_VIOLATIONS = new Metric.Builder(BLOCKER_VIOLATIONS_KEY, "Blocker Issues", Metric.ValueType.INT)
  733. .setDescription("Blocker issues")
  734. .setDirection(Metric.DIRECTION_WORST)
  735. .setQualitative(true)
  736. .setDomain(DOMAIN_ISSUES)
  737. .setBestValue(0.0)
  738. .setOptimizedBestValue(true)
  739. .create();
  740. public static final String CRITICAL_VIOLATIONS_KEY = "critical_violations";
  741. public static final Metric<Integer> CRITICAL_VIOLATIONS = new Metric.Builder(CRITICAL_VIOLATIONS_KEY, "Critical Issues", Metric.ValueType.INT)
  742. .setDescription("Critical issues")
  743. .setDirection(Metric.DIRECTION_WORST)
  744. .setQualitative(true)
  745. .setDomain(DOMAIN_ISSUES)
  746. .setBestValue(0.0)
  747. .setOptimizedBestValue(true)
  748. .create();
  749. public static final String MAJOR_VIOLATIONS_KEY = "major_violations";
  750. public static final Metric<Integer> MAJOR_VIOLATIONS = new Metric.Builder(MAJOR_VIOLATIONS_KEY, "Major Issues", Metric.ValueType.INT)
  751. .setDescription("Major issues")
  752. .setDirection(Metric.DIRECTION_WORST)
  753. .setQualitative(true)
  754. .setDomain(DOMAIN_ISSUES)
  755. .setBestValue(0.0)
  756. .setOptimizedBestValue(true)
  757. .create();
  758. public static final String MINOR_VIOLATIONS_KEY = "minor_violations";
  759. public static final Metric<Integer> MINOR_VIOLATIONS = new Metric.Builder(MINOR_VIOLATIONS_KEY, "Minor Issues", Metric.ValueType.INT)
  760. .setDescription("Minor issues")
  761. .setDirection(Metric.DIRECTION_WORST)
  762. .setQualitative(true)
  763. .setDomain(DOMAIN_ISSUES)
  764. .setBestValue(0.0)
  765. .setOptimizedBestValue(true)
  766. .create();
  767. public static final String INFO_VIOLATIONS_KEY = "info_violations";
  768. public static final Metric<Integer> INFO_VIOLATIONS = new Metric.Builder(INFO_VIOLATIONS_KEY, "Info Issues", Metric.ValueType.INT)
  769. .setDescription("Info issues")
  770. .setDirection(Metric.DIRECTION_WORST)
  771. .setQualitative(true)
  772. .setDomain(DOMAIN_ISSUES)
  773. .setBestValue(0.0)
  774. .setOptimizedBestValue(true)
  775. .create();
  776. public static final String NEW_VIOLATIONS_KEY = "new_violations";
  777. public static final Metric<Integer> NEW_VIOLATIONS = new Metric.Builder(NEW_VIOLATIONS_KEY, "New Issues", Metric.ValueType.INT)
  778. .setDescription("New issues")
  779. .setDirection(Metric.DIRECTION_WORST)
  780. .setQualitative(true)
  781. .setDomain(DOMAIN_ISSUES)
  782. .setBestValue(0.0)
  783. .setOptimizedBestValue(true)
  784. .setDeleteHistoricalData(true)
  785. .create();
  786. public static final String NEW_BLOCKER_VIOLATIONS_KEY = "new_blocker_violations";
  787. public static final Metric<Integer> NEW_BLOCKER_VIOLATIONS = new Metric.Builder(NEW_BLOCKER_VIOLATIONS_KEY, "New Blocker Issues", Metric.ValueType.INT)
  788. .setDescription("New Blocker issues")
  789. .setDirection(Metric.DIRECTION_WORST)
  790. .setQualitative(true)
  791. .setDomain(DOMAIN_ISSUES)
  792. .setBestValue(0.0)
  793. .setOptimizedBestValue(true)
  794. .setDeleteHistoricalData(true)
  795. .create();
  796. public static final String NEW_CRITICAL_VIOLATIONS_KEY = "new_critical_violations";
  797. public static final Metric<Integer> NEW_CRITICAL_VIOLATIONS = new Metric.Builder(NEW_CRITICAL_VIOLATIONS_KEY, "New Critical Issues", Metric.ValueType.INT)
  798. .setDescription("New Critical issues")
  799. .setDirection(Metric.DIRECTION_WORST)
  800. .setQualitative(true)
  801. .setDomain(DOMAIN_ISSUES)
  802. .setBestValue(0.0)
  803. .setOptimizedBestValue(true)
  804. .setDeleteHistoricalData(true)
  805. .create();
  806. public static final String NEW_MAJOR_VIOLATIONS_KEY = "new_major_violations";
  807. public static final Metric<Integer> NEW_MAJOR_VIOLATIONS = new Metric.Builder(NEW_MAJOR_VIOLATIONS_KEY, "New Major Issues", Metric.ValueType.INT)
  808. .setDescription("New Major issues")
  809. .setDirection(Metric.DIRECTION_WORST)
  810. .setQualitative(true)
  811. .setDomain(DOMAIN_ISSUES)
  812. .setBestValue(0.0)
  813. .setOptimizedBestValue(true)
  814. .setDeleteHistoricalData(true)
  815. .create();
  816. public static final String NEW_MINOR_VIOLATIONS_KEY = "new_minor_violations";
  817. public static final Metric<Integer> NEW_MINOR_VIOLATIONS = new Metric.Builder(NEW_MINOR_VIOLATIONS_KEY, "New Minor Issues", Metric.ValueType.INT)
  818. .setDescription("New Minor issues")
  819. .setDirection(Metric.DIRECTION_WORST)
  820. .setQualitative(true)
  821. .setDomain(DOMAIN_ISSUES)
  822. .setBestValue(0.0)
  823. .setOptimizedBestValue(true)
  824. .setDeleteHistoricalData(true)
  825. .create();
  826. public static final String NEW_INFO_VIOLATIONS_KEY = "new_info_violations";
  827. public static final Metric<Integer> NEW_INFO_VIOLATIONS = new Metric.Builder(NEW_INFO_VIOLATIONS_KEY, "New Info Issues", Metric.ValueType.INT)
  828. .setDescription("New Info issues")
  829. .setDirection(Metric.DIRECTION_WORST)
  830. .setQualitative(true)
  831. .setDomain(DOMAIN_ISSUES)
  832. .setBestValue(0.0)
  833. .setOptimizedBestValue(true)
  834. .setDeleteHistoricalData(true)
  835. .create();
  836. /**
  837. * @since 3.6
  838. */
  839. public static final String FALSE_POSITIVE_ISSUES_KEY = "false_positive_issues";
  840. /**
  841. * @since 3.6
  842. */
  843. public static final Metric<Integer> FALSE_POSITIVE_ISSUES = new Metric.Builder(FALSE_POSITIVE_ISSUES_KEY, "False Positive Issues", Metric.ValueType.INT)
  844. .setDescription("False positive issues")
  845. .setDirection(Metric.DIRECTION_WORST)
  846. .setDomain(DOMAIN_ISSUES)
  847. .setBestValue(0.0)
  848. .setOptimizedBestValue(true)
  849. .create();
  850. /**
  851. * @since 5.6
  852. */
  853. public static final String WONT_FIX_ISSUES_KEY = "wont_fix_issues";
  854. /**
  855. * @since 5.6
  856. */
  857. public static final Metric<Integer> WONT_FIX_ISSUES = new Metric.Builder(WONT_FIX_ISSUES_KEY, "Won't Fix Issues", Metric.ValueType.INT)
  858. .setDescription("Won't fix issues")
  859. .setDirection(Metric.DIRECTION_WORST)
  860. .setDomain(DOMAIN_ISSUES)
  861. .setBestValue(0.0)
  862. .setOptimizedBestValue(true)
  863. .create();
  864. /**
  865. * @since 3.6
  866. */
  867. public static final String OPEN_ISSUES_KEY = "open_issues";
  868. /**
  869. * @since 3.6
  870. */
  871. public static final Metric<Integer> OPEN_ISSUES = new Metric.Builder(OPEN_ISSUES_KEY, "Open Issues", Metric.ValueType.INT)
  872. .setDescription("Open issues")
  873. .setDirection(Metric.DIRECTION_WORST)
  874. .setDomain(DOMAIN_ISSUES)
  875. .setBestValue(0.0)
  876. .setOptimizedBestValue(true)
  877. .create();
  878. /**
  879. * @since 3.6
  880. */
  881. public static final String REOPENED_ISSUES_KEY = "reopened_issues";
  882. /**
  883. * @since 3.6
  884. */
  885. public static final Metric<Integer> REOPENED_ISSUES = new Metric.Builder(REOPENED_ISSUES_KEY, "Reopened Issues", Metric.ValueType.INT)
  886. .setDescription("Reopened issues")
  887. .setDirection(Metric.DIRECTION_WORST)
  888. .setQualitative(true)
  889. .setDomain(DOMAIN_ISSUES)
  890. .setBestValue(0.0)
  891. .setOptimizedBestValue(true)
  892. .create();
  893. /**
  894. * @since 3.6
  895. */
  896. public static final String CONFIRMED_ISSUES_KEY = "confirmed_issues";
  897. /**
  898. * @since 3.6
  899. */
  900. public static final Metric<Integer> CONFIRMED_ISSUES = new Metric.Builder(CONFIRMED_ISSUES_KEY, "Confirmed Issues", Metric.ValueType.INT)
  901. .setDescription("Confirmed issues")
  902. .setDirection(Metric.DIRECTION_WORST)
  903. .setQualitative(true)
  904. .setDomain(DOMAIN_ISSUES)
  905. .setBestValue(0.0)
  906. .setOptimizedBestValue(true)
  907. .create();
  908. /**
  909. * SonarQube Quality Model
  910. *
  911. * @since 5.5
  912. */
  913. public static final String CODE_SMELLS_KEY = "code_smells";
  914. /**
  915. * SonarQube Quality Model
  916. *
  917. * @since 5.5
  918. */
  919. public static final Metric<Integer> CODE_SMELLS = new Metric.Builder(CODE_SMELLS_KEY, "Code Smells", Metric.ValueType.INT)
  920. .setDescription("Code Smells")
  921. .setDirection(Metric.DIRECTION_WORST)
  922. .setQualitative(false)
  923. .setDomain(DOMAIN_MAINTAINABILITY)
  924. .setBestValue(0.0)
  925. .setOptimizedBestValue(true)
  926. .create();
  927. /**
  928. * SonarQube Quality Model
  929. *
  930. * @since 5.5
  931. */
  932. public static final String NEW_CODE_SMELLS_KEY = "new_code_smells";
  933. /**
  934. * SonarQube Quality Model
  935. *
  936. * @since 5.5
  937. */
  938. public static final Metric<Integer> NEW_CODE_SMELLS = new Metric.Builder(NEW_CODE_SMELLS_KEY, "New Code Smells", Metric.ValueType.INT)
  939. .setDescription("New Code Smells")
  940. .setDirection(Metric.DIRECTION_WORST)
  941. .setQualitative(true)
  942. .setDomain(DOMAIN_MAINTAINABILITY)
  943. .setBestValue(0.0)
  944. .setOptimizedBestValue(true)
  945. .setDeleteHistoricalData(true)
  946. .create();
  947. /**
  948. * SonarQube Quality Model
  949. *
  950. * @since 5.5
  951. */
  952. public static final String BUGS_KEY = "bugs";
  953. /**
  954. * SonarQube Quality Model
  955. *
  956. * @since 5.5
  957. */
  958. public static final Metric<Integer> BUGS = new Metric.Builder(BUGS_KEY, "Bugs", Metric.ValueType.INT)
  959. .setDescription("Bugs")
  960. .setDirection(Metric.DIRECTION_WORST)
  961. .setQualitative(false)
  962. .setDomain(DOMAIN_RELIABILITY)
  963. .setBestValue(0.0)
  964. .setOptimizedBestValue(true)
  965. .create();
  966. /**
  967. * SonarQube Quality Model
  968. *
  969. * @since 5.5
  970. */
  971. public static final String NEW_BUGS_KEY = "new_bugs";
  972. /**
  973. * SonarQube Quality Model
  974. *
  975. * @since 5.5
  976. */
  977. public static final Metric<Integer> NEW_BUGS = new Metric.Builder(NEW_BUGS_KEY, "New Bugs", Metric.ValueType.INT)
  978. .setDescription("New Bugs")
  979. .setDirection(Metric.DIRECTION_WORST)
  980. .setQualitative(true)
  981. .setDomain(DOMAIN_RELIABILITY)
  982. .setBestValue(0.0)
  983. .setOptimizedBestValue(true)
  984. .setDeleteHistoricalData(true)
  985. .create();
  986. /**
  987. * SonarQube Quality Model
  988. *
  989. * @since 5.5
  990. */
  991. public static final String VULNERABILITIES_KEY = "vulnerabilities";
  992. /**
  993. * SonarQube Quality Model
  994. *
  995. * @since 5.5
  996. */
  997. public static final Metric<Integer> VULNERABILITIES = new Metric.Builder(VULNERABILITIES_KEY, "Vulnerabilities", Metric.ValueType.INT)
  998. .setDescription("Vulnerabilities")
  999. .setDirection(Metric.DIRECTION_WORST)
  1000. .setQualitative(false)
  1001. .setDomain(DOMAIN_SECURITY)
  1002. .setBestValue(0.0)
  1003. .setOptimizedBestValue(true)
  1004. .create();
  1005. /**
  1006. * SonarQube Quality Model
  1007. *
  1008. * @since 5.5
  1009. */
  1010. public static final String NEW_VULNERABILITIES_KEY = "new_vulnerabilities";
  1011. /**
  1012. * SonarQube Quality Model
  1013. *
  1014. * @since 5.5
  1015. */
  1016. public static final Metric<Integer> NEW_VULNERABILITIES = new Metric.Builder(NEW_VULNERABILITIES_KEY, "New Vulnerabilities", Metric.ValueType.INT)
  1017. .setDescription("New Vulnerabilities")
  1018. .setDirection(Metric.DIRECTION_WORST)
  1019. .setQualitative(true)
  1020. .setDomain(DOMAIN_SECURITY)
  1021. .setBestValue(0.0)
  1022. .setOptimizedBestValue(true)
  1023. .setDeleteHistoricalData(true)
  1024. .create();
  1025. /**
  1026. * @since 7.8
  1027. */
  1028. public static final String SECURITY_HOTSPOTS_KEY = "security_hotspots";
  1029. /**
  1030. * @since 7.8
  1031. */
  1032. public static final Metric<Integer> SECURITY_HOTSPOTS = new Metric.Builder(SECURITY_HOTSPOTS_KEY, "Security Hotspots", Metric.ValueType.INT)
  1033. .setDescription("Security Hotspots")
  1034. .setDirection(Metric.DIRECTION_WORST)
  1035. .setQualitative(false)
  1036. .setDomain(DOMAIN_SECURITY)
  1037. .setBestValue(0.0)
  1038. .setOptimizedBestValue(true)
  1039. .create();
  1040. /**
  1041. * @since 7.8
  1042. */
  1043. public static final String NEW_SECURITY_HOTSPOTS_KEY = "new_security_hotspots";
  1044. /**
  1045. * @since 7.8
  1046. */
  1047. public static final Metric<Integer> NEW_SECURITY_HOTSPOTS = new Metric.Builder(NEW_SECURITY_HOTSPOTS_KEY, "New Security Hotspots", Metric.ValueType.INT)
  1048. .setDescription("New Security Hotspots")
  1049. .setDirection(Metric.DIRECTION_WORST)
  1050. .setQualitative(true)
  1051. .setDomain(DOMAIN_SECURITY)
  1052. .setBestValue(0.0)
  1053. .setOptimizedBestValue(true)
  1054. .setDeleteHistoricalData(true)
  1055. .create();
  1056. // --------------------------------------------------------------------------------------------------------------------
  1057. //
  1058. // MAINTAINABILITY CHARACTERISTIC
  1059. //
  1060. // --------------------------------------------------------------------------------------------------------------------
  1061. /**
  1062. * @since 4.0
  1063. */
  1064. // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "maintainability_remediation_effort"
  1065. public static final String TECHNICAL_DEBT_KEY = "sqale_index";
  1066. /**
  1067. * @since 4.0
  1068. */
  1069. // TODO should be renamed to MAINTAINABILITY_REMEDIATION_EFFORT
  1070. public static final Metric<Long> TECHNICAL_DEBT = new Metric.Builder(TECHNICAL_DEBT_KEY, "Technical Debt", Metric.ValueType.WORK_DUR)
  1071. .setDescription("Total effort (in hours) to fix all the issues on the component and therefore to comply to all the requirements.")
  1072. .setDomain(DOMAIN_MAINTAINABILITY)
  1073. .setDirection(Metric.DIRECTION_WORST)
  1074. .setOptimizedBestValue(true)
  1075. .setBestValue(0.0)
  1076. .setQualitative(true)
  1077. .create();
  1078. /**
  1079. * @since 4.1
  1080. */
  1081. // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT_KEY = "new_maintainability_remediation_effort"
  1082. public static final String NEW_TECHNICAL_DEBT_KEY = "new_technical_debt";
  1083. /**
  1084. * @since 4.1
  1085. */
  1086. // TODO should be renamed to NEW_MAINTAINABILITY_REMEDIATION_EFFORT
  1087. public static final Metric<Long> NEW_TECHNICAL_DEBT = new Metric.Builder(NEW_TECHNICAL_DEBT_KEY, "Added Technical Debt", Metric.ValueType.WORK_DUR)
  1088. .setDescription("Added technical debt")
  1089. .setDomain(DOMAIN_MAINTAINABILITY)
  1090. .setDirection(Metric.DIRECTION_WORST)
  1091. .setOptimizedBestValue(true)
  1092. .setBestValue(0.0)
  1093. .setQualitative(true)
  1094. .setDeleteHistoricalData(true)
  1095. .create();
  1096. /**
  1097. * @since 4.5
  1098. */
  1099. // TODO should be renamed to MAINTAINABILITY_RATING_KEY = "maintainability_rating"
  1100. public static final String SQALE_RATING_KEY = "sqale_rating";
  1101. /**
  1102. * @since 4.5
  1103. */
  1104. // TODO should be renamed to MAINTAINABILITY_RATING
  1105. public static final Metric<Integer> SQALE_RATING = new Metric.Builder(SQALE_RATING_KEY, "Maintainability Rating", Metric.ValueType.RATING)
  1106. .setDescription("A-to-E rating based on the technical debt ratio")
  1107. .setDomain(DOMAIN_MAINTAINABILITY)
  1108. .setDirection(Metric.DIRECTION_WORST)
  1109. .setQualitative(true)
  1110. .setBestValue(1.0)
  1111. .setWorstValue(5.0)
  1112. .create();
  1113. /**
  1114. * @since 6.2
  1115. */
  1116. public static final String NEW_MAINTAINABILITY_RATING_KEY = "new_maintainability_rating";
  1117. /**
  1118. * @since 6.2
  1119. */
  1120. public static final Metric<Integer> NEW_MAINTAINABILITY_RATING = new Metric.Builder(NEW_MAINTAINABILITY_RATING_KEY, "Maintainability Rating on New Code", Metric.ValueType.RATING)
  1121. .setDescription("Maintainability rating on new code")
  1122. .setDomain(DOMAIN_MAINTAINABILITY)
  1123. .setDirection(Metric.DIRECTION_WORST)
  1124. .setDeleteHistoricalData(true)
  1125. .setOptimizedBestValue(true)
  1126. .setQualitative(true)
  1127. .setBestValue(1.0)
  1128. .setWorstValue(5.0)
  1129. .create();
  1130. /**
  1131. * @since 4.5
  1132. */
  1133. public static final String DEVELOPMENT_COST_KEY = "development_cost";
  1134. /**
  1135. * @since 4.5
  1136. */
  1137. public static final Metric<String> DEVELOPMENT_COST = new Metric.Builder(DEVELOPMENT_COST_KEY, "Development Cost", Metric.ValueType.STRING)
  1138. .setDescription("Development cost")
  1139. .setDomain(DOMAIN_MAINTAINABILITY)
  1140. .setDirection(Metric.DIRECTION_WORST)
  1141. .setOptimizedBestValue(true)
  1142. .setBestValue(0.0)
  1143. .setQualitative(true)
  1144. .setHidden(true)
  1145. .create();
  1146. /**
  1147. * @since 7.0
  1148. */
  1149. public static final String NEW_DEVELOPMENT_COST_KEY = "new_development_cost";
  1150. /**
  1151. * @since 7.0
  1152. */
  1153. public static final Metric<String> NEW_DEVELOPMENT_COST = new Metric.Builder(NEW_DEVELOPMENT_COST_KEY, "Development Cost on New Code", Metric.ValueType.STRING)
  1154. .setDescription("Development cost on new code")
  1155. .setDomain(DOMAIN_MAINTAINABILITY)
  1156. .setDirection(Metric.DIRECTION_WORST)
  1157. .setOptimizedBestValue(true)
  1158. .setBestValue(0.0)
  1159. .setQualitative(true)
  1160. .setHidden(true)
  1161. .create();
  1162. /**
  1163. * @since 4.5
  1164. */
  1165. // TODO should be renamed to TECHNICALDEBT_RATIO_KEY = "technicaldebt_ratio"
  1166. public static final String SQALE_DEBT_RATIO_KEY = "sqale_debt_ratio";
  1167. /**
  1168. * @since 4.5
  1169. */
  1170. // TODO should be renamed to TECHNICALDEBT_RATIO
  1171. public static final Metric<Double> SQALE_DEBT_RATIO = new Metric.Builder(SQALE_DEBT_RATIO_KEY, "Technical Debt Ratio", Metric.ValueType.PERCENT)
  1172. .setDescription("Ratio of the actual technical debt compared to the estimated cost to develop the whole source code from scratch")
  1173. .setDomain(DOMAIN_MAINTAINABILITY)
  1174. .setDirection(Metric.DIRECTION_WORST)
  1175. .setOptimizedBestValue(true)
  1176. .setBestValue(0.0)
  1177. .setQualitative(true)
  1178. .create();
  1179. /**
  1180. * @since 5.2
  1181. */
  1182. // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE_KEY = "technicaldebt_ratio_on_new_code"
  1183. public static final String NEW_SQALE_DEBT_RATIO_KEY = "new_sqale_debt_ratio";
  1184. /**
  1185. * @since 5.2
  1186. */
  1187. // TODO should be renamed to TECHNICALDEBT_RATIO_ON_NEW_CODE
  1188. 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)
  1189. .setDescription("Technical Debt Ratio of new/changed code.")
  1190. .setDomain(DOMAIN_MAINTAINABILITY)
  1191. .setDirection(Metric.DIRECTION_WORST)
  1192. .setOptimizedBestValue(true)
  1193. .setBestValue(0.0)
  1194. .setQualitative(true)
  1195. .create();
  1196. /**
  1197. * @since 5.5
  1198. */
  1199. public static final String EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY = "effort_to_reach_maintainability_rating_a";
  1200. /**
  1201. * @since 5.5
  1202. */
  1203. public static final Metric<Long> EFFORT_TO_REACH_MAINTAINABILITY_RATING_A = new Metric.Builder(EFFORT_TO_REACH_MAINTAINABILITY_RATING_A_KEY,
  1204. "Effort to Reach Maintainability Rating A", Metric.ValueType.WORK_DUR)
  1205. .setDescription("Effort to reach maintainability rating A")
  1206. .setDomain(DOMAIN_MAINTAINABILITY)
  1207. .setDirection(Metric.DIRECTION_WORST)
  1208. .setQualitative(true)
  1209. .setBestValue(0.0)
  1210. .setOptimizedBestValue(true)
  1211. .create();
  1212. // --------------------------------------------------------------------------------------------------------------------
  1213. //
  1214. // RELIABILITY CHARACTERISTIC
  1215. //
  1216. // --------------------------------------------------------------------------------------------------------------------
  1217. /**
  1218. * @since 5.5
  1219. */
  1220. public static final String RELIABILITY_REMEDIATION_EFFORT_KEY = "reliability_remediation_effort";
  1221. /**
  1222. * @since 5.5
  1223. */
  1224. public static final Metric<Long> RELIABILITY_REMEDIATION_EFFORT = new Metric.Builder(RELIABILITY_REMEDIATION_EFFORT_KEY, "Reliability Remediation Effort",
  1225. Metric.ValueType.WORK_DUR)
  1226. .setDescription("Reliability Remediation Effort")
  1227. .setDomain(DOMAIN_RELIABILITY)
  1228. .setDirection(Metric.DIRECTION_WORST)
  1229. .setOptimizedBestValue(true)
  1230. .setBestValue(0.0)
  1231. .setQualitative(true)
  1232. .create();
  1233. /**
  1234. * @since 5.5
  1235. */
  1236. public static final String NEW_RELIABILITY_REMEDIATION_EFFORT_KEY = "new_reliability_remediation_effort";
  1237. /**
  1238. * @since 5.5
  1239. */
  1240. public static final Metric<Long> NEW_RELIABILITY_REMEDIATION_EFFORT = new Metric.Builder(NEW_RELIABILITY_REMEDIATION_EFFORT_KEY, "Reliability Remediation Effort on New Code",
  1241. Metric.ValueType.WORK_DUR)
  1242. .setDescription("Reliability remediation effort on new code")
  1243. .setDomain(DOMAIN_RELIABILITY)
  1244. .setDirection(Metric.DIRECTION_WORST)
  1245. .setOptimizedBestValue(true)
  1246. .setBestValue(0.0)
  1247. .setQualitative(true)
  1248. .setDeleteHistoricalData(true)
  1249. .create();
  1250. /**
  1251. * @since 5.5
  1252. */
  1253. public static final String RELIABILITY_RATING_KEY = "reliability_rating";
  1254. /**
  1255. * @since 5.5
  1256. */
  1257. public static final Metric<Integer> RELIABILITY_RATING = new Metric.Builder(RELIABILITY_RATING_KEY, "Reliability Rating", Metric.ValueType.RATING)
  1258. .setDescription("Reliability rating")
  1259. .setDomain(DOMAIN_RELIABILITY)
  1260. .setDirection(Metric.DIRECTION_WORST)
  1261. .setQualitative(true)
  1262. .setBestValue(1.0)
  1263. .setWorstValue(5.0)
  1264. .create();
  1265. /**
  1266. * @since 6.2
  1267. */
  1268. public static final String NEW_RELIABILITY_RATING_KEY = "new_reliability_rating";
  1269. /**
  1270. * @since 6.2
  1271. */
  1272. public static final Metric<Integer> NEW_RELIABILITY_RATING = new Metric.Builder(NEW_RELIABILITY_RATING_KEY, "Reliability Rating on New Code", Metric.ValueType.RATING)
  1273. .setDescription("Reliability rating on new code")
  1274. .setDomain(DOMAIN_RELIABILITY)
  1275. .setDirection(Metric.DIRECTION_WORST)
  1276. .setDeleteHistoricalData(true)
  1277. .setOptimizedBestValue(true)
  1278. .setQualitative(true)
  1279. .setBestValue(1.0)
  1280. .setWorstValue(5.0)
  1281. .create();
  1282. // --------------------------------------------------------------------------------------------------------------------
  1283. //
  1284. // SECURITY CHARACTERISTIC
  1285. //
  1286. // --------------------------------------------------------------------------------------------------------------------
  1287. /**
  1288. * @since 5.5
  1289. */
  1290. public static final String SECURITY_REMEDIATION_EFFORT_KEY = "security_remediation_effort";
  1291. /**
  1292. * @since 5.5
  1293. */
  1294. public static final Metric<Long> SECURITY_REMEDIATION_EFFORT = new Metric.Builder(SECURITY_REMEDIATION_EFFORT_KEY, "Security Remediation Effort", Metric.ValueType.WORK_DUR)
  1295. .setDescription("Security remediation effort")
  1296. .setDomain(DOMAIN_SECURITY)
  1297. .setDirection(Metric.DIRECTION_WORST)
  1298. .setOptimizedBestValue(true)
  1299. .setBestValue(0.0)
  1300. .setQualitative(true)
  1301. .create();
  1302. /**
  1303. * @since 5.5
  1304. */
  1305. public static final String NEW_SECURITY_REMEDIATION_EFFORT_KEY = "new_security_remediation_effort";
  1306. /**
  1307. * @since 5.5
  1308. */
  1309. public static final Metric<Long> NEW_SECURITY_REMEDIATION_EFFORT = new Metric.Builder(NEW_SECURITY_REMEDIATION_EFFORT_KEY, "Security Remediation Effort on New Code",
  1310. Metric.ValueType.WORK_DUR)
  1311. .setDescription("Security remediation effort on new code")
  1312. .setDomain(DOMAIN_SECURITY)
  1313. .setDirection(Metric.DIRECTION_WORST)
  1314. .setOptimizedBestValue(true)
  1315. .setBestValue(0.0)
  1316. .setQualitative(true)
  1317. .setDeleteHistoricalData(true)
  1318. .create();
  1319. /**
  1320. * @since 5.5
  1321. */
  1322. public static final String SECURITY_RATING_KEY = "security_rating";
  1323. /**
  1324. * @since 5.5
  1325. */
  1326. public static final Metric<Integer> SECURITY_RATING = new Metric.Builder(SECURITY_RATING_KEY, "Security Rating", Metric.ValueType.RATING)
  1327. .setDescription("Security rating")
  1328. .setDomain(DOMAIN_SECURITY)
  1329. .setDirection(Metric.DIRECTION_WORST)
  1330. .setQualitative(true)
  1331. .setBestValue(1.0)
  1332. .setWorstValue(5.0)
  1333. .create();
  1334. /**
  1335. * @since 6.2
  1336. */
  1337. public static final String NEW_SECURITY_RATING_KEY = "new_security_rating";
  1338. /**
  1339. * @since 6.2
  1340. */
  1341. public static final Metric<Integer> NEW_SECURITY_RATING = new Metric.Builder(NEW_SECURITY_RATING_KEY, "Security Rating on New Code", Metric.ValueType.RATING)
  1342. .setDescription("Security rating on new code")
  1343. .setDomain(DOMAIN_SECURITY)
  1344. .setDirection(Metric.DIRECTION_WORST)
  1345. .setDeleteHistoricalData(true)
  1346. .setOptimizedBestValue(true)
  1347. .setQualitative(true)
  1348. .setBestValue(1.0)
  1349. .setWorstValue(5.0)
  1350. .create();
  1351. /**
  1352. * @since 7.8
  1353. */
  1354. public static final String SECURITY_REVIEW_RATING_KEY = "security_review_rating";
  1355. /**
  1356. * @since 7.8
  1357. */
  1358. public static final Metric<Integer> SECURITY_REVIEW_RATING = new Metric.Builder(SECURITY_REVIEW_RATING_KEY, "Security Review Rating", Metric.ValueType.RATING)
  1359. .setDescription("Security Review Rating")
  1360. .setDomain(DOMAIN_SECURITY)
  1361. .setDirection(Metric.DIRECTION_WORST)
  1362. .setQualitative(true)
  1363. .setBestValue(1d)
  1364. .setWorstValue(5d)
  1365. .create();
  1366. // --------------------------------------------------------------------------------------------------------------------
  1367. //
  1368. // FILE DATA
  1369. //
  1370. // --------------------------------------------------------------------------------------------------------------------
  1371. /**
  1372. * @since 2.14
  1373. */
  1374. public static final String NCLOC_DATA_KEY = "ncloc_data";
  1375. /**
  1376. * Information about lines of code in file.
  1377. * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains code (1) or not (0).
  1378. * If a line number is missing in the map it is equivalent to the default value (0).
  1379. *
  1380. * @see org.sonar.api.measures.FileLinesContext
  1381. * @since 2.14
  1382. */
  1383. public static final Metric<String> NCLOC_DATA = new Metric.Builder(NCLOC_DATA_KEY, "ncloc_data", Metric.ValueType.DATA)
  1384. .setHidden(true)
  1385. .setDomain(DOMAIN_SIZE)
  1386. .create();
  1387. /**
  1388. * @since 2.14
  1389. * @deprecated in 7.3. Measures are no longer sent within analysis reports, and by consequence no
  1390. * longer persisted nor available from web API.
  1391. */
  1392. @Deprecated
  1393. public static final String COMMENT_LINES_DATA_KEY = "comment_lines_data";
  1394. /**
  1395. * Information about comments in file.
  1396. * Key-value pairs, where key - is a number of line, and value - is an indicator of whether line contains comment (1) or not (0).
  1397. * If a line number is missing in the map it is equivalent to the default value (0).
  1398. *
  1399. * @see org.sonar.api.measures.FileLinesContext
  1400. * @since 2.14
  1401. * @deprecated in 7.3. Measures are no longer sent within analysis reports, and by consequence no
  1402. * longer persisted nor available from web API.
  1403. */
  1404. @Deprecated
  1405. public static final Metric<String> COMMENT_LINES_DATA = new Metric.Builder(COMMENT_LINES_DATA_KEY, "comment_lines_data", Metric.ValueType.DATA)
  1406. .setHidden(true)
  1407. .setDomain(DOMAIN_SIZE)
  1408. .create();
  1409. /**
  1410. * @since 5.5
  1411. */
  1412. public static final String EXECUTABLE_LINES_DATA_KEY = "executable_lines_data";
  1413. /**
  1414. * Information about executable lines of code in file.
  1415. * 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).
  1416. * If a line number is missing in the map it is equivalent to the default value (0).
  1417. *
  1418. * @see org.sonar.api.measures.FileLinesContext
  1419. * @since 5.5
  1420. */
  1421. public static final Metric<String> EXECUTABLE_LINES_DATA = new Metric.Builder(EXECUTABLE_LINES_DATA_KEY, "executable_lines_data", Metric.ValueType.DATA)
  1422. .setHidden(true)
  1423. .setDomain(DOMAIN_COVERAGE)
  1424. .create();
  1425. // --------------------------------------------------------------------------------------------------------------------
  1426. //
  1427. // OTHERS
  1428. //
  1429. // --------------------------------------------------------------------------------------------------------------------
  1430. public static final String ALERT_STATUS_KEY = "alert_status";
  1431. public static final Metric<Metric.Level> ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, "Quality Gate Status", Metric.ValueType.LEVEL)
  1432. .setDescription("The project status with regard to its quality gate.")
  1433. .setDirection(Metric.DIRECTION_BETTER)
  1434. .setQualitative(true)
  1435. .setDomain(DOMAIN_RELEASABILITY)
  1436. .create();
  1437. /**
  1438. * @since 4.4
  1439. */
  1440. public static final String QUALITY_GATE_DETAILS_KEY = "quality_gate_details";
  1441. /**
  1442. * The project detailed status with regard to its quality gate.
  1443. * Storing the global quality gate status, along with all evaluated conditions, into a JSON object.
  1444. *
  1445. * @since 4.4
  1446. */
  1447. public static final Metric<String> QUALITY_GATE_DETAILS = new Metric.Builder(QUALITY_GATE_DETAILS_KEY, "Quality Gate Details", Metric.ValueType.DATA)
  1448. .setDescription("The project detailed status with regard to its quality gate")
  1449. .setDomain(DOMAIN_GENERAL)
  1450. .create();
  1451. /**
  1452. * @since 4.4
  1453. * @deprecated since 5.5
  1454. */
  1455. @Deprecated
  1456. public static final String QUALITY_PROFILES_KEY = "quality_profiles";
  1457. /**
  1458. * @since 4.4
  1459. * @deprecated since 5.5
  1460. */
  1461. @Deprecated
  1462. public static final Metric<String> QUALITY_PROFILES = new Metric.Builder(QUALITY_PROFILES_KEY, "Profiles", Metric.ValueType.DATA)
  1463. .setDescription("Details of quality profiles used during analysis")
  1464. .setQualitative(false)
  1465. .setDomain(DOMAIN_GENERAL)
  1466. .setHidden(true)
  1467. .create();
  1468. /**
  1469. * @since 5.2
  1470. */
  1471. public static final String LAST_COMMIT_DATE_KEY = "last_commit_date";
  1472. /**
  1473. * Date of the most recent commit. Current implementation is based on commits touching lines of source code. It
  1474. * ignores other changes like file renaming or file deletion.
  1475. *
  1476. * @since 5.2
  1477. */
  1478. public static final Metric LAST_COMMIT_DATE = new Metric.Builder(LAST_COMMIT_DATE_KEY, "Date of Last Commit", Metric.ValueType.MILLISEC)
  1479. .setDomain(CoreMetrics.DOMAIN_SCM)
  1480. // waiting for type "datetime" to be correctly handled
  1481. .setHidden(true)
  1482. .create();
  1483. private static final List<Metric> METRICS;
  1484. static {
  1485. METRICS = new LinkedList<>();
  1486. for (Field field : CoreMetrics.class.getFields()) {
  1487. if (!Modifier.isTransient(field.getModifiers()) && Metric.class.isAssignableFrom(field.getType())) {
  1488. try {
  1489. Metric metric = (Metric) field.get(null);
  1490. METRICS.add(metric);
  1491. } catch (IllegalAccessException e) {
  1492. throw new SonarException("can not introspect " + CoreMetrics.class + " to get metrics", e);
  1493. }
  1494. }
  1495. }
  1496. }
  1497. private CoreMetrics() {
  1498. // only static stuff
  1499. }
  1500. public static List<Metric> getMetrics() {
  1501. return METRICS;
  1502. }
  1503. public static Metric getMetric(final String key) {
  1504. return METRICS.stream().filter(metric -> metric != null && metric.getKey().equals(key)).findFirst().orElseThrow(NoSuchElementException::new);
  1505. }
  1506. }