@repometry/cli 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (415) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -2
  3. package/package.json +75 -4
  4. package/target/main/resources/language-catalog.json +61 -0
  5. package/target/main/resources/report/json/compact-json-v1.schema.json +24 -0
  6. package/target/main/resources/report/json/comparison-v1.schema.json +65 -0
  7. package/target/main/resources/report/json/config-v2.schema.json +224 -0
  8. package/target/main/resources/report/json/diff-coverage-v1.schema.json +55 -0
  9. package/target/main/resources/report/json/file-metrics-v1.schema.json +157 -0
  10. package/target/main/resources/report/json/metabranch-v1.schema.json +9 -0
  11. package/target/main/resources/report/json/metric-catalog-v1.schema.json +31 -0
  12. package/target/main/resources/report/json/pull-review-v1.schema.json +97 -0
  13. package/target/main/resources/report/json/pull-review-v2.schema.json +100 -0
  14. package/target/main/resources/report/json/report-v2.schema.json +530 -0
  15. package/target/main/resources/report/json/repository-summary-v1.schema.json +337 -0
  16. package/target/main/resources/report/json/viewer-inspection-v1.schema.json +534 -0
  17. package/target/main/resources/viewer/files.css +616 -0
  18. package/target/main/resources/viewer/index.html +120 -0
  19. package/target/main/resources/viewer/projects.html +52 -0
  20. package/target/main/resources/viewer/styles.css +579 -0
  21. package/target/main/resources/viewer/viewer-pulls.css +64 -0
  22. package/target/main/ts/api/cache/root.d.ts +2 -0
  23. package/target/main/ts/api/cache/root.js +21 -0
  24. package/target/main/ts/api/gh/github.d.ts +4 -0
  25. package/target/main/ts/api/gh/github.js +47 -0
  26. package/target/main/ts/api/git/blob-batch.d.ts +10 -0
  27. package/target/main/ts/api/git/blob-batch.js +107 -0
  28. package/target/main/ts/api/git/blob-history.d.ts +20 -0
  29. package/target/main/ts/api/git/blob-history.js +54 -0
  30. package/target/main/ts/api/git/changes.d.ts +27 -0
  31. package/target/main/ts/api/git/changes.js +117 -0
  32. package/target/main/ts/api/git/commit-metadata.d.ts +2 -0
  33. package/target/main/ts/api/git/commit-metadata.js +46 -0
  34. package/target/main/ts/api/git/git-churn.d.ts +9 -0
  35. package/target/main/ts/api/git/git-churn.js +72 -0
  36. package/target/main/ts/api/git/git-executable.d.ts +1 -0
  37. package/target/main/ts/api/git/git-executable.js +31 -0
  38. package/target/main/ts/api/git/git-reader.d.ts +24 -0
  39. package/target/main/ts/api/git/git-reader.js +113 -0
  40. package/target/main/ts/api/git/git.d.ts +47 -0
  41. package/target/main/ts/api/git/git.js +289 -0
  42. package/target/main/ts/api/git/inspection-source.d.ts +17 -0
  43. package/target/main/ts/api/git/inspection-source.js +36 -0
  44. package/target/main/ts/api/git/line-changes.d.ts +6 -0
  45. package/target/main/ts/api/git/line-changes.js +57 -0
  46. package/target/main/ts/api/git/local-sources.d.ts +5 -0
  47. package/target/main/ts/api/git/local-sources.js +48 -0
  48. package/target/main/ts/api/git/local.d.ts +7 -0
  49. package/target/main/ts/api/git/local.js +106 -0
  50. package/target/main/ts/api/git/source-cache.d.ts +1 -0
  51. package/target/main/ts/api/git/source-cache.js +42 -0
  52. package/target/main/ts/api/import/cobertura.d.ts +2 -0
  53. package/target/main/ts/api/import/cobertura.js +160 -0
  54. package/target/main/ts/api/import/coverage-xml.d.ts +7 -0
  55. package/target/main/ts/api/import/coverage-xml.js +135 -0
  56. package/target/main/ts/api/import/finding-import.d.ts +9 -0
  57. package/target/main/ts/api/import/finding-import.js +227 -0
  58. package/target/main/ts/api/import/go-cover.d.ts +13 -0
  59. package/target/main/ts/api/import/go-cover.js +150 -0
  60. package/target/main/ts/api/import/lcov-files.d.ts +12 -0
  61. package/target/main/ts/api/import/lcov-files.js +53 -0
  62. package/target/main/ts/api/import/profile-file.d.ts +4 -0
  63. package/target/main/ts/api/import/profile-file.js +17 -0
  64. package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
  65. package/target/main/ts/api/process/docker-tool-runner.js +92 -0
  66. package/target/main/ts/api/process/failure.d.ts +1 -0
  67. package/target/main/ts/api/process/failure.js +12 -0
  68. package/target/main/ts/api/process/plugin.d.ts +13 -0
  69. package/target/main/ts/api/process/plugin.js +100 -0
  70. package/target/main/ts/api/process/tool-snapshot.d.ts +3 -0
  71. package/target/main/ts/api/process/tool-snapshot.js +26 -0
  72. package/target/main/ts/cli/arguments.d.ts +28 -0
  73. package/target/main/ts/cli/arguments.js +109 -0
  74. package/target/main/ts/cli/config.d.ts +63 -0
  75. package/target/main/ts/cli/config.js +165 -0
  76. package/target/main/ts/cli/imports.d.ts +9 -0
  77. package/target/main/ts/cli/imports.js +37 -0
  78. package/target/main/ts/cli/main.d.ts +2 -0
  79. package/target/main/ts/cli/main.js +4 -0
  80. package/target/main/ts/cli/range-inspection.d.ts +38 -0
  81. package/target/main/ts/cli/range-inspection.js +34 -0
  82. package/target/main/ts/cli/range-jobs.d.ts +23 -0
  83. package/target/main/ts/cli/range-jobs.js +152 -0
  84. package/target/main/ts/cli/range-worker.d.ts +1 -0
  85. package/target/main/ts/cli/range-worker.js +40 -0
  86. package/target/main/ts/cli/reporting.d.ts +42 -0
  87. package/target/main/ts/cli/reporting.js +98 -0
  88. package/target/main/ts/cli/revisions.d.ts +6 -0
  89. package/target/main/ts/cli/revisions.js +16 -0
  90. package/target/main/ts/cli/run.d.ts +2 -0
  91. package/target/main/ts/cli/run.js +306 -0
  92. package/target/main/ts/cli/store.d.ts +13 -0
  93. package/target/main/ts/cli/store.js +39 -0
  94. package/target/main/ts/compose/analysis-report.d.ts +6 -0
  95. package/target/main/ts/compose/analysis-report.js +131 -0
  96. package/target/main/ts/compose/analysis-results.d.ts +42 -0
  97. package/target/main/ts/compose/analysis-results.js +84 -0
  98. package/target/main/ts/compose/analysis-steps.d.ts +23 -0
  99. package/target/main/ts/compose/analysis-steps.js +217 -0
  100. package/target/main/ts/compose/analyze-snapshot.d.ts +7 -0
  101. package/target/main/ts/compose/analyze-snapshot.js +21 -0
  102. package/target/main/ts/compose/attach-churn.d.ts +2 -0
  103. package/target/main/ts/compose/attach-churn.js +50 -0
  104. package/target/main/ts/compose/built-ins.d.ts +6 -0
  105. package/target/main/ts/compose/built-ins.js +12 -0
  106. package/target/main/ts/compose/diff-coverage.d.ts +25 -0
  107. package/target/main/ts/compose/diff-coverage.js +82 -0
  108. package/target/main/ts/compose/distribution.d.ts +17 -0
  109. package/target/main/ts/compose/distribution.js +13 -0
  110. package/target/main/ts/compose/docker-image.d.ts +5 -0
  111. package/target/main/ts/compose/docker-image.js +49 -0
  112. package/target/main/ts/compose/file-selection.d.ts +9 -0
  113. package/target/main/ts/compose/file-selection.js +38 -0
  114. package/target/main/ts/compose/history-cache.d.ts +31 -0
  115. package/target/main/ts/compose/history-cache.js +62 -0
  116. package/target/main/ts/compose/inspect.d.ts +34 -0
  117. package/target/main/ts/compose/inspect.js +51 -0
  118. package/target/main/ts/compose/inspection-coverage.d.ts +9 -0
  119. package/target/main/ts/compose/inspection-coverage.js +9 -0
  120. package/target/main/ts/compose/js-plugin.d.ts +113 -0
  121. package/target/main/ts/compose/js-plugin.js +99 -0
  122. package/target/main/ts/compose/language-discovery.d.ts +12 -0
  123. package/target/main/ts/compose/language-discovery.js +51 -0
  124. package/target/main/ts/compose/languages.d.ts +64 -0
  125. package/target/main/ts/compose/languages.js +98 -0
  126. package/target/main/ts/compose/load-plugins.d.ts +6 -0
  127. package/target/main/ts/compose/load-plugins.js +71 -0
  128. package/target/main/ts/compose/parser-order.d.ts +20 -0
  129. package/target/main/ts/compose/parser-order.js +90 -0
  130. package/target/main/ts/compose/phases.d.ts +140 -0
  131. package/target/main/ts/compose/phases.js +147 -0
  132. package/target/main/ts/compose/plugin-list.d.ts +37 -0
  133. package/target/main/ts/compose/plugin-list.js +30 -0
  134. package/target/main/ts/compose/plugin-manifest.d.ts +14 -0
  135. package/target/main/ts/compose/plugin-manifest.js +50 -0
  136. package/target/main/ts/compose/plugin-options.d.ts +2 -0
  137. package/target/main/ts/compose/plugin-options.js +29 -0
  138. package/target/main/ts/compose/plugin-reference.d.ts +9 -0
  139. package/target/main/ts/compose/plugin-reference.js +40 -0
  140. package/target/main/ts/compose/plugin-requirements.d.ts +5 -0
  141. package/target/main/ts/compose/plugin-requirements.js +83 -0
  142. package/target/main/ts/compose/plugin-scope.d.ts +9 -0
  143. package/target/main/ts/compose/plugin-scope.js +60 -0
  144. package/target/main/ts/compose/process-plugins.d.ts +89 -0
  145. package/target/main/ts/compose/process-plugins.js +74 -0
  146. package/target/main/ts/compose/registered-plugin.d.ts +17 -0
  147. package/target/main/ts/compose/registered-plugin.js +8 -0
  148. package/target/main/ts/compose/review.d.ts +26 -0
  149. package/target/main/ts/compose/review.js +54 -0
  150. package/target/main/ts/compose/schema-error.d.ts +2 -0
  151. package/target/main/ts/compose/schema-error.js +16 -0
  152. package/target/main/ts/compose/sources.d.ts +2 -0
  153. package/target/main/ts/compose/sources.js +32 -0
  154. package/target/main/ts/compose/structure-measures.d.ts +9 -0
  155. package/target/main/ts/compose/structure-measures.js +63 -0
  156. package/target/main/ts/index.d.ts +8 -0
  157. package/target/main/ts/index.js +5 -0
  158. package/target/main/ts/plugin.d.ts +2 -0
  159. package/target/main/ts/plugin.js +2 -0
  160. package/target/main/ts/plugins/built-in.d.ts +3 -0
  161. package/target/main/ts/plugins/built-in.js +19 -0
  162. package/target/main/ts/plugins/coverage/coverage.d.ts +11 -0
  163. package/target/main/ts/plugins/coverage/coverage.js +289 -0
  164. package/target/main/ts/plugins/coverage/diff-coverage.d.ts +3 -0
  165. package/target/main/ts/plugins/coverage/diff-coverage.js +85 -0
  166. package/target/main/ts/plugins/duplication/duplication.d.ts +2 -0
  167. package/target/main/ts/plugins/duplication/duplication.js +95 -0
  168. package/target/main/ts/plugins/language-js/babel-provider.d.ts +10 -0
  169. package/target/main/ts/plugins/language-js/babel-provider.js +54 -0
  170. package/target/main/ts/plugins/language-js/clone-candidates.d.ts +3 -0
  171. package/target/main/ts/plugins/language-js/clone-candidates.js +65 -0
  172. package/target/main/ts/plugins/language-js/code-lines.d.ts +6 -0
  173. package/target/main/ts/plugins/language-js/code-lines.js +36 -0
  174. package/target/main/ts/plugins/language-js/extensions.d.ts +1 -0
  175. package/target/main/ts/plugins/language-js/extensions.js +3 -0
  176. package/target/main/ts/plugins/language-js/function-facts.d.ts +9 -0
  177. package/target/main/ts/plugins/language-js/function-facts.js +74 -0
  178. package/target/main/ts/plugins/language-js/js-security.d.ts +4 -0
  179. package/target/main/ts/plugins/language-js/js-security.js +497 -0
  180. package/target/main/ts/plugins/language-js/qualified-names.d.ts +11 -0
  181. package/target/main/ts/plugins/language-js/qualified-names.js +63 -0
  182. package/target/main/ts/plugins/language-js/structural-observations.d.ts +9 -0
  183. package/target/main/ts/plugins/language-js/structural-observations.js +85 -0
  184. package/target/main/ts/plugins/language-js/syntax.d.ts +2 -0
  185. package/target/main/ts/plugins/language-js/syntax.js +11 -0
  186. package/target/main/ts/plugins/maintainability/maintainability.d.ts +2 -0
  187. package/target/main/ts/plugins/maintainability/maintainability.js +38 -0
  188. package/target/main/ts/plugins/maintainability/structural-smells.d.ts +3 -0
  189. package/target/main/ts/plugins/maintainability/structural-smells.js +17 -0
  190. package/target/main/ts/plugins/security/actions-security.d.ts +2 -0
  191. package/target/main/ts/plugins/security/actions-security.js +581 -0
  192. package/target/main/ts/plugins/security/dockerfile.d.ts +2 -0
  193. package/target/main/ts/plugins/security/dockerfile.js +487 -0
  194. package/target/main/ts/plugins/security/npm-supply-chain.d.ts +4 -0
  195. package/target/main/ts/plugins/security/npm-supply-chain.js +368 -0
  196. package/target/main/ts/plugins/security/secrets.d.ts +12 -0
  197. package/target/main/ts/plugins/security/secrets.js +254 -0
  198. package/target/main/ts/plugins/source/forges.d.ts +4 -0
  199. package/target/main/ts/plugins/source/forges.js +80 -0
  200. package/target/main/ts/plugins/structure/structure.d.ts +2 -0
  201. package/target/main/ts/plugins/structure/structure.js +42 -0
  202. package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +13 -0
  203. package/target/main/ts/report/html/app/viewer-chart-bars.js +59 -0
  204. package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
  205. package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
  206. package/target/main/ts/report/html/app/viewer-chart-line.d.ts +33 -0
  207. package/target/main/ts/report/html/app/viewer-chart-line.js +88 -0
  208. package/target/main/ts/report/html/app/viewer-chart-points.d.ts +52 -0
  209. package/target/main/ts/report/html/app/viewer-chart-points.js +65 -0
  210. package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
  211. package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
  212. package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
  213. package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
  214. package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
  215. package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
  216. package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
  217. package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
  218. package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
  219. package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
  220. package/target/main/ts/report/html/app/viewer-chart.d.ts +7 -0
  221. package/target/main/ts/report/html/app/viewer-chart.js +50 -0
  222. package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
  223. package/target/main/ts/report/html/app/viewer-code-map.js +176 -0
  224. package/target/main/ts/report/html/app/viewer-columns.d.ts +40 -0
  225. package/target/main/ts/report/html/app/viewer-columns.js +97 -0
  226. package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
  227. package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
  228. package/target/main/ts/report/html/app/viewer-commits.d.ts +32 -0
  229. package/target/main/ts/report/html/app/viewer-commits.js +81 -0
  230. package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
  231. package/target/main/ts/report/html/app/viewer-controls.js +141 -0
  232. package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
  233. package/target/main/ts/report/html/app/viewer-copy.js +64 -0
  234. package/target/main/ts/report/html/app/viewer-data.d.ts +24 -0
  235. package/target/main/ts/report/html/app/viewer-data.js +78 -0
  236. package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
  237. package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
  238. package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
  239. package/target/main/ts/report/html/app/viewer-dom.js +99 -0
  240. package/target/main/ts/report/html/app/viewer-file-aside.d.ts +15 -0
  241. package/target/main/ts/report/html/app/viewer-file-aside.js +134 -0
  242. package/target/main/ts/report/html/app/viewer-file-figures.d.ts +17 -0
  243. package/target/main/ts/report/html/app/viewer-file-figures.js +65 -0
  244. package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
  245. package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
  246. package/target/main/ts/report/html/app/viewer-files.d.ts +11 -0
  247. package/target/main/ts/report/html/app/viewer-files.js +40 -0
  248. package/target/main/ts/report/html/app/viewer-filter.d.ts +65 -0
  249. package/target/main/ts/report/html/app/viewer-filter.js +161 -0
  250. package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
  251. package/target/main/ts/report/html/app/viewer-hotspots.js +133 -0
  252. package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
  253. package/target/main/ts/report/html/app/viewer-inspection.js +38 -0
  254. package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
  255. package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
  256. package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
  257. package/target/main/ts/report/html/app/viewer-issues.js +173 -0
  258. package/target/main/ts/report/html/app/viewer-language-bar.d.ts +11 -0
  259. package/target/main/ts/report/html/app/viewer-language-bar.js +76 -0
  260. package/target/main/ts/report/html/app/viewer-languages.d.ts +35 -0
  261. package/target/main/ts/report/html/app/viewer-languages.js +97 -0
  262. package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
  263. package/target/main/ts/report/html/app/viewer-layout.js +134 -0
  264. package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
  265. package/target/main/ts/report/html/app/viewer-line-coverage.js +108 -0
  266. package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
  267. package/target/main/ts/report/html/app/viewer-locations.js +31 -0
  268. package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
  269. package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
  270. package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
  271. package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
  272. package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
  273. package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
  274. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +47 -0
  275. package/target/main/ts/report/html/app/viewer-metric-registry.js +138 -0
  276. package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
  277. package/target/main/ts/report/html/app/viewer-metrics-view.js +159 -0
  278. package/target/main/ts/report/html/app/viewer-metrics.d.ts +51 -0
  279. package/target/main/ts/report/html/app/viewer-metrics.js +195 -0
  280. package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
  281. package/target/main/ts/report/html/app/viewer-overview-cards.js +121 -0
  282. package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
  283. package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
  284. package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
  285. package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
  286. package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
  287. package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
  288. package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
  289. package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
  290. package/target/main/ts/report/html/app/viewer-profile.d.ts +13 -0
  291. package/target/main/ts/report/html/app/viewer-profile.js +180 -0
  292. package/target/main/ts/report/html/app/viewer-projects.d.ts +1 -0
  293. package/target/main/ts/report/html/app/viewer-projects.js +90 -0
  294. package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
  295. package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
  296. package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
  297. package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
  298. package/target/main/ts/report/html/app/viewer-pulls.d.ts +2 -0
  299. package/target/main/ts/report/html/app/viewer-pulls.js +92 -0
  300. package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
  301. package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
  302. package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
  303. package/target/main/ts/report/html/app/viewer-route.js +55 -0
  304. package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
  305. package/target/main/ts/report/html/app/viewer-shell.js +113 -0
  306. package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
  307. package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
  308. package/target/main/ts/report/html/app/viewer-source.d.ts +27 -0
  309. package/target/main/ts/report/html/app/viewer-source.js +57 -0
  310. package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
  311. package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
  312. package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
  313. package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
  314. package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
  315. package/target/main/ts/report/html/app/viewer-table-cells.js +135 -0
  316. package/target/main/ts/report/html/app/viewer-table-rows.d.ts +56 -0
  317. package/target/main/ts/report/html/app/viewer-table-rows.js +97 -0
  318. package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +15 -0
  319. package/target/main/ts/report/html/app/viewer-tokenizer.js +241 -0
  320. package/target/main/ts/report/html/app/viewer-totals.d.ts +20 -0
  321. package/target/main/ts/report/html/app/viewer-totals.js +100 -0
  322. package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
  323. package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
  324. package/target/main/ts/report/html/app/viewer-trend-data.d.ts +54 -0
  325. package/target/main/ts/report/html/app/viewer-trend-data.js +109 -0
  326. package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
  327. package/target/main/ts/report/html/app/viewer-trend-nav.js +86 -0
  328. package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
  329. package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
  330. package/target/main/ts/report/html/app/viewer-trend-series.d.ts +32 -0
  331. package/target/main/ts/report/html/app/viewer-trend-series.js +128 -0
  332. package/target/main/ts/report/html/app/viewer-trends.d.ts +5 -0
  333. package/target/main/ts/report/html/app/viewer-trends.js +89 -0
  334. package/target/main/ts/report/html/app/viewer.d.ts +1 -0
  335. package/target/main/ts/report/html/app/viewer.js +222 -0
  336. package/target/main/ts/report/html/site/badges.d.ts +11 -0
  337. package/target/main/ts/report/html/site/badges.js +72 -0
  338. package/target/main/ts/report/html/site/export-site.d.ts +16 -0
  339. package/target/main/ts/report/html/site/export-site.js +129 -0
  340. package/target/main/ts/report/html/site/exported-server.d.ts +6 -0
  341. package/target/main/ts/report/html/site/exported-server.js +72 -0
  342. package/target/main/ts/report/html/site/local-server.d.ts +7 -0
  343. package/target/main/ts/report/html/site/local-server.js +59 -0
  344. package/target/main/ts/report/html/site/projects.d.ts +1 -0
  345. package/target/main/ts/report/html/site/projects.js +69 -0
  346. package/target/main/ts/report/html/site/server.d.ts +4 -0
  347. package/target/main/ts/report/html/site/server.js +65 -0
  348. package/target/main/ts/report/html/site/source-route.d.ts +6 -0
  349. package/target/main/ts/report/html/site/source-route.js +23 -0
  350. package/target/main/ts/report/json/projections/commit-summary.d.ts +13 -0
  351. package/target/main/ts/report/json/projections/commit-summary.js +125 -0
  352. package/target/main/ts/report/json/projections/components.d.ts +4 -0
  353. package/target/main/ts/report/json/projections/components.js +30 -0
  354. package/target/main/ts/report/json/projections/file-metrics.d.ts +4 -0
  355. package/target/main/ts/report/json/projections/file-metrics.js +260 -0
  356. package/target/main/ts/report/json/projections/ignore-view.d.ts +2 -0
  357. package/target/main/ts/report/json/projections/ignore-view.js +13 -0
  358. package/target/main/ts/report/json/projections/inspection-context.d.ts +5 -0
  359. package/target/main/ts/report/json/projections/inspection-context.js +104 -0
  360. package/target/main/ts/report/json/projections/inspection-details.d.ts +14 -0
  361. package/target/main/ts/report/json/projections/inspection-details.js +98 -0
  362. package/target/main/ts/report/json/projections/metric-values.d.ts +14 -0
  363. package/target/main/ts/report/json/projections/metric-values.js +104 -0
  364. package/target/main/ts/report/json/projections/profile-selectors.d.ts +8 -0
  365. package/target/main/ts/report/json/projections/profile-selectors.js +34 -0
  366. package/target/main/ts/report/json/projections/security-summary.d.ts +11 -0
  367. package/target/main/ts/report/json/projections/security-summary.js +22 -0
  368. package/target/main/ts/report/json/store/directory.d.ts +3 -0
  369. package/target/main/ts/report/json/store/directory.js +19 -0
  370. package/target/main/ts/report/json/store/local-store.d.ts +25 -0
  371. package/target/main/ts/report/json/store/local-store.js +214 -0
  372. package/target/main/ts/report/json/store/object-store.d.ts +14 -0
  373. package/target/main/ts/report/json/store/object-store.js +73 -0
  374. package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
  375. package/target/main/ts/report/json/store/operation-cache.js +32 -0
  376. package/target/main/ts/report/json/store/pull-review-store.d.ts +2 -0
  377. package/target/main/ts/report/json/store/pull-review-store.js +33 -0
  378. package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
  379. package/target/main/ts/report/json/store/replace-file.js +35 -0
  380. package/target/main/ts/report/json/store/report-tree.d.ts +46 -0
  381. package/target/main/ts/report/json/store/report-tree.js +295 -0
  382. package/target/main/ts/report/json/store/store-check.d.ts +32 -0
  383. package/target/main/ts/report/json/store/store-check.js +153 -0
  384. package/target/main/ts/report/json/validation/metabranch.d.ts +4 -0
  385. package/target/main/ts/report/json/validation/metabranch.js +11 -0
  386. package/target/main/ts/report/json/validation/report.d.ts +20 -0
  387. package/target/main/ts/report/json/validation/report.js +77 -0
  388. package/target/main/ts/report/json/validation/summary-validation.d.ts +4 -0
  389. package/target/main/ts/report/json/validation/summary-validation.js +26 -0
  390. package/target/main/ts/report/json/wire/compact-json.d.ts +11 -0
  391. package/target/main/ts/report/json/wire/compact-json.js +76 -0
  392. package/target/main/ts/report/json/wire/component-model.d.ts +9 -0
  393. package/target/main/ts/report/json/wire/component-model.js +1 -0
  394. package/target/main/ts/report/json/wire/domain-types.d.ts +2 -0
  395. package/target/main/ts/report/json/wire/domain-types.js +1 -0
  396. package/target/main/ts/report/json/wire/file-metrics-model.d.ts +81 -0
  397. package/target/main/ts/report/json/wire/file-metrics-model.js +1 -0
  398. package/target/main/ts/report/json/wire/inspection-context-model.d.ts +31 -0
  399. package/target/main/ts/report/json/wire/inspection-context-model.js +1 -0
  400. package/target/main/ts/report/json/wire/inspection-details-model.d.ts +87 -0
  401. package/target/main/ts/report/json/wire/inspection-details-model.js +1 -0
  402. package/target/main/ts/report/json/wire/project-model.d.ts +7 -0
  403. package/target/main/ts/report/json/wire/project-model.js +1 -0
  404. package/target/main/ts/report/json/wire/public-history-model.d.ts +36 -0
  405. package/target/main/ts/report/json/wire/public-history-model.js +5 -0
  406. package/target/main/ts/report/json/wire/pull-review-model.d.ts +54 -0
  407. package/target/main/ts/report/json/wire/pull-review-model.js +3 -0
  408. package/target/main/ts/report/json/wire/summary-model.d.ts +45 -0
  409. package/target/main/ts/report/json/wire/summary-model.js +1 -0
  410. package/target/main/ts/report/markdown/pull-review.d.ts +5 -0
  411. package/target/main/ts/report/markdown/pull-review.js +132 -0
  412. package/target/main/ts/report.d.ts +23 -0
  413. package/target/main/ts/report.js +12 -0
  414. package/target/main/ts/runtime.d.ts +17 -0
  415. package/target/main/ts/runtime.js +30 -0
@@ -0,0 +1,159 @@
1
+ import { columnMenu, tableColumns } from './viewer-columns.js';
2
+ import { navigationButtons, pressSegment, segmented } from './viewer-controls.js';
3
+ import { count, element, inside, scrollableTable } from './viewer-dom.js';
4
+ import { directorySummary, fileDetails } from './viewer-file-aside.js';
5
+ import { formatQuery, matches, parseQuery } from './viewer-filter.js';
6
+ import { pageSize } from './viewer-inspection.js';
7
+ import { renderLanguages } from './viewer-language-bar.js';
8
+ import { breadcrumbs, splitter } from './viewer-layout.js';
9
+ import { findingIndex } from './viewer-locations.js';
10
+ import { labelOf } from './viewer-metrics.js';
11
+ import { queryField } from './viewer-query-field.js';
12
+ import { suggest } from './viewer-suggest.js';
13
+ import { markSort, metricsRow, sortableTable, unreadRow } from './viewer-table-cells.js';
14
+ import { componentRows, entryRange, filteredFolderRows, folderRows, foldUnread, isGroup, listSummary, notInComponent, sortRows } from './viewer-table-rows.js';
15
+ import { aggregate, componentIndex, unreadFolders } from './viewer-totals.js';
16
+ const groupChoices = [['folders', 'Folders'], ['files', 'Files'], ['components', 'Components']];
17
+ function tableNote(columns) {
18
+ const effort = labelOf('effort');
19
+ return 'A dash marks an unavailable measurement. Totals include measured files.'
20
+ + (columns.some(column => column.label === effort) ? ` ${effort} is assigned to each finding’s primary file.` : '');
21
+ }
22
+ function componentHint(hint) {
23
+ hint.hidden = false;
24
+ hint.replaceChildren('No components are defined for this repository. Set the components key in ', element('code', '', 'repometry.config.json'), ' to compare groups of paths here.');
25
+ }
26
+ /** The Metrics page: a query, a grouping and columns over the folder's files, their languages, and the totals beside. */
27
+ export function metricsView(details, navigation, settings, directory, selectedFile) {
28
+ const view = element('div', 'fx-view');
29
+ const { metrics } = details;
30
+ const columns = tableColumns();
31
+ const scopeFiles = metrics.files.filter(entry => inside(entry.path, directory));
32
+ const components = details.components ?? [];
33
+ const facts = { components: componentIndex(components), findings: findingIndex(details.findings ?? []) };
34
+ const state = {
35
+ clauses: parseQuery(navigation.query ?? ''), text: '', page: 0,
36
+ group: isGroup(navigation.group) ? navigation.group : settings.mode === 'tree' ? 'folders' : 'files',
37
+ };
38
+ // Every link out of the view carries the query and the grouping, so a file opened from a selection keeps it.
39
+ const linkTo = (options = {}) => navigation.href('metrics', { ...options, query: formatQuery(state.clauses), group: state.group });
40
+ const trail = element('div');
41
+ view.append(trail);
42
+ const split = element('div', 'fx-split');
43
+ const main = element('div', 'fx-main');
44
+ split.append(main, splitter(split));
45
+ view.append(split);
46
+ const restart = () => {
47
+ state.page = 0;
48
+ remember();
49
+ refresh();
50
+ };
51
+ const field = queryField(state.clauses, {
52
+ suggestions: typed => suggest(typed, scopeFiles, facts, state.clauses),
53
+ change: (next, typed) => {
54
+ state.clauses = next;
55
+ state.text = typed;
56
+ restart();
57
+ },
58
+ });
59
+ const grouping = segmented('Group by', groupChoices, state.group, value => {
60
+ state.group = value;
61
+ settings.mode = state.group === 'folders' ? 'tree' : 'list';
62
+ restart();
63
+ });
64
+ const resort = () => {
65
+ state.page = 0;
66
+ refresh();
67
+ };
68
+ const { menu, isVisible } = columnMenu(columns, settings, { totals: aggregate(directory, scopeFiles), files: scopeFiles }, resort);
69
+ const tools = element('div', 'fx-tools fx-metrics-tools');
70
+ tools.append(field.element, grouping, menu);
71
+ const languages = element('div', 'fx-languages');
72
+ const hint = element('p', 'fx-hint');
73
+ hint.hidden = true;
74
+ const result = element('p', 'fx-note fx-results');
75
+ result.setAttribute('aria-live', 'polite');
76
+ const table = sortableTable(columns, settings, resort);
77
+ const pages = navigationButtons('File pages', () => { state.page--; refresh(); }, () => { state.page++; refresh(); });
78
+ // The count of what the list holds stands with the page buttons, under the table it counts.
79
+ const pager = element('div', 'fx-pager');
80
+ pager.append(result, pages.section);
81
+ const tableWrap = scrollableTable(table.table, 'File and directory metrics');
82
+ const note = element('p', 'fx-note');
83
+ main.append(tools, languages, hint, tableWrap, pager, note);
84
+ let aside = element('aside');
85
+ split.append(aside);
86
+ /** The URL follows the query, without a new history entry per keystroke. */
87
+ function remember() {
88
+ history.replaceState(history.state, '', navigation.href('metrics', {
89
+ directory, ...(selectedFile ? { file: selectedFile.path } : {}), query: formatQuery(state.clauses), group: state.group
90
+ }));
91
+ }
92
+ function selected(...except) {
93
+ const kept = state.clauses.filter(clause => !except.includes(clause.kind));
94
+ return scopeFiles.filter(entry => matches(entry, kept, facts, state.text));
95
+ }
96
+ function groupedRows(files, filtering) {
97
+ hint.hidden = true;
98
+ if (state.group === 'files')
99
+ return files.map(entry => ({ entry, kind: 'file' }));
100
+ if (state.group === 'folders')
101
+ return filtering ? filteredFolderRows(files, directory) : folderRows(metrics.directories, files, directory);
102
+ if (components.length)
103
+ return componentRows(components, files, filtering);
104
+ componentHint(hint);
105
+ return [];
106
+ }
107
+ /** A component's name opens its files as a list, filtered by it. */
108
+ function opener(row) {
109
+ if (row.kind !== 'component' || row.entry.path === notInComponent)
110
+ return undefined;
111
+ return () => {
112
+ state.group = 'files';
113
+ settings.mode = 'list';
114
+ pressSegment(grouping, 'Files');
115
+ field.set([...state.clauses.filter(clause => clause.kind !== 'component'), { kind: 'component', value: row.entry.path }]);
116
+ };
117
+ }
118
+ function toggleFold() {
119
+ settings.unanalysed = !settings.unanalysed;
120
+ refresh();
121
+ }
122
+ /** Only the side panel is swapped: moving the list column would take focus out of the query field. */
123
+ function showAside(files, filtering) {
124
+ const next = selectedFile
125
+ ? fileDetails(details, selectedFile, { ...navigation, href: (target, options) => target === 'metrics' ? linkTo(options) : navigation.href(target, options) })
126
+ : directorySummary(aggregate(directory, files), files, filtering ? `${count(files.length)} of ${count(scopeFiles.length)} files selected` : undefined);
127
+ aside.replaceWith(next);
128
+ aside = next;
129
+ }
130
+ function refresh() {
131
+ const files = selected();
132
+ const filtering = state.clauses.length > 0 || state.text !== '';
133
+ trail.replaceChildren(breadcrumbs('metrics', { href: (_, options) => linkTo(options) }, directory));
134
+ renderLanguages(languages, selected('lang', 'analysed'), state.clauses, next => field.set(next));
135
+ const sort = columns[settings.sort] ?? columns[0];
136
+ const rows = sortRows(groupedRows(files, filtering), settings.sort === 0, sort.value, settings.ascending);
137
+ markSort(table.headers, isVisible, settings);
138
+ table.headers[0].querySelector('button').textContent = state.group === 'components' ? 'Component' : 'Path';
139
+ const keep = state.clauses.some(clause => clause.kind === 'analysed' || clause.kind === 'lockfile');
140
+ const { display, folded } = foldUnread(rows, unreadFolders(scopeFiles), keep, settings.unanalysed);
141
+ const first = state.page * pageSize;
142
+ const visible = display.slice(first, first + pageSize);
143
+ const visibleColumns = columns.slice(1).filter((_, index) => isVisible(index + 1));
144
+ const context = { group: state.group, columns: visibleColumns, linkTo, selected: selectedFile?.path };
145
+ table.body.replaceChildren(...visible.map(row => row.kind === 'unread'
146
+ ? unreadRow(folded, visibleColumns.length + 1, settings.unanalysed, toggleFold) : metricsRow(row, context, opener(row))));
147
+ result.textContent = listSummary(state.group, { rows: rows.length, display: display.length, files: files.length, scope: scopeFiles.length,
148
+ range: entryRange(display, first, visible.length) }, filtering, !hint.hidden);
149
+ tableWrap.hidden = rows.length === 0;
150
+ pager.hidden = !result.textContent;
151
+ pages.section.hidden = display.length <= pageSize;
152
+ pages.update(state.page, Math.ceil(display.length / pageSize));
153
+ note.hidden = rows.length === 0;
154
+ note.textContent = tableNote(visibleColumns);
155
+ showAside(files, filtering);
156
+ }
157
+ refresh();
158
+ return view;
159
+ }
@@ -0,0 +1,51 @@
1
+ import type { InspectionContext } from '../../json/wire/inspection-context-model.js';
2
+ import type { QualitySummary } from '../../json/wire/domain-types.js';
3
+ import type { PublicHistoryEntry } from '../../json/wire/public-history-model.js';
4
+ import type { MetricDescriptor } from '../../json/wire/summary-model.js';
5
+ import * as metricFormat from './viewer-metric-format.js';
6
+ import type { MetricSpec } from './viewer-metric-registry.js';
7
+ export type BuiltinMetric = 'coverage' | 'lines' | 'files' | 'functions' | 'complexity' | 'cognitive' | 'duplication' | 'debt' | 'effort' | 'smells' | 'code-lines' | 'classes' | 'comments' | 'security' | 'coverable-lines' | 'covered-lines' | 'uncovered-lines' | 'security-high' | 'security-medium' | 'security-low';
8
+ /** Another plugin's metric, by the key the registry gives it. */
9
+ export type PluginMetric = string & {
10
+ readonly plugin: unique symbol;
11
+ };
12
+ export type Metric = BuiltinMetric | PluginMetric;
13
+ /** One name per metric, for every page: Trends, the Overview figures, the Metrics and Issues summaries and columns. */
14
+ export declare const metricLabels: Record<BuiltinMetric, string>;
15
+ /**
16
+ * Security is graded like the other areas, by the worst finding's risk: none A, low or unclassified B, medium C,
17
+ * high D, critical F. The letter grades the repository; the words name the risk the findings carry, never a level of
18
+ * security ("high risk" is not "high security").
19
+ */
20
+ export declare const securityGrades: readonly ['A', 'B', 'C', 'D', 'F'];
21
+ export declare const securityRisks: readonly ['No findings', 'Low risk', 'Medium risk', 'High risk', 'Critical risk'];
22
+ /** Line coverage as a letter, coloured as the coverage badge colours it. */
23
+ export declare function coverageGrade(ratio: number): (typeof securityGrades)[number];
24
+ export declare const metricDefinitions: Record<BuiltinMetric, string>;
25
+ export declare function useCatalog(catalog: readonly MetricDescriptor[] | undefined): void;
26
+ /** A detail's own catalog may name metrics the history does not, as when its inspection is newer than the summary. */
27
+ export declare function extendCatalog(catalog: readonly MetricDescriptor[] | undefined): void;
28
+ export declare function pluginMetrics(): readonly MetricSpec[];
29
+ export declare function pluginSpec(metric: string): MetricSpec | undefined;
30
+ export declare function isMetric(value: string | null | undefined): value is Metric;
31
+ export declare function labelOf(metric: Metric): string;
32
+ export declare function definitionOf(metric: Metric): string;
33
+ /** Which way is better: the green and red of changes and the flags on a chart follow it. */
34
+ export declare function betterOf(metric: Metric): 'lower' | 'higher' | 'none';
35
+ /** Where the maintainability grade covers only some files, as in a repository some plugins cannot measure, it says so. */
36
+ export declare function gradeScope(quality: QualitySummary | undefined): string | undefined;
37
+ /** A metric's value at a commit; null where the commit has no such measurement. */
38
+ export declare function metricValue(report: PublicHistoryEntry, metric: Metric, quality: QualitySummary | undefined, context?: InspectionContext): number | null;
39
+ export declare function isPercent(metric: Metric): boolean;
40
+ export declare function formatMetric(value: number, metric: Metric): string;
41
+ /** A size in bytes, in binary units named the way code hosts name them: 512 B, 4.8 KB, 340 KB, 1.2 MB. */
42
+ export declare function size(bytes: number | null | undefined): string;
43
+ export declare function count(value: number | null): string;
44
+ /** Remediation time in hours and minutes: 45 min, 2 h, 3 h 20 min. */
45
+ export declare const duration: typeof metricFormat.duration;
46
+ export type Direction = 'better' | 'worse' | 'same' | 'neutral';
47
+ /** Signed change between two values of one metric, in percentage points for ratios. */
48
+ export declare function difference(value: number, before: number, metric: Metric): {
49
+ text: string;
50
+ direction: Direction;
51
+ };
@@ -0,0 +1,195 @@
1
+ import * as metricFormat from './viewer-metric-format.js';
2
+ import * as registry from './viewer-metric-registry.js';
3
+ /** One name per metric, for every page: Trends, the Overview figures, the Metrics and Issues summaries and columns. */
4
+ export const metricLabels = {
5
+ coverage: 'Line coverage', lines: 'Physical lines', files: 'Analysed files', functions: 'Functions',
6
+ complexity: 'Peak cyclomatic', cognitive: 'Cognitive complexity', duplication: 'Duplication',
7
+ debt: 'Technical debt ratio', effort: 'Remediation time', smells: 'Code smells', 'code-lines': 'Code lines',
8
+ classes: 'Classes', comments: 'Comment lines', security: 'Security findings',
9
+ 'coverable-lines': 'Measured lines', 'covered-lines': 'Covered lines', 'uncovered-lines': 'Uncovered lines',
10
+ 'security-high': 'High severity', 'security-medium': 'Medium severity', 'security-low': 'Low severity',
11
+ };
12
+ /**
13
+ * Security is graded like the other areas, by the worst finding's risk: none A, low or unclassified B, medium C,
14
+ * high D, critical F. The letter grades the repository; the words name the risk the findings carry, never a level of
15
+ * security ("high risk" is not "high security").
16
+ */
17
+ export const securityGrades = ['A', 'B', 'C', 'D', 'F'];
18
+ export const securityRisks = ['No findings', 'Low risk', 'Medium risk', 'High risk', 'Critical risk'];
19
+ /** The lowest line coverage of each grade, in the steps of the coverage badge: A from 90%, F below 60%. */
20
+ const coverageSteps = [[.9, 'A'], [.8, 'B'], [.7, 'C'], [.6, 'D']];
21
+ /** Line coverage as a letter, coloured as the coverage badge colours it. */
22
+ export function coverageGrade(ratio) {
23
+ return coverageSteps.find(([lowest]) => ratio >= lowest)?.[1] ?? 'F';
24
+ }
25
+ export const metricDefinitions = {
26
+ coverage: 'Share of measured lines executed by tests, read from LCOV.',
27
+ lines: 'All lines in inspected source files, including blanks and comments.',
28
+ files: 'Files in the inspection scope that a plugin analysed.',
29
+ functions: 'Functions and methods found in inspected source files.',
30
+ complexity: 'Highest cyclomatic complexity of any single function.',
31
+ cognitive: 'Sum of cognitive complexity over all functions.',
32
+ duplication: 'Share of code lines that belong to duplicated blocks.',
33
+ debt: 'Estimated time to fix all code smells as a share of the estimated time to write the code (basic COCOMO).',
34
+ effort: 'Estimated time to fix all code smells.',
35
+ smells: 'Structural findings counted toward technical debt.',
36
+ 'code-lines': 'Lines of code, excluding blanks and comments.',
37
+ classes: 'Classes found in inspected source files.',
38
+ comments: 'Lines that contain only comments.',
39
+ security: 'Findings from imported security scanners, all severities.',
40
+ 'coverable-lines': 'Lines the coverage report measured.',
41
+ 'covered-lines': 'Measured lines executed by tests.',
42
+ 'uncovered-lines': 'Measured lines no test executed.',
43
+ 'security-high': 'High-severity findings from imported security scanners.',
44
+ 'security-medium': 'Medium-severity findings from imported security scanners.',
45
+ 'security-low': 'Low-severity findings from imported security scanners.',
46
+ };
47
+ /** Metrics where a lower value is better. Coverage is better higher; the rest are neutral. */
48
+ const lowerIsBetter = new Set(['complexity', 'cognitive', 'duplication', 'debt', 'effort', 'smells', 'security',
49
+ 'uncovered-lines', 'security-high', 'security-medium', 'security-low']);
50
+ const integers = new Intl.NumberFormat();
51
+ const percent = new Intl.NumberFormat(undefined, { style: 'percent', maximumFractionDigits: 1 });
52
+ const decimal = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 });
53
+ /**
54
+ * The metrics other plugins declare, from the summary's catalog. Repometry's own metrics keep their typed fields and
55
+ * hand-made surfaces, so a catalog that lists them changes nothing on screen.
56
+ */
57
+ let plugins = [];
58
+ let pluginKeys = new Map();
59
+ let historyIndex = new Map();
60
+ export function useCatalog(catalog) {
61
+ historyIndex = registry.catalogIndex(catalog);
62
+ plugins = registry.metricSpecs(catalog ?? []).filter(spec => !registry.isBuiltin(spec.descriptor));
63
+ pluginKeys = registry.byKey(plugins);
64
+ }
65
+ /** A detail's own catalog may name metrics the history does not, as when its inspection is newer than the summary. */
66
+ export function extendCatalog(catalog) {
67
+ const known = new Set(plugins.map(spec => spec.descriptor.id));
68
+ const added = (catalog ?? []).filter(descriptor => !registry.isBuiltin(descriptor) && !known.has(descriptor.id));
69
+ if (!added.length)
70
+ return;
71
+ plugins = registry.metricSpecs([...plugins.map(spec => spec.descriptor), ...added]);
72
+ pluginKeys = registry.byKey(plugins);
73
+ }
74
+ export function pluginMetrics() {
75
+ return plugins;
76
+ }
77
+ export function pluginSpec(metric) {
78
+ return metric in metricLabels ? undefined : pluginKeys.get(metric);
79
+ }
80
+ export function isMetric(value) {
81
+ return value != null && (value in metricLabels || pluginKeys.has(value));
82
+ }
83
+ export function labelOf(metric) {
84
+ return pluginSpec(metric)?.label ?? metricLabels[metric];
85
+ }
86
+ export function definitionOf(metric) {
87
+ const spec = pluginSpec(metric);
88
+ return spec ? spec.descriptor.description ?? '' : metricDefinitions[metric];
89
+ }
90
+ /** Which way is better: the green and red of changes and the flags on a chart follow it. */
91
+ export function betterOf(metric) {
92
+ const spec = pluginSpec(metric);
93
+ if (spec)
94
+ return spec.descriptor.better;
95
+ return lowerIsBetter.has(metric) ? 'lower' : metric === 'coverage' ? 'higher' : 'none';
96
+ }
97
+ function securityTotal(context) {
98
+ return context?.security ? Object.values(context.security).reduce((total, value) => total + value, 0) : null;
99
+ }
100
+ /** Where each of Repometry's own metrics is read: the history entry, its quality summary, or its scanner context. */
101
+ const readers = {
102
+ coverage: report => report.lineCoverage && report.lineCoverage.total > 0 ? report.lineCoverage.covered / report.lineCoverage.total : null,
103
+ lines: report => report.lines,
104
+ files: report => report.files,
105
+ functions: report => report.functions,
106
+ complexity: report => report.maxComplexity,
107
+ cognitive: (_, quality) => quality?.cognitiveComplexity,
108
+ duplication: (_, quality) => quality?.duplication?.ratio,
109
+ debt: (_, quality) => quality?.maintainability?.debtRatio,
110
+ effort: (_, quality) => quality?.maintainability?.effortMinutes,
111
+ smells: (_, quality) => quality?.maintainability?.smells,
112
+ 'code-lines': (_, quality) => quality?.codeLines,
113
+ classes: (_, quality) => quality?.classes,
114
+ comments: (_, quality) => quality?.comments,
115
+ security: (_, __, context) => securityTotal(context),
116
+ 'coverable-lines': report => report.lineCoverage?.total,
117
+ 'covered-lines': report => report.lineCoverage?.covered,
118
+ 'uncovered-lines': report => report.lineCoverage ? report.lineCoverage.total - report.lineCoverage.covered : null,
119
+ 'security-high': (_, __, context) => context?.security?.high,
120
+ 'security-medium': (_, __, context) => context?.security?.medium,
121
+ 'security-low': (_, __, context) => context?.security?.low,
122
+ };
123
+ /** Where the maintainability grade covers only some files, as in a repository some plugins cannot measure, it says so. */
124
+ export function gradeScope(quality) {
125
+ const scope = quality?.maintainability?.gradeCoverage;
126
+ return scope && scope.measuredFiles < scope.totalFiles ? `Graded on ${count(scope.measuredFiles)} of ${count(scope.totalFiles)} files` : undefined;
127
+ }
128
+ /** A metric's value at a commit; null where the commit has no such measurement. */
129
+ export function metricValue(report, metric, quality, context) {
130
+ const spec = pluginSpec(metric);
131
+ if (spec)
132
+ return registry.commitValue(historyIndex, report, spec);
133
+ return readers[metric]?.(report, quality, context) ?? null;
134
+ }
135
+ export function isPercent(metric) {
136
+ const spec = pluginSpec(metric);
137
+ if (spec)
138
+ return spec.descriptor.unit === 'ratio';
139
+ return metric === 'coverage' || metric === 'duplication' || metric === 'debt';
140
+ }
141
+ export function formatMetric(value, metric) {
142
+ const spec = pluginSpec(metric);
143
+ if (spec)
144
+ return metricFormat.format(spec, value);
145
+ if (isPercent(metric))
146
+ return percent.format(value);
147
+ return metric === 'effort' ? duration(value) : count(value);
148
+ }
149
+ /** A size in bytes, in binary units named the way code hosts name them: 512 B, 4.8 KB, 340 KB, 1.2 MB. */
150
+ export function size(bytes) {
151
+ if (bytes === null || bytes === undefined)
152
+ return '—';
153
+ const units = ['B', 'KB', 'MB', 'GB', 'TB'];
154
+ let value = bytes;
155
+ let unit = 0;
156
+ while (value >= 1024 && unit < units.length - 1) {
157
+ value /= 1024;
158
+ unit++;
159
+ }
160
+ // Below ten of a unit one decimal tells sizes apart; above it, whole units read faster.
161
+ const shown = unit === 0 ? Math.round(value) : value < 10 ? Math.round(value * 10) / 10 : Math.round(value);
162
+ if (shown >= 1024 && unit < units.length - 1)
163
+ return `1 ${units[unit + 1]}`;
164
+ return `${shown.toLocaleString(undefined, { maximumFractionDigits: 1 })} ${units[unit]}`;
165
+ }
166
+ export function count(value) {
167
+ return value === null ? '—' : integers.format(value);
168
+ }
169
+ /** Remediation time in hours and minutes: 45 min, 2 h, 3 h 20 min. */
170
+ export const duration = metricFormat.duration;
171
+ /** Signed change between two values of one metric, in percentage points for ratios. */
172
+ export function difference(value, before, metric) {
173
+ const spec = pluginSpec(metric);
174
+ if (spec)
175
+ return metricFormat.difference(spec, value, before);
176
+ const percentPoints = isPercent(metric);
177
+ const raw = percentPoints ? (value - before) * 100 : value - before;
178
+ const rounded = percentPoints ? Math.round(raw * 10) / 10 : Math.round(raw);
179
+ if (rounded === 0)
180
+ return { text: 'No change', direction: 'same' };
181
+ return { text: `${rounded > 0 ? '+' : '−'}${magnitudeText(metric, Math.abs(rounded), percentPoints)}`, direction: changeDirection(metric, rounded) };
182
+ }
183
+ function magnitudeText(metric, magnitude, percentPoints) {
184
+ if (percentPoints)
185
+ return `${decimal.format(magnitude)} pp`;
186
+ return metric === 'effort' ? duration(magnitude) : count(magnitude);
187
+ }
188
+ /** Whether a change is good news: down for what is better lower, up for coverage; other metrics are neutral. */
189
+ function changeDirection(metric, change) {
190
+ if (lowerIsBetter.has(metric))
191
+ return change < 0 ? 'better' : 'worse';
192
+ if (metric !== 'coverage')
193
+ return 'neutral';
194
+ return change > 0 ? 'better' : 'worse';
195
+ }
@@ -0,0 +1,12 @@
1
+ import type { InspectionContext } from '../../json/wire/inspection-context-model.js';
2
+ import type { QualitySummary } from '../../json/wire/domain-types.js';
3
+ import type { PublicHistoryEntry } from '../../json/wire/public-history-model.js';
4
+ /** A detail that counts something leads to exactly what it counts, where the report has a page for it. */
5
+ export declare function detailText(id: string, text: string, link?: string): void;
6
+ /** Where each Overview figure leads: the findings it counts, the files it ranks, the function it names. */
7
+ export declare function smellsLink(sha: string): string;
8
+ export declare function securityLink(sha: string, level?: string): string;
9
+ export declare function uncoveredLink(sha: string): string;
10
+ export declare function renderInspection(report: PublicHistoryEntry): void;
11
+ export declare function renderQuality(report: PublicHistoryEntry, quality: QualitySummary | undefined): void;
12
+ export declare function renderScannerContext(context: InspectionContext | undefined, sha: string): void;
@@ -0,0 +1,121 @@
1
+ import { byId, count, percent, quantity } from './viewer-dom.js';
2
+ import { codeSmellCategories, securityCategories } from './viewer-files.js';
3
+ import { coverageGrade, formatMetric, gradeScope, metricValue, pluginSpec, securityGrades, securityRisks } from './viewer-metrics.js';
4
+ import { href } from './viewer-route.js';
5
+ /** Coverage kinds beyond lines, by their registry keys, in the words the Overview card uses for them. */
6
+ const coverageKinds = [['branch-coverage', 'Branches'], ['function-coverage', 'Functions']];
7
+ /** A detail that counts something leads to exactly what it counts, where the report has a page for it. */
8
+ export function detailText(id, text, link) {
9
+ if (link === undefined) {
10
+ byId(id).textContent = text;
11
+ return;
12
+ }
13
+ const anchor = document.createElement('a');
14
+ anchor.href = link;
15
+ anchor.textContent = text;
16
+ byId(id).replaceChildren(anchor);
17
+ }
18
+ /** Where each Overview figure leads: the findings it counts, the files it ranks, the function it names. */
19
+ export function smellsLink(sha) {
20
+ return href({ page: 'issues', sha, category: codeSmellCategories.join(',') });
21
+ }
22
+ export function securityLink(sha, level) {
23
+ return href({ page: 'issues', sha, category: securityCategories.join(','), ...level ? { level } : {} });
24
+ }
25
+ export function uncoveredLink(sha) {
26
+ return href({ page: 'hotspots', sha, rank: 'missedLines' });
27
+ }
28
+ /** A small progress ring for a ratio; an empty ring when there is no value. */
29
+ function ring(ratio) {
30
+ const namespace = 'http://www.w3.org/2000/svg';
31
+ const svg = document.createElementNS(namespace, 'svg');
32
+ svg.setAttribute('viewBox', '0 0 40 40');
33
+ const track = document.createElementNS(namespace, 'circle');
34
+ const arc = document.createElementNS(namespace, 'circle');
35
+ for (const circle of [track, arc]) {
36
+ circle.setAttribute('cx', '20');
37
+ circle.setAttribute('cy', '20');
38
+ circle.setAttribute('r', '16');
39
+ }
40
+ track.setAttribute('class', 'ring-track');
41
+ arc.setAttribute('class', 'ring-arc');
42
+ const length = 2 * Math.PI * 16;
43
+ arc.setAttribute('stroke-dasharray', `${(ratio ?? 0) * length} ${length}`);
44
+ // Flat ends keep the gap true to the value: a round cap would close 95.9% into a full circle and turn
45
+ // a zero into a dot. An unknown or zero ratio shows the track alone.
46
+ svg.append(...(ratio !== null && ratio > 0 ? [track, arc] : [track]));
47
+ return svg;
48
+ }
49
+ /** Line coverage leads; the other kinds the coverage report carries follow on a quieter line. */
50
+ function renderCoverageKinds(report) {
51
+ const kinds = coverageKinds.flatMap(([key, name]) => {
52
+ const metric = key;
53
+ const value = pluginSpec(metric) ? metricValue(report, metric, undefined) : null;
54
+ if (value === null)
55
+ return [];
56
+ // Each kind keeps its number; a narrow card wraps between kinds, never inside one.
57
+ const kind = document.createElement('span');
58
+ kind.textContent = `${name} ${formatMetric(value, metric)}`;
59
+ return [kind];
60
+ });
61
+ byId('coverage-kinds').replaceChildren(...kinds.flatMap((kind, index) => index ? [' · ', kind] : [kind]));
62
+ byId('coverage-kinds').hidden = kinds.length === 0;
63
+ }
64
+ export function renderInspection(report) {
65
+ const lines = report.lineCoverage;
66
+ const coverage = lines && lines.total > 0 ? lines.covered / lines.total : null;
67
+ if (coverage === null)
68
+ detailText('coverage-detail', 'No coverage report');
69
+ else
70
+ detailText('coverage-detail', `${percent(coverage)} of ${count(lines.total)} lines`, coverage < 1 ? uncoveredLink(report.sha) : undefined);
71
+ const mark = byId('coverage-mark');
72
+ mark.replaceChildren(ring(coverage));
73
+ // The ring is coloured by the grade the coverage badge gives it.
74
+ if (coverage === null)
75
+ delete mark.dataset.grade;
76
+ else
77
+ mark.dataset.grade = coverageGrade(coverage);
78
+ renderCoverageKinds(report);
79
+ }
80
+ export function renderQuality(report, quality) {
81
+ const maintainability = quality?.maintainability ?? null;
82
+ const grade = byId('maintainability');
83
+ grade.textContent = maintainability?.grade ?? '–';
84
+ grade.dataset.grade = maintainability?.grade ?? 'none';
85
+ if (!maintainability)
86
+ detailText('maintainability-detail', 'Not measured');
87
+ else
88
+ detailText('maintainability-detail', quantity(maintainability.smells, 'code smell'), maintainability.smells > 0 ? smellsLink(report.sha) : undefined);
89
+ const scope = byId('maintainability-scope');
90
+ scope.textContent = gradeScope(quality) ?? '';
91
+ scope.hidden = !scope.textContent;
92
+ }
93
+ /** The words of the five steps, as every grade has them: clear A, low B, medium C, high D, critical F. */
94
+ const severities = ['clear', 'low', 'medium', 'high', 'critical'];
95
+ /** A grade like maintainability's, by the worst finding: 4 critical, 3 high, 2 medium, 1 anything else, 0 none. */
96
+ function securityStep(security) {
97
+ const worst = [security.critical ?? 0, security.high, security.medium].findIndex(amount => amount > 0);
98
+ if (worst >= 0)
99
+ return 4 - worst;
100
+ return security.low + security.unknown > 0 ? 1 : 0;
101
+ }
102
+ function securityText(security) {
103
+ if (!security)
104
+ return { text: 'No scanner report', counted: false };
105
+ const levels = [['critical', security.critical ?? 0], ['high', security.high], ['medium', security.medium], ['low', security.low],
106
+ ['unclassified', security.unknown]].filter(([, amount]) => amount > 0);
107
+ if (levels.length === 0)
108
+ return { text: 'No findings', counted: false };
109
+ return { text: levels.map(([name, amount]) => `${count(amount)} ${name}`).join(' · '), counted: true };
110
+ }
111
+ export function renderScannerContext(context, sha) {
112
+ const security = context?.security;
113
+ const mark = byId('security-mark');
114
+ const step = security ? securityStep(security) : null;
115
+ mark.textContent = step === null ? '–' : securityGrades[step];
116
+ mark.title = step === null ? '' : `Security ${securityGrades[step]}: ${securityRisks[step].toLowerCase()}`;
117
+ mark.dataset.severity = step === null ? 'none' : severities[step];
118
+ // The mark carries the level; the text gives the counts by severity.
119
+ const { text, counted } = securityText(security);
120
+ detailText('security-detail', text, counted ? securityLink(sha) : undefined);
121
+ }
@@ -0,0 +1,9 @@
1
+ import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
2
+ import type { BuiltinMetric } from './viewer-metrics.js';
3
+ /** The Overview's hotspot column for the selected quality area: the compact map and the top five files. */
4
+ export declare function renderOverviewHotspots(details: InspectionDetails, sha: string, area: BuiltinMetric, scanned: boolean): void;
5
+ /**
6
+ * The hotspot column while the inspection loads. A map and ranking already on screen stay, dimmed, until the next ones
7
+ * replace them; on a first visit placeholders of the same size hold the column, so nothing beside it moves.
8
+ */
9
+ export declare function overviewStub(sha: string): void;