@repometry/cli 0.0.0-dev.0 → 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 -3
  3. package/package.json +65 -2
  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,15 @@
1
+ import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
2
+ import type { Directory, Metrics, Navigation } from './viewer-inspection.js';
3
+ /**
4
+ * The totals of a folder, or of the files a query selected in it, with how the selection reads against its folder. A
5
+ * total some of the files a plugin read do not carry says in how many it was measured.
6
+ */
7
+ export declare function directorySummary(entry: Directory, files: readonly Metrics[], selection?: string): HTMLElement;
8
+ export interface SourceHooks {
9
+ /** Brings a line of the open source into view. */
10
+ readonly reveal?: (line: number) => void;
11
+ /** The loaded source text, which names anonymous functions by their first line. */
12
+ readonly text?: string;
13
+ }
14
+ /** An open file's figures, the links to what it was charged with, and its functions. */
15
+ export declare function fileDetails(details: InspectionDetails, entry: Metrics, navigation: Navigation, hooks?: SourceHooks): HTMLElement;
@@ -0,0 +1,134 @@
1
+ import { basename, count, element, fact, link, parentPath, quantity } from './viewer-dom.js';
2
+ import { coverageContext, coverageRatio, coverageText, duplicationContext, duplicationText, effortText } from './viewer-file-figures.js';
3
+ import { isLockfile, lockfilesLabel } from './viewer-languages.js';
4
+ import { tableColumns } from './viewer-columns.js';
5
+ import { partialNote } from './viewer-totals.js';
6
+ import { coverageKinds, localValue, measured, measuredFileMetrics } from './viewer-inspection.js';
7
+ import { atPath } from './viewer-locations.js';
8
+ import { format } from './viewer-metric-format.js';
9
+ import { labelOf, size } from './viewer-metrics.js';
10
+ import { lineSnippet } from './viewer-source-view.js';
11
+ import { highlighter } from './viewer-tokenizer.js';
12
+ /** A fact where the inspection took the measurement; a measurement it did not take leaves no row behind. */
13
+ function factIf(shown, label, value, context) {
14
+ return shown ? [fact(label, value, context)] : [];
15
+ }
16
+ function panel(label, title, className = 'fx-aside') {
17
+ const aside = element('aside', className);
18
+ aside.setAttribute('aria-label', label);
19
+ const heading = element('div', 'fx-aside-heading');
20
+ heading.append(element('h2', '', title));
21
+ return { panel: aside, heading };
22
+ }
23
+ /**
24
+ * The totals of a folder, or of the files a query selected in it, with how the selection reads against its folder. A
25
+ * total some of the files a plugin read do not carry says in how many it was measured.
26
+ */
27
+ export function directorySummary(entry, files, selection) {
28
+ const { panel: aside, heading } = panel(selection ? 'Selection totals' : 'Folder totals', selection ? 'Selection' : basename(entry.path) || 'All files');
29
+ // The breadcrumbs above name the folder; only a selection needs its words here.
30
+ if (selection)
31
+ heading.append(element('p', 'fx-aside-path fx-aside-selection', selection));
32
+ const facts = element('dl', 'fx-kv');
33
+ const quality = entry.quality;
34
+ const analysed = files.filter(file => file.analysed !== false).length;
35
+ const lockfiles = files.filter(file => isLockfile(file.path)).length;
36
+ const partial = analysed !== entry.files;
37
+ // A total is partial as its table column is: the column says which files carry the measure.
38
+ const presence = new Map(tableColumns().map(column => [column.label, column.present]));
39
+ const note = (label) => presence.get(label) && partialNote(files, presence.get(label));
40
+ facts.append(
41
+ // Every tracked file counts here; Trends counts the analysed ones, so both say which they are.
42
+ fact('Tracked files', count(entry.files)), ...factIf(partial, labelOf('files'), count(analysed)), ...factIf(lockfiles > 0, lockfilesLabel, count(lockfiles)), ...factIf(quality?.codeLines !== undefined, labelOf('code-lines'), count(quality?.codeLines), note(labelOf('code-lines'))),
43
+ // Physical lines are what the language bar weighs once some files are ignored, so its total stands here too.
44
+ ...factIf(quality?.codeLines === undefined || partial, labelOf('lines'), count(entry.lines)), ...factIf(entry.bytes !== undefined, 'Size', size(entry.bytes)), ...factIf(entry.functions !== null, labelOf('functions'), count(entry.functions)), fact(labelOf('complexity'), count(entry.complexity?.maximum), note(labelOf('complexity'))), ...factIf(quality?.cognitiveComplexity !== undefined, labelOf('cognitive'), count(quality?.cognitiveComplexity), note(labelOf('cognitive'))), ...factIf(quality?.duplication !== undefined, labelOf('duplication'), duplicationText(entry), note(labelOf('duplication'))), ...factIf(quality?.maintainability !== undefined, labelOf('effort'), effortText(quality?.maintainability?.effortMinutes), note(labelOf('effort'))), ...factIf(coverageRatio(entry) !== null, labelOf('coverage'), coverageText(entry)),
45
+ // Other plugins' totals follow Repometry's own, where this inspection ran them and they roll up; the counts behind
46
+ // a ratio read through it.
47
+ ...measuredFileMetrics().filter(spec => spec.descriptor.aggregate !== 'none' && !spec.ratioPart)
48
+ .map(spec => fact(spec.short, format(spec, localValue(entry, spec)), note(spec.short))));
49
+ aside.append(heading, facts);
50
+ return aside;
51
+ }
52
+ function fileFacts(details, entry) {
53
+ const facts = element('dl', 'fx-kv');
54
+ const quality = entry.quality;
55
+ const window = details.metrics.churnWindow;
56
+ const kinds = coverageKinds().flatMap(spec => {
57
+ const value = measured(spec.descriptor) ? localValue(entry, spec) : null;
58
+ return value === null ? [] : [fact(spec.short, format(spec, value))];
59
+ });
60
+ facts.append(...factIf(quality?.codeLines !== undefined, labelOf('code-lines'), count(quality?.codeLines)), fact(labelOf('lines'), count(entry.lines)), ...factIf(entry.bytes !== undefined, 'Size', size(entry.bytes)), ...factIf(quality?.commentLines !== undefined, labelOf('comments'), count(quality?.commentLines)), fact(labelOf('functions'), count(entry.functions)), ...factIf(Boolean(quality?.classes), labelOf('classes'), count(quality?.classes)), fact(labelOf('complexity'), count(entry.complexity?.maximum)), ...factIf(quality?.cognitiveComplexity !== undefined, labelOf('cognitive'), count(quality?.cognitiveComplexity)), fact(labelOf('coverage'), coverageText(entry), coverageContext(entry)), ...kinds, ...factIf(Boolean(quality?.duplication), labelOf('duplication'), duplicationText(entry), duplicationContext(entry)), ...factIf(Boolean(quality?.maintainability), labelOf('effort'), effortText(quality?.maintainability?.effortMinutes)), ...factIf(quality?.churn !== undefined, 'Git changes', count(quality?.churn), window ? `${count(window.lookbackDays)}-day window` : undefined));
61
+ return facts;
62
+ }
63
+ /** Links to the file's findings and diagnostics, where it has some. */
64
+ function fileLinks(details, entry, navigation) {
65
+ const findings = details.findings?.filter(item => atPath(item, entry.path)).length ?? 0;
66
+ const links = element('p', 'fx-aside-links');
67
+ if (findings)
68
+ links.append(link(navigation.href('issues', { file: entry.path }), quantity(findings, 'finding'), 'fx-inline-link'));
69
+ if (entry.diagnosticCount)
70
+ links.append(link(navigation.href('diagnostics', { file: entry.path }), quantity(entry.diagnosticCount, 'diagnostic'), 'fx-inline-link'));
71
+ return links.childElementCount ? [links] : [];
72
+ }
73
+ /** The side column has room for the functions, most complex first; a long file folds the rest away. */
74
+ function functionSection(details, path, hooks) {
75
+ const functions = details.functions.filter(record => record.path === path).sort((a, b) => b.complexity - a.complexity);
76
+ if (!functions.length)
77
+ return [];
78
+ const list = (records) => hooks.reveal ? sourceFunctionList(records, hooks.reveal, hooks.text) : functionList(records);
79
+ const section = element('section', 'fx-aside-section');
80
+ section.append(element('h3', '', 'Functions by complexity'), list(functions.slice(0, 10)));
81
+ if (functions.length > 10) {
82
+ const rest = element('details', 'fx-functions');
83
+ rest.append(element('summary', '', `${functions.length - 10} more`), list(functions.slice(10)));
84
+ section.append(rest);
85
+ }
86
+ return [section];
87
+ }
88
+ /** An open file's figures, the links to what it was charged with, and its functions. */
89
+ export function fileDetails(details, entry, navigation, hooks = {}) {
90
+ // The breadcrumbs above name the folder, so the title is the file alone.
91
+ const { panel: aside, heading } = panel('File details', basename(entry.path), 'fx-aside fx-file');
92
+ const close = link(navigation.href('metrics', { directory: parentPath(entry.path) }), '', 'fx-close');
93
+ close.setAttribute('aria-label', 'Close file details');
94
+ close.title = 'Close file details';
95
+ heading.append(close);
96
+ aside.append(heading, fileFacts(details, entry), ...fileLinks(details, entry, navigation), ...functionSection(details, entry.path, hooks));
97
+ return aside;
98
+ }
99
+ /** Functions as buttons that bring their first line into view; an anonymous one is named by that line's code. */
100
+ function sourceFunctionList(functions, reveal, text) {
101
+ const list = element('ol', 'fx-function-list fx-function-jumps');
102
+ list.append(...functions.map(record => {
103
+ const row = element('li');
104
+ const anonymous = record.name === '(anonymous)' && Boolean(text) && record.line !== null;
105
+ const snippet = anonymous ? lineSnippet(text, record.line) : null;
106
+ const button = element('button', 'fx-function-jump');
107
+ button.type = 'button';
108
+ button.disabled = record.line === null;
109
+ const name = element(snippet ? 'code' : 'span', 'fx-function-name');
110
+ if (snippet)
111
+ name.append(...highlighter(record.path)(snippet));
112
+ else
113
+ name.textContent = record.name;
114
+ button.append(name);
115
+ if (record.line !== null)
116
+ button.append(element('span', 'fx-function-line', `${record.line}`));
117
+ button.addEventListener('click', () => { if (record.line !== null)
118
+ reveal(record.line); });
119
+ row.append(button, element('strong', 'fx-function-score', count(record.complexity)));
120
+ return row;
121
+ }));
122
+ return list;
123
+ }
124
+ function functionList(functions) {
125
+ const list = element('ol', 'fx-function-list');
126
+ list.append(...functions.map(record => {
127
+ const row = element('li');
128
+ const subject = element('div');
129
+ subject.append(element('strong', '', record.line === null ? record.name : `${record.name} · line ${record.line}`));
130
+ row.append(subject, element('strong', 'fx-function-score', count(record.complexity)));
131
+ return row;
132
+ }));
133
+ return list;
134
+ }
@@ -0,0 +1,17 @@
1
+ import type { HotspotMetric, Metrics, Navigation } from './viewer-inspection.js';
2
+ /** How a file's or a folder's figures read: ratios as percentages, a dash for what was not measured. */
3
+ export declare function coverageRatio(entry: Metrics): number | null;
4
+ export declare function coverageText(entry: Metrics): string;
5
+ export declare function coverageContext(entry: Metrics): string | undefined;
6
+ export declare function duplicationRatio(entry: Metrics): number | null;
7
+ export declare function duplicationText(entry: Metrics): string;
8
+ export declare function duplicationContext(entry: Metrics): string | undefined;
9
+ /** Remediation time, or a dash where maintainability was not measured. */
10
+ export declare function effortText(minutes: number | null | undefined): string;
11
+ /** What a file scores on the metric the code map and the ranking show; null where it was not measured. */
12
+ export declare function hotspotScore(entry: Metrics, metric: HotspotMetric): number | null;
13
+ /** The top of a ranking's bars: its highest measured score, and 1 where none is above zero. */
14
+ export declare function scorePeak(scores: readonly (number | null)[]): number;
15
+ /** Orders two entries by a column, unmeasured last whichever way the column sorts, and by path between equals. */
16
+ export declare function compareEntries(a: Metrics, b: Metrics, measurement: (row: Metrics) => string | number | null, ascending: boolean): number;
17
+ export declare function fileHref(navigation: Pick<Navigation, 'href'>, file: string): string;
@@ -0,0 +1,65 @@
1
+ import { collator, count, parentPath, percent } from './viewer-dom.js';
2
+ import { localValue } from './viewer-inspection.js';
3
+ import { duration, pluginSpec } from './viewer-metrics.js';
4
+ /** How a file's or a folder's figures read: ratios as percentages, a dash for what was not measured. */
5
+ export function coverageRatio(entry) {
6
+ const coverage = entry.lineCoverage;
7
+ return coverage && coverage.total > 0 ? coverage.covered / coverage.total : null;
8
+ }
9
+ export function coverageText(entry) {
10
+ return ratioText(coverageRatio(entry));
11
+ }
12
+ export function coverageContext(entry) {
13
+ const value = entry.lineCoverage;
14
+ return value && value.total > 0 ? `${count(value.covered)} of ${count(value.total)} lines` : undefined;
15
+ }
16
+ export function duplicationRatio(entry) {
17
+ const value = entry.quality?.duplication;
18
+ return value && value.codeLines > 0 ? value.duplicatedLines / value.codeLines : null;
19
+ }
20
+ export function duplicationText(entry) {
21
+ return ratioText(duplicationRatio(entry));
22
+ }
23
+ export function duplicationContext(entry) {
24
+ const value = entry.quality?.duplication;
25
+ return value && value.codeLines > 0 ? `${count(value.duplicatedLines)} of ${count(value.codeLines)} code lines` : undefined;
26
+ }
27
+ function ratioText(value) {
28
+ return value === null ? '—' : percent(value);
29
+ }
30
+ /** Remediation time, or a dash where maintainability was not measured. */
31
+ export function effortText(minutes) {
32
+ return minutes == null ? '—' : duration(minutes);
33
+ }
34
+ const builtinScores = {
35
+ // A file measured without functions has nothing to score; one with no record was not measured.
36
+ complexity: entry => entry.complexity && (entry.complexity.maximum ?? 0),
37
+ cognitive: entry => entry.quality?.cognitiveComplexity,
38
+ duplication: entry => entry.quality?.duplication?.duplicatedLines,
39
+ churn: entry => entry.quality?.churn,
40
+ missedLines: entry => entry.lineCoverage && entry.lineCoverage.total > 0 ? entry.lineCoverage.total - entry.lineCoverage.covered : null,
41
+ };
42
+ /** What a file scores on the metric the code map and the ranking show; null where it was not measured. */
43
+ export function hotspotScore(entry, metric) {
44
+ const plugin = pluginSpec(metric);
45
+ if (plugin)
46
+ return localValue(entry, plugin);
47
+ // A name that is neither a plugin's nor one of the rankings reads as uncovered lines, the last of them.
48
+ return (builtinScores[metric] ?? builtinScores.missedLines)(entry) ?? null;
49
+ }
50
+ /** The top of a ranking's bars: its highest measured score, and 1 where none is above zero. */
51
+ export function scorePeak(scores) {
52
+ return scores.reduce((max, score) => score === null ? max : Math.max(max, score), 0) || 1;
53
+ }
54
+ /** Orders two entries by a column, unmeasured last whichever way the column sorts, and by path between equals. */
55
+ export function compareEntries(a, b, measurement, ascending) {
56
+ const left = measurement(a);
57
+ const right = measurement(b);
58
+ if (left === null || right === null)
59
+ return Number(left === null) - Number(right === null) || collator.compare(a.path, b.path);
60
+ const difference = typeof left === 'number' && typeof right === 'number' ? left - right : collator.compare(String(left), String(right));
61
+ return (ascending ? difference : -difference) || collator.compare(a.path, b.path);
62
+ }
63
+ export function fileHref(navigation, file) {
64
+ return navigation.href('metrics', { directory: parentPath(file), file });
65
+ }
@@ -0,0 +1,7 @@
1
+ import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
2
+ import type { Metrics, Navigation } from './viewer-inspection.js';
3
+ /**
4
+ * An open file: its source with the inspection laid on its lines, and its figures and functions beside it. The
5
+ * functions lead into the code, and a chosen line goes into the URL so the place can be shared.
6
+ */
7
+ export declare function fileView(details: InspectionDetails, navigation: Navigation, file: Metrics, load: (path: string) => Promise<string | null>): HTMLElement;
@@ -0,0 +1,119 @@
1
+ import { segmented } from './viewer-controls.js';
2
+ import { copyPathButton } from './viewer-copy.js';
3
+ import { basename, count, element, externalLink, parentPath, store, stored } from './viewer-dom.js';
4
+ import { fileDetails } from './viewer-file-aside.js';
5
+ import { languageColor, languageOf } from './viewer-languages.js';
6
+ import { breadcrumbs, splitter } from './viewer-layout.js';
7
+ import { lineIn } from './viewer-locations.js';
8
+ import { isSourceLayer, lineReadings, setSourceLayer } from './viewer-line-coverage.js';
9
+ import { renderSource } from './viewer-source-view.js';
10
+ /** A file's line coverage, where the inspection's coverage report names the file. */
11
+ function fileCoverage(details, path) {
12
+ const coverage = details.lineCoverage;
13
+ return coverage && Object.hasOwn(coverage, path) ? coverage[path] : undefined;
14
+ }
15
+ const layerKey = 'repometry.source-layer';
16
+ /** The URL's choice of what lines show, else the one made earlier in this session, else the findings. */
17
+ function sourceLayer(requested) {
18
+ if (isSourceLayer(requested))
19
+ return requested;
20
+ const remembered = stored(() => sessionStorage, layerKey);
21
+ return isSourceLayer(remembered) ? remembered : 'issues';
22
+ }
23
+ /** The file's name with its full path a click away; a refused clipboard shows the path in the name's place, selected. */
24
+ function sourceName(path) {
25
+ // The folder is in the breadcrumbs right above; the head names the file alone, with its full path on hover.
26
+ const name = element('code', 'fx-source-path', basename(path));
27
+ name.title = path;
28
+ const named = element('span', 'fx-source-name');
29
+ named.append(name, copyPathButton(path, () => {
30
+ name.textContent = path;
31
+ return name;
32
+ }));
33
+ return named;
34
+ }
35
+ function sourceMeta(file) {
36
+ const language = languageOf(file);
37
+ const dot = element('span', 'fx-language-dot');
38
+ dot.style.background = languageColor(language);
39
+ const meta = element('span', 'fx-source-meta');
40
+ meta.append(dot, `${language} · ${count(file.lines)} lines`);
41
+ return meta;
42
+ }
43
+ /** The findings that mark the file's lines, at their place in it. */
44
+ function sourceNotes(details, path) {
45
+ return (details.findings ?? []).flatMap(finding => {
46
+ const line = lineIn(finding, path);
47
+ return line ? [{ line, level: finding.level, title: finding.rule, message: finding.message }] : [];
48
+ });
49
+ }
50
+ /**
51
+ * An open file: its source with the inspection laid on its lines, and its figures and functions beside it. The
52
+ * functions lead into the code, and a chosen line goes into the URL so the place can be shared.
53
+ */
54
+ export function fileView(details, navigation, file, load) {
55
+ const view = element('div', 'fx-view');
56
+ const keep = { query: navigation.query ?? '', group: navigation.group ?? '' };
57
+ const nav = { ...navigation,
58
+ href: (target, options) => target === 'metrics' ? navigation.href('metrics', { ...keep, ...options }) : navigation.href(target, options) };
59
+ view.append(breadcrumbs('metrics', nav, parentPath(file.path)));
60
+ const split = element('div', 'fx-split fx-split-source');
61
+ const main = element('section', 'fx-source panel');
62
+ main.setAttribute('aria-label', 'Source');
63
+ const head = element('div', 'fx-source-head');
64
+ const meta = sourceMeta(file);
65
+ // Lines show the findings, or the tests' coverage where the file has it; without coverage the head stays as it was.
66
+ const coverage = fileCoverage(details, file.path);
67
+ let layer = coverage ? sourceLayer(navigation.layer) : 'issues';
68
+ let line = navigation.line;
69
+ const place = () => nav.href('metrics', { directory: parentPath(file.path), file: file.path, ...line ? { line } : {},
70
+ ...layer === 'coverage' ? { layer } : {} });
71
+ const body = element('div', 'fx-source-body');
72
+ const toggle = coverage ? segmented('Lines show', [['issues', 'Issues'], ['coverage', 'Coverage']], layer, value => {
73
+ layer = value;
74
+ store(() => sessionStorage, layerKey, layer);
75
+ setSourceLayer(body, layer);
76
+ history.replaceState(history.state, '', place());
77
+ }) : null;
78
+ toggle?.classList.add('fx-source-layer');
79
+ const tools = element('div', 'fx-source-tools');
80
+ tools.append(...toggle ? [toggle] : [], meta);
81
+ head.append(sourceName(file.path), tools);
82
+ // The forge's page for the file, at the chosen line, whether or not the text opens here.
83
+ const page = navigation.sourcePage?.(file.path, navigation.line);
84
+ const forge = page ? externalLink(page.href, `View on ${page.provider}`, 'fx-source-forge') : null;
85
+ if (forge)
86
+ meta.append(' · ', forge);
87
+ body.append(element('p', 'fx-note fx-source-wait', 'Loading source…'));
88
+ main.append(head, body);
89
+ let aside = fileDetails(details, file, nav);
90
+ split.append(main, splitter(split), aside);
91
+ view.append(split);
92
+ const functions = details.functions.filter(record => record.path === file.path);
93
+ const choose = (chosen) => {
94
+ line = chosen;
95
+ history.replaceState(history.state, '', place());
96
+ const moved = navigation.sourcePage?.(file.path, chosen);
97
+ if (forge && moved)
98
+ forge.href = moved.href;
99
+ };
100
+ void load(file.path).then(text => {
101
+ if (text === null) {
102
+ // No locator, a private repository, a commit never pushed: one quiet state, and the forge's page when there is one.
103
+ body.replaceChildren(element('p', 'fx-source-missing', 'Source not available'));
104
+ // Nothing to shade: the head is the one a file without coverage has.
105
+ toggle?.remove();
106
+ return;
107
+ }
108
+ const reveal = renderSource(body, text, {
109
+ path: file.path,
110
+ functions: functions.flatMap(record => record.line === null ? [] : [{ line: record.line, complexity: record.complexity, name: record.name }]),
111
+ notes: sourceNotes(details, file.path), line: navigation.line, choose,
112
+ coverage: coverage && lineReadings(coverage), layer,
113
+ });
114
+ const next = fileDetails(details, file, nav, { text, reveal: target => { reveal(target); choose(target); } });
115
+ aside.replaceWith(next);
116
+ aside = next;
117
+ });
118
+ return view;
119
+ }
@@ -0,0 +1,11 @@
1
+ import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
2
+ import type { Navigation, View } from './viewer-inspection.js';
3
+ /**
4
+ * The finding categories Repometry counts as code smells, mirroring core's quality summary (structure and
5
+ * duplication), so the Overview's smell count links to exactly the findings it counts.
6
+ */
7
+ export declare const codeSmellCategories: readonly ['structure', 'duplication'];
8
+ /** The finding categories behind the security level, as the Overview's security column counts them. */
9
+ export declare const securityCategories: readonly ['security', 'dependency', 'secret', 'infrastructure'];
10
+ /** The pages that read one inspection: Metrics (or an open file), Hotspots, Findings and Diagnostics. */
11
+ export declare function renderFileView(container: HTMLElement, view: View, details: InspectionDetails, navigation: Navigation): void;
@@ -0,0 +1,40 @@
1
+ import { diagnosticsView } from './viewer-diagnostics.js';
2
+ import { parentPath } from './viewer-dom.js';
3
+ import { fileView } from './viewer-file-source.js';
4
+ import { hotspotView } from './viewer-hotspots.js';
5
+ import { useDetails } from './viewer-inspection.js';
6
+ import { issuesView } from './viewer-issues.js';
7
+ import { metricsView } from './viewer-metrics-view.js';
8
+ /**
9
+ * The finding categories Repometry counts as code smells, mirroring core's quality summary (structure and
10
+ * duplication), so the Overview's smell count links to exactly the findings it counts.
11
+ */
12
+ export const codeSmellCategories = ['structure', 'duplication'];
13
+ /** The finding categories behind the security level, as the Overview's security column counts them. */
14
+ export const securityCategories = ['security', 'dependency', 'secret', 'infrastructure'];
15
+ const preferences = new WeakMap();
16
+ /** A reader's choices on these pages, kept per container while the viewer stays open. */
17
+ function preferencesOf(container, details) {
18
+ // A small codebase reads best as one flat list; a large one starts from its folders.
19
+ const settings = preferences.get(container) ?? { mode: details.metrics.files.length <= 1000 ? 'list' : 'tree', sort: 0, ascending: true,
20
+ hotspot: 'complexity', columns: new Map(), unanalysed: false };
21
+ preferences.set(container, settings);
22
+ return settings;
23
+ }
24
+ /** The pages that read one inspection: Metrics (or an open file), Hotspots, Findings and Diagnostics. */
25
+ export function renderFileView(container, view, details, navigation) {
26
+ useDetails(details);
27
+ const settings = preferencesOf(container, details);
28
+ const selectedFile = details.metrics.files.find(file => file.path === navigation.file);
29
+ const requested = selectedFile && view === 'metrics' ? parentPath(selectedFile.path) : navigation.directory;
30
+ const directory = details.metrics.directories.find(entry => entry.path === requested)?.path ?? '';
31
+ const pages = {
32
+ metrics: () => selectedFile && navigation.source
33
+ ? fileView(details, navigation, selectedFile, navigation.source)
34
+ : metricsView(details, navigation, settings, directory, selectedFile),
35
+ hotspots: () => hotspotView(details, navigation, settings, directory),
36
+ issues: () => issuesView(details, navigation),
37
+ diagnostics: () => diagnosticsView(details, navigation),
38
+ };
39
+ container.replaceChildren(pages[view]());
40
+ }
@@ -0,0 +1,65 @@
1
+ import type { FileMetricsReport } from '../../json/wire/file-metrics-model.js';
2
+ type FileEntry = FileMetricsReport['files'][number];
3
+ /** A built-in measure, or another plugin's metric by its registry key. */
4
+ export type Measure = string;
5
+ export type Operator = '>' | '>=' | '<' | '<=' | '=';
6
+ export type Clause = {
7
+ readonly kind: 'lang';
8
+ readonly value: string;
9
+ } | {
10
+ readonly kind: 'component';
11
+ readonly value: string;
12
+ } | {
13
+ readonly kind: 'path';
14
+ readonly value: string;
15
+ } | {
16
+ readonly kind: 'measure';
17
+ readonly measure: Measure;
18
+ readonly operator: Operator;
19
+ readonly value: number;
20
+ } | {
21
+ readonly kind: 'has';
22
+ readonly value: 'findings' | 'diagnostics';
23
+ }
24
+ /** Whether a plugin read the file: `ignored:yes` lists what is only counted, lockfiles aside. */
25
+ | {
26
+ readonly kind: 'analysed';
27
+ readonly value: 'yes' | 'no';
28
+ }
29
+ /** Generated dependency lockfiles: `lockfile:yes`. */
30
+ | {
31
+ readonly kind: 'lockfile';
32
+ readonly value: 'yes' | 'no';
33
+ };
34
+ /** What a file brings to the query beyond its metrics: the components it belongs to and its open findings. */
35
+ export interface FileFacts {
36
+ readonly components: ReadonlyMap<string, readonly string[]>;
37
+ readonly findings: ReadonlyMap<string, number>;
38
+ }
39
+ export interface MeasureSpec {
40
+ readonly label: string;
41
+ readonly percent?: boolean;
42
+ readonly minutes?: boolean;
43
+ read(entry: FileEntry): number | null;
44
+ }
45
+ export declare function usePluginMeasures(entries: Iterable<readonly [string, MeasureSpec]>): void;
46
+ /** Other plugins' metrics the query can name, by key. */
47
+ export declare function pluginMeasureList(): readonly (readonly [string, MeasureSpec])[];
48
+ export declare function measureOf(name: string): MeasureSpec | undefined;
49
+ /** Splits the query into clauses; a word that names nothing known becomes a path fragment. */
50
+ export declare function parseQuery(text: string): Clause[];
51
+ export declare function parseWord(word: string): Clause | null;
52
+ export declare function formatQuery(clauses: readonly Clause[]): string;
53
+ export declare function clauseText(clause: Clause): string;
54
+ /** The chip's words: what it selects, in the interface's language rather than the query's. */
55
+ export declare function clauseLabel(clause: Clause): {
56
+ key: string;
57
+ value: string;
58
+ };
59
+ export declare function sameClause(a: Clause, b: Clause): boolean;
60
+ /**
61
+ * Whether a file passes the query. Chips of one kind widen the selection (TypeScript or JavaScript), chips of
62
+ * different kinds narrow it (TypeScript in the core component), and every condition must hold.
63
+ */
64
+ export declare function matches(entry: FileEntry, clauses: readonly Clause[], facts: FileFacts, text?: string): boolean;
65
+ export {};
@@ -0,0 +1,161 @@
1
+ import { isIgnored, isLockfile, languageOf } from './viewer-languages.js';
2
+ import { labelOf } from './viewer-metrics.js';
3
+ function byKind(table, clause) {
4
+ return table[clause.kind](clause);
5
+ }
6
+ function ratio(part, whole) {
7
+ return part !== undefined && whole !== undefined && whole > 0 ? part / whole : null;
8
+ }
9
+ const measures = {
10
+ complexity: { label: labelOf('complexity'), read: entry => entry.complexity?.maximum ?? null },
11
+ cognitive: { label: labelOf('cognitive'), read: entry => entry.quality?.cognitiveComplexity ?? null },
12
+ lines: { label: labelOf('code-lines'), read: entry => entry.quality?.codeLines ?? entry.lines },
13
+ functions: { label: 'Functions', read: entry => entry.functions },
14
+ coverage: { label: labelOf('coverage'), percent: true, read: entry => ratio(entry.lineCoverage?.covered, entry.lineCoverage?.total) },
15
+ duplication: { label: 'Duplication', percent: true,
16
+ read: entry => ratio(entry.quality?.duplication?.duplicatedLines, entry.quality?.duplication?.codeLines) },
17
+ remediation: { label: labelOf('effort'), minutes: true, read: entry => entry.quality?.maintainability?.effortMinutes ?? null },
18
+ changes: { label: 'Git changes', read: entry => entry.quality?.churn ?? null },
19
+ };
20
+ /** Other plugins' metrics, by key, for the inspection on screen. */
21
+ let pluginMeasures = new Map();
22
+ export function usePluginMeasures(entries) {
23
+ pluginMeasures = new Map(entries);
24
+ }
25
+ /** Other plugins' metrics the query can name, by key. */
26
+ export function pluginMeasureList() {
27
+ return [...pluginMeasures];
28
+ }
29
+ export function measureOf(name) {
30
+ return name in measures ? measures[name] : pluginMeasures.get(name);
31
+ }
32
+ /** Splits the query into clauses; a word that names nothing known becomes a path fragment. */
33
+ export function parseQuery(text) {
34
+ const clauses = [];
35
+ for (const match of text.matchAll(/(\w+):"([^"]*)"|(\S+)/g)) {
36
+ const clause = match[1] ? keyed(match[1], match[2]) : parseWord(match[3]);
37
+ if (clause)
38
+ clauses.push(clause);
39
+ }
40
+ return clauses;
41
+ }
42
+ /** A condition's number in the measure's own unit: a ratio for percentages (80 and 80% alike), minutes for hours. */
43
+ function conditionValue(spec, number, unit) {
44
+ if (spec.percent)
45
+ return unit === '%' || number > 1 ? number / 100 : number;
46
+ return unit === 'h' ? number * 60 : number;
47
+ }
48
+ export function parseWord(word) {
49
+ const keyedWord = /^(\w+):(.+)$/.exec(word);
50
+ if (keyedWord)
51
+ return keyed(keyedWord[1], keyedWord[2]);
52
+ const condition = /^([\w.-]+)(>=|<=|>|<|=)(\d+(?:\.\d+)?)(%|h|min)?$/i.exec(word);
53
+ if (!condition)
54
+ return word ? { kind: 'path', value: word } : null;
55
+ const measure = condition[1].toLowerCase();
56
+ const spec = measureOf(measure);
57
+ if (!spec)
58
+ return null;
59
+ return { kind: 'measure', measure, operator: condition[2], value: conditionValue(spec, Number(condition[3]), condition[4]?.toLowerCase()) };
60
+ }
61
+ const yesNo = (value) => value === 'yes' || value === 'no';
62
+ const flag = (kind, read = value => value) => (value) => yesNo(value) ? { kind, value: read(value) } : null;
63
+ const named = (kind) => (value) => ({ kind, value });
64
+ /** The keys a clause is written with. The interface calls the files no plugin read "ignored"; `analysed:` stays a silent alias. */
65
+ const keys = new Map([
66
+ ['lang', named('lang')], ['language', named('lang')],
67
+ ['component', named('component')],
68
+ ['path', named('path')], ['in', named('path')],
69
+ ['has', (value) => value === 'findings' || value === 'diagnostics' ? { kind: 'has', value } : null],
70
+ ['analysed', flag('analysed')], ['analyzed', flag('analysed')],
71
+ ['ignored', flag('analysed', value => value === 'yes' ? 'no' : 'yes')],
72
+ ['lockfile', flag('lockfile')], ['lockfiles', flag('lockfile')],
73
+ ]);
74
+ function keyed(key, value) {
75
+ return keys.get(key.toLowerCase())?.(value) ?? null;
76
+ }
77
+ export function formatQuery(clauses) {
78
+ return clauses.map(clauseText).join(' ');
79
+ }
80
+ const quoted = (value) => /\s|"/.test(value) ? `"${value.replaceAll('"', '')}"` : value;
81
+ /** A measure's bound as written: percentages as percentages, everything else as the number. */
82
+ function boundText(clause) {
83
+ return measureOf(clause.measure)?.percent ? `${Math.round(clause.value * 1000) / 10}%` : String(clause.value);
84
+ }
85
+ /** A path that reads as anything else is written out as one. */
86
+ function pathText(value) {
87
+ return /^\w+:|[<>=]/.test(value) || /\s/.test(value) ? `path:${quoted(value)}` : value;
88
+ }
89
+ const clauseTexts = {
90
+ lang: clause => `lang:${quoted(clause.value)}`,
91
+ component: clause => `component:${quoted(clause.value)}`,
92
+ path: clause => pathText(clause.value),
93
+ has: clause => `has:${clause.value}`,
94
+ analysed: clause => `ignored:${clause.value === 'no' ? 'yes' : 'no'}`,
95
+ lockfile: clause => `lockfile:${clause.value}`,
96
+ measure: clause => `${clause.measure}${clause.operator}${boundText(clause)}`,
97
+ };
98
+ export function clauseText(clause) {
99
+ return byKind(clauseTexts, clause);
100
+ }
101
+ const operatorSigns = { '>': '>', '>=': '≥', '<': '<', '<=': '≤', '=': '=' };
102
+ const yesNoWords = { yes: 'Yes', no: 'No' };
103
+ function measureLabel(clause) {
104
+ const { label, percent, minutes } = measureOf(clause.measure) ?? { label: clause.measure };
105
+ const bound = percent ? `${Math.round(clause.value * 1000) / 10}%` : minutes ? `${clause.value} min` : String(clause.value);
106
+ return { key: label, value: `${operatorSigns[clause.operator]} ${bound}` };
107
+ }
108
+ const clauseLabels = {
109
+ lang: clause => ({ key: 'Language', value: clause.value }),
110
+ component: clause => ({ key: 'Component', value: clause.value }),
111
+ path: clause => ({ key: 'Path', value: clause.value }),
112
+ has: clause => ({ key: 'Has', value: clause.value }),
113
+ analysed: clause => ({ key: 'Ignored', value: clause.value === 'no' ? 'Yes' : 'No' }),
114
+ lockfile: clause => ({ key: 'Lockfile', value: yesNoWords[clause.value] }),
115
+ measure: measureLabel,
116
+ };
117
+ /** The chip's words: what it selects, in the interface's language rather than the query's. */
118
+ export function clauseLabel(clause) {
119
+ return byKind(clauseLabels, clause);
120
+ }
121
+ export function sameClause(a, b) {
122
+ return clauseText(a) === clauseText(b);
123
+ }
124
+ const comparisons = {
125
+ '>': (value, bound) => value > bound,
126
+ '>=': (value, bound) => value >= bound,
127
+ '<': (value, bound) => value < bound,
128
+ '<=': (value, bound) => value <= bound,
129
+ '=': (value, bound) => value === bound,
130
+ };
131
+ const conditions = {
132
+ has: (clause, entry, facts) => clause.value === 'findings' ? (facts.findings.get(entry.path) ?? 0) > 0 : entry.diagnosticCount > 0,
133
+ analysed: (clause, entry) => isIgnored(entry) === (clause.value === 'no'),
134
+ lockfile: (clause, entry) => isLockfile(entry.path) === (clause.value === 'yes'),
135
+ measure: (clause, entry) => {
136
+ const { measure, operator, value: bound } = clause;
137
+ const value = measureOf(measure)?.read(entry) ?? null;
138
+ return value !== null && comparisons[operator](value, bound);
139
+ },
140
+ };
141
+ /** Whether the file passes the chips of one kind: any of them, or no chip of that kind at all. */
142
+ function anyOf(clauses, kind, test) {
143
+ const values = clauses.flatMap(clause => clause.kind === kind ? [clause.value.toLowerCase()] : []);
144
+ return values.length === 0 || values.some(test);
145
+ }
146
+ /**
147
+ * Whether a file passes the query. Chips of one kind widen the selection (TypeScript or JavaScript), chips of
148
+ * different kinds narrow it (TypeScript in the core component), and every condition must hold.
149
+ */
150
+ export function matches(entry, clauses, facts, text = '') {
151
+ const path = entry.path.toLowerCase();
152
+ const language = languageOf(entry).toLowerCase();
153
+ const components = (facts.components.get(entry.path) ?? []).map(name => name.toLowerCase());
154
+ const widened = [
155
+ path.includes(text.toLowerCase()),
156
+ anyOf(clauses, 'lang', value => language === value),
157
+ anyOf(clauses, 'component', value => components.includes(value)),
158
+ anyOf(clauses, 'path', value => path.includes(value)),
159
+ ];
160
+ return widened.every(Boolean) && clauses.every(clause => conditions[clause.kind]?.(clause, entry, facts) ?? true);
161
+ }