@repometry/cli 0.0.0-stage → 0.1.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 +77 -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 +534 -0
  15. package/target/main/resources/report/json/repository-summary-v1.schema.json +341 -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 +132 -0
  96. package/target/main/ts/compose/analysis-results.d.ts +46 -0
  97. package/target/main/ts/compose/analysis-results.js +119 -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 +126 -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 +82 -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 +30 -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 +37 -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,86 @@
1
+ import { element } from './viewer-dom.js';
2
+ import { coverageGrade, formatMetric, gradeScope } from './viewer-metrics.js';
3
+ import { groups, trendValue, viewLabel, viewMetric } from './viewer-trend-data.js';
4
+ function gradeLabel(text, grade) {
5
+ const label = element('span', 'trend-reading trend-reading-grade', text);
6
+ label.dataset.grade = grade;
7
+ return label;
8
+ }
9
+ /**
10
+ * What a quality group comes to at the selected commit, as the badges show it: the maintainability grade, and line
11
+ * coverage in its grade's colour, from green at 90% to red below 60%. Other groups carry no total: it would repeat a row.
12
+ */
13
+ const groupReadings = {
14
+ Maintainability: (data, selected) => {
15
+ const grade = data.quality[selected.sha]?.maintainability?.grade;
16
+ return grade ? gradeLabel(grade, grade) : null;
17
+ },
18
+ Coverage: (data, selected) => {
19
+ const ratio = trendValue(data, selected, 'coverage');
20
+ return ratio === null ? null : gradeLabel(formatMetric(ratio, 'coverage'), coverageGrade(ratio));
21
+ },
22
+ };
23
+ /** A series in the list, with its value at the selected commit, in the tabs' counter. */
24
+ function seriesLink(data, selected, view, current, period) {
25
+ const item = element('li');
26
+ const link = element('a', '', viewLabel(view));
27
+ link.href = data.link(selected.sha, view, period);
28
+ // The group's own label carries the signal (the grade, the coverage); a row reads like a summary table.
29
+ const metric = viewMetric(view);
30
+ const reading = metric === null ? null : trendValue(data, selected, metric);
31
+ if (metric !== null && reading !== null)
32
+ link.append(element('span', 'trend-value', formatMetric(reading, metric)));
33
+ if (current)
34
+ link.setAttribute('aria-current', 'page');
35
+ item.append(link);
36
+ return item;
37
+ }
38
+ function groupBlock({ data, selected, current, period }, group, present) {
39
+ const block = element('div', 'trend-group');
40
+ const title = element('h3', '', group);
41
+ const reading = groupReadings[group]?.(data, selected);
42
+ if (reading)
43
+ title.append(reading);
44
+ const list = element('ul');
45
+ list.append(...present.map(view => seriesLink(data, selected, view, view === current, period)));
46
+ const scope = group === 'Maintainability' ? gradeScope(data.quality[selected.sha]) : undefined;
47
+ block.append(title, ...scope ? [element('p', 'trend-group-note', scope)] : [], list);
48
+ return block;
49
+ }
50
+ /** The series list, and a select with the same series for a narrow screen. */
51
+ export function viewNavigation(data, views, current, selected, period) {
52
+ const wrapper = element('aside', 'trend-picker fx-aside');
53
+ const navigation = element('nav', 'trend-nav');
54
+ navigation.setAttribute('aria-label', 'Trend series');
55
+ const select = document.createElement('select');
56
+ for (const [group, members] of groups()) {
57
+ const present = members.filter(view => views.includes(view));
58
+ if (!present.length)
59
+ continue;
60
+ navigation.append(groupBlock({ data, selected, current, period }, group, present));
61
+ const options = document.createElement('optgroup');
62
+ options.label = group;
63
+ options.append(...present.map(view => new Option(viewLabel(view), view, false, view === current)));
64
+ select.append(options);
65
+ }
66
+ select.addEventListener('change', () => { location.hash = data.link(selected.sha, select.value, period); });
67
+ const label = element('label', 'trend-select', 'Series');
68
+ label.append(select);
69
+ wrapper.append(navigation, label);
70
+ return wrapper;
71
+ }
72
+ export function periodControl(data, sha, view, period) {
73
+ // The choices say what they are ("Last 100 inspections"), so the label is for screen readers only.
74
+ const label = element('label', 'trend-period');
75
+ label.append(element('span', 'visually-hidden', 'Period'));
76
+ const select = document.createElement('select');
77
+ const total = data.reports.length;
78
+ for (const option of ['30', '100']) {
79
+ if (Number(option) < total)
80
+ select.append(new Option(`Last ${option} inspections`, option, false, option === period));
81
+ }
82
+ select.append(new Option(`All ${total} inspections`, 'all', false, period === 'all' || Number(period) >= total));
83
+ select.addEventListener('change', () => { location.hash = data.link(sha, view, select.value); });
84
+ label.append(select);
85
+ return label;
86
+ }
@@ -0,0 +1,30 @@
1
+ import type { PublicHistoryEntry } from '../../json/wire/public-history-model.js';
2
+ import type { ChartPoint } from './viewer-chart.js';
3
+ import type { Metric } from './viewer-metrics.js';
4
+ import type { TrendData } from './viewer-trend-data.js';
5
+ /** The inspection just before this one in the whole history, which the change is measured from. */
6
+ export declare function previousOf(data: TrendData, report: PublicHistoryEntry): PublicHistoryEntry | undefined;
7
+ export declare function seriesPoints(data: TrendData, shown: readonly PublicHistoryEntry[], metric: Metric, selected: string, link: (sha: string) => string): ChartPoint[];
8
+ /**
9
+ * Where the green and the red flag stand: the best and the worst value of the series, each at the inspection that
10
+ * first reached it, the way a flag is planted where a summit was reached. Neutral metrics get no flags, and neither
11
+ * does a series with fewer than three measurements or one that reads as unchanged from its best to its worst.
12
+ *
13
+ * The extremes are the raw minimum and maximum, as the line draws them: a tolerant "beats" is not transitive, and a
14
+ * first value within rounding of both ends used to hide them. A value reaches an extreme when it equals it up to
15
+ * floating-point noise, so a flag never stands beside a point the line shows lower or higher.
16
+ */
17
+ export declare function plantFlags(values: readonly (number | null)[], metric: Metric): {
18
+ best: number | null;
19
+ worst: number | null;
20
+ };
21
+ /** Only what the chart cannot say by itself; empty when there is nothing to add. Profile lines are explained while drawn. */
22
+ export declare function trendLegend(points: readonly ChartPoint[], profileLines?: boolean): string;
23
+ /** Remediation time ticks in whole hours once the series reaches two hours. */
24
+ export declare function tickUnit(values: readonly (number | null)[], metric: Metric): number;
25
+ export declare function signedDuration(minutes: number): string;
26
+ /**
27
+ * Remediation time as changes, one bar per inspection. The first shown inspection compares with the one just before
28
+ * the window, when there is one. Flags mark the best and worst total; the bars show changes, so they carry none.
29
+ */
30
+ export declare function debtChanges(data: TrendData, shown: readonly PublicHistoryEntry[], selected: string, link: (sha: string) => string): ChartPoint[];
@@ -0,0 +1,128 @@
1
+ import { betterOf, difference, formatMetric, pluginSpec } from './viewer-metrics.js';
2
+ import { commitTime, trendValue } from './viewer-trend-data.js';
3
+ const dateTime = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' });
4
+ const shortDate = new Intl.DateTimeFormat(undefined, { month: 'short', day: 'numeric' });
5
+ /** When the commit was made, or else when it was inspected. */
6
+ function whenOf(report) {
7
+ const time = commitTime(report);
8
+ if (time !== null)
9
+ return dateTime.format(time);
10
+ const inspectedAt = Date.parse(report.generatedAt);
11
+ return Number.isFinite(inspectedAt) ? `Inspected ${dateTime.format(inspectedAt)}` : 'Date unavailable';
12
+ }
13
+ function pointNotes(report, boundary) {
14
+ const notes = report.status === 'partial' ? ['Partial inspection'] : [];
15
+ if (boundary)
16
+ notes.push(boundary === 'changed' ? 'Inspection profile changed' : 'Profile comparison unavailable');
17
+ return notes;
18
+ }
19
+ function point(report, reading, selected, link) {
20
+ const { value, shown, change, boundary } = reading;
21
+ const time = commitTime(report);
22
+ const at = time ?? Date.parse(report.generatedAt);
23
+ const when = whenOf(report);
24
+ const moved = change && change.direction !== 'same' ? `, ${change.text}` : '';
25
+ return {
26
+ value, time, boundary,
27
+ label: Number.isFinite(at) ? shortDate.format(at) : report.sha.slice(0, 7),
28
+ title: `${report.sha.slice(0, 7)}, ${when}: ${shown}${moved}`,
29
+ tip: { heading: when, commit: report.sha.slice(0, 7), ...(report.subject ? { subject: report.subject } : {}), value: shown, change,
30
+ notes: pointNotes(report, boundary) },
31
+ href: link(report.sha),
32
+ current: report.sha === selected,
33
+ partial: report.status === 'partial',
34
+ };
35
+ }
36
+ /** The inspection just before this one in the whole history, which the change is measured from. */
37
+ export function previousOf(data, report) {
38
+ return data.reports[data.reports.indexOf(report) + 1];
39
+ }
40
+ /** A value's change from the inspection before; none across a profile change or a missing measurement. */
41
+ function readingOf(data, report, metric) {
42
+ const value = trendValue(data, report, metric);
43
+ const previous = previousOf(data, report);
44
+ const before = previous ? trendValue(data, previous, metric) : null;
45
+ const boundary = data.context?.[report.sha]?.boundary ?? null;
46
+ const comparable = boundary !== 'changed' && value !== null && before !== null;
47
+ return { value, boundary, shown: value === null ? 'No measurement' : formatMetric(value, metric),
48
+ change: comparable ? difference(value, before, metric) : null };
49
+ }
50
+ export function seriesPoints(data, shown, metric, selected, link) {
51
+ const points = shown.map(report => point(report, readingOf(data, report, metric), selected, link));
52
+ const { best, worst } = plantFlags(points.map(entry => entry.value), metric);
53
+ return points.map((entry, index) => {
54
+ if (index === best)
55
+ return { ...entry, flag: 'best' };
56
+ return index === worst ? { ...entry, flag: 'worst' } : entry;
57
+ });
58
+ }
59
+ /**
60
+ * Where the green and the red flag stand: the best and the worst value of the series, each at the inspection that
61
+ * first reached it, the way a flag is planted where a summit was reached. Neutral metrics get no flags, and neither
62
+ * does a series with fewer than three measurements or one that reads as unchanged from its best to its worst.
63
+ *
64
+ * The extremes are the raw minimum and maximum, as the line draws them: a tolerant "beats" is not transitive, and a
65
+ * first value within rounding of both ends used to hide them. A value reaches an extreme when it equals it up to
66
+ * floating-point noise, so a flag never stands beside a point the line shows lower or higher.
67
+ */
68
+ export function plantFlags(values, metric) {
69
+ const none = { best: null, worst: null };
70
+ const better = betterOf(metric);
71
+ if (better === 'none')
72
+ return none;
73
+ const measured = values.flatMap((entry, index) => entry === null ? [] : [index]);
74
+ if (measured.length < 3)
75
+ return none;
76
+ const raw = measured.map(index => values[index]);
77
+ const lowest = Math.min(...raw);
78
+ const highest = Math.max(...raw);
79
+ const [bestValue, worstValue] = better === 'lower' ? [lowest, highest] : [highest, lowest];
80
+ if (difference(bestValue, worstValue, metric).direction === 'same')
81
+ return none;
82
+ const reached = (target) => measured.find(index => Math.abs(values[index] - target) <= 1e-9 * Math.max(1, Math.abs(target)));
83
+ const best = reached(bestValue);
84
+ const worst = reached(worstValue);
85
+ return best === worst ? none : { best, worst };
86
+ }
87
+ /** Only what the chart cannot say by itself; empty when there is nothing to add. Profile lines are explained while drawn. */
88
+ export function trendLegend(points, profileLines = true) {
89
+ const parts = [
90
+ points.some(entry => entry.partial && entry.value !== null) ? 'Dashed dots mark partial inspections' : '',
91
+ profileLines && points.some(entry => entry.boundary === 'changed') ? 'Dashed lines mark profile changes' : '',
92
+ profileLines && points.some(entry => entry.boundary === 'unavailable') ? 'Dotted lines mark missing profile information' : '',
93
+ ].filter(Boolean);
94
+ return parts.length ? `${parts.join('. ')}.` : '';
95
+ }
96
+ /** Remediation time ticks in whole hours once the series reaches two hours. */
97
+ export function tickUnit(values, metric) {
98
+ const minutes = metric === 'effort' || pluginSpec(metric)?.descriptor.unit === 'minutes';
99
+ return minutes && values.some(value => Math.abs(value ?? 0) >= 120) ? 60 : 1;
100
+ }
101
+ export function signedDuration(minutes) {
102
+ if (Math.round(minutes) === 0)
103
+ return '0 min';
104
+ return `${minutes > 0 ? '+' : '−'}${formatMetric(Math.abs(minutes), 'effort')}`;
105
+ }
106
+ /** Why an inspection has no change to show: it is the first, the profile changed, or the one before was not measured. */
107
+ function noChange(previous, boundary) {
108
+ if (!previous)
109
+ return 'First inspection';
110
+ return boundary === 'changed' ? 'Profile changed' : 'Not measured before';
111
+ }
112
+ /**
113
+ * Remediation time as changes, one bar per inspection. The first shown inspection compares with the one just before
114
+ * the window, when there is one. Flags mark the best and worst total; the bars show changes, so they carry none.
115
+ */
116
+ export function debtChanges(data, shown, selected, link) {
117
+ return seriesPoints(data, shown, 'effort', selected, link).map((entry, index) => {
118
+ const report = shown[index];
119
+ const previous = previousOf(data, report);
120
+ const before = previous ? trendValue(data, previous, 'effort') : null;
121
+ const change = entry.boundary !== 'changed' && entry.value !== null && before !== null ? entry.value - before : null;
122
+ const total = entry.value === null ? 'No measurement' : `${formatMetric(entry.value, 'effort')} in total`;
123
+ const shownChange = change === null ? noChange(previous, entry.boundary) : signedDuration(change);
124
+ return { ...entry, value: change, flag: undefined,
125
+ title: `${report.sha.slice(0, 7)}, ${entry.tip.heading}: ${shownChange}`,
126
+ tip: { ...entry.tip, value: shownChange, change: null, notes: [total, ...entry.tip.notes] } };
127
+ });
128
+ }
@@ -0,0 +1,32 @@
1
+ import type { PublicHistoryEntry } from '../../json/wire/public-history-model.js';
2
+ import type { Metric } from './viewer-metrics.js';
3
+ import type { TrendData } from './viewer-trend-data.js';
4
+ /** The measure drawn beside a series as a grey line on its own scale: the time behind the ratio, the lines behind the share. */
5
+ export declare const companions: Readonly<Partial<Record<Metric, Metric>>>;
6
+ /** Whether the dashed lines at profile changes are drawn: off until the viewer switches them on, on both tabs. */
7
+ export declare function profileLines(): boolean;
8
+ export interface SeriesOptions {
9
+ readonly compact: boolean;
10
+ readonly height?: number | undefined;
11
+ readonly labelCurrent?: boolean;
12
+ }
13
+ /** Where a series is drawn and what it draws: the chart and its key, the inspections shown, and the selected commit. */
14
+ export interface SeriesView {
15
+ readonly chart: HTMLElement;
16
+ readonly key: HTMLElement;
17
+ /** Where the footnote goes; it follows the key's profile switch. */
18
+ readonly note?: HTMLElement | undefined;
19
+ readonly data: TrendData;
20
+ readonly shown: readonly PublicHistoryEntry[];
21
+ readonly metric: Metric;
22
+ readonly selected: string;
23
+ readonly link: (sha: string) => string;
24
+ }
25
+ /** The key's entry for the dashed lines at profile changes: a dashed swatch, struck through while they are off. */
26
+ export declare function profileSwitch(on: boolean, redraw: () => void): HTMLButtonElement;
27
+ /**
28
+ * A series with its companion, as the Overview draws it: the series in ink on the left scale, the companion in grey on
29
+ * the right, and a key whose entries switch each line on and off. The last line shown cannot be switched off; with one
30
+ * left it takes the left scale. The choice is remembered for this viewer. Returns whether anything was drawn.
31
+ */
32
+ export declare function renderSeries(view: SeriesView, options: SeriesOptions): boolean;
@@ -0,0 +1,128 @@
1
+ import { renderLineChart } from './viewer-chart.js';
2
+ import { element, store, stored } from './viewer-dom.js';
3
+ import { formatMetric, isPercent, labelOf } from './viewer-metrics.js';
4
+ import { trendValue } from './viewer-trend-data.js';
5
+ import { seriesPoints, tickUnit, trendLegend } from './viewer-trend-points.js';
6
+ /** The measure drawn beside a series as a grey line on its own scale: the time behind the ratio, the lines behind the share. */
7
+ export const companions = { debt: 'effort', coverage: 'uncovered-lines' };
8
+ const hiddenKey = 'repometry.hidden-series';
9
+ let hiddenSeries;
10
+ /** The lines switched off in the key, remembered for this viewer. */
11
+ function hidden() {
12
+ if (hiddenSeries)
13
+ return hiddenSeries;
14
+ try {
15
+ hiddenSeries = new Set(JSON.parse(stored(() => localStorage, hiddenKey) ?? '[]'));
16
+ }
17
+ catch {
18
+ hiddenSeries = new Set();
19
+ }
20
+ return hiddenSeries;
21
+ }
22
+ const profileKey = 'repometry.profile-lines';
23
+ /** Whether the dashed lines at profile changes are drawn: off until the viewer switches them on, on both tabs. */
24
+ export function profileLines() {
25
+ return stored(() => localStorage, profileKey) === 'on';
26
+ }
27
+ function remember() {
28
+ store(() => localStorage, hiddenKey, JSON.stringify([...hidden()]));
29
+ }
30
+ /** The card under the pointer names the grey series too. */
31
+ function withCompanion(points, second, pair) {
32
+ return points.map((entry, index) => {
33
+ const value = second[index];
34
+ if (value == null)
35
+ return entry;
36
+ return { ...entry, tip: { ...entry.tip, notes: [`${labelOf(pair)}: ${formatMetric(value, pair)}`, ...entry.tip.notes] } };
37
+ });
38
+ }
39
+ /** One entry of the key: pressed while its line shows; the one line left stays, since a chart of nothing says nothing. */
40
+ function keyItem(series, kind, on, alone, toggle) {
41
+ const item = document.createElement('button');
42
+ item.type = 'button';
43
+ item.className = `trend-key-item trend-key-${kind}`;
44
+ item.textContent = labelOf(series);
45
+ item.setAttribute('aria-pressed', String(on));
46
+ item.disabled = on && alone;
47
+ item.addEventListener('click', toggle);
48
+ return item;
49
+ }
50
+ /** The key's entry for the dashed lines at profile changes: a dashed swatch, struck through while they are off. */
51
+ export function profileSwitch(on, redraw) {
52
+ const item = document.createElement('button');
53
+ item.type = 'button';
54
+ item.className = 'trend-key-item trend-key-profile';
55
+ item.textContent = 'Profile changes';
56
+ // The swatch is the key's own bar, painted as dashes.
57
+ item.style.setProperty('--series', 'repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px)');
58
+ item.setAttribute('aria-pressed', String(on));
59
+ item.addEventListener('click', () => {
60
+ store(() => localStorage, profileKey, on ? 'off' : 'on');
61
+ redraw();
62
+ });
63
+ return item;
64
+ }
65
+ function emptySeries(chart) {
66
+ chart.replaceChildren(element('p', 'detail empty', 'No measurements for this series in the shown inspections.'));
67
+ }
68
+ /**
69
+ * A series with its companion, as the Overview draws it: the series in ink on the left scale, the companion in grey on
70
+ * the right, and a key whose entries switch each line on and off. The last line shown cannot be switched off; with one
71
+ * left it takes the left scale. The choice is remembered for this viewer. Returns whether anything was drawn.
72
+ */
73
+ export function renderSeries(view, options) {
74
+ const { chart, key, note, data, shown, metric, selected, link } = view;
75
+ const pair = companions[metric];
76
+ const second = pair ? shown.map(report => trendValue(data, report, pair)) : [];
77
+ // A companion earns its line only once it can draw one, that is, from two measurements on.
78
+ const paired = pair !== undefined && second.filter(item => item !== null).length >= 2;
79
+ const main = seriesPoints(data, shown, metric, selected, link);
80
+ const hasData = main.some(entry => entry.value !== null) || (paired && second.some(item => item !== null));
81
+ const changes = main.some(entry => entry.boundary);
82
+ function draw() {
83
+ const lines = profileLines();
84
+ const showMain = !paired || !hidden().has(metric);
85
+ const showSecond = paired && !hidden().has(pair);
86
+ const both = showMain && showSecond;
87
+ const lead = showMain ? metric : pair;
88
+ const base = showMain ? main : seriesPoints(data, shown, pair, selected, link);
89
+ const points = both ? withCompanion(base, second, pair) : base;
90
+ chart.classList.toggle('chart-companion-only', !showMain);
91
+ if (points.some(entry => entry.value !== null)) {
92
+ renderLineChart(chart, points, { format: number => formatMetric(number, lead), ratio: isPercent(lead), compact: options.compact,
93
+ height: options.height, tickUnit: tickUnit(points.map(entry => entry.value), lead), labelCurrent: options.labelCurrent ?? true, boundaries: lines,
94
+ secondary: both ? { values: second, format: number => formatMetric(number, pair), tickUnit: tickUnit(second, pair) } : undefined });
95
+ }
96
+ else
97
+ emptySeries(chart);
98
+ if (note) {
99
+ const text = trendLegend(main, lines);
100
+ note.textContent = text;
101
+ note.hidden = text === '';
102
+ }
103
+ key.hidden = !paired && !changes;
104
+ const items = paired ? [[metric, 'main', showMain], [pair, 'second', showSecond]].map(([series, kind, on]) => keyItem(series, kind, on, !both, () => {
105
+ if (on)
106
+ hidden().add(series);
107
+ else
108
+ hidden().delete(series);
109
+ remember();
110
+ draw();
111
+ key.querySelector(`.trend-key-${kind}`)?.focus();
112
+ })) : [];
113
+ if (changes) {
114
+ items.push(profileSwitch(lines, () => {
115
+ draw();
116
+ key.querySelector('.trend-key-profile')?.focus();
117
+ }));
118
+ }
119
+ key.replaceChildren(...items);
120
+ }
121
+ if (hasData)
122
+ draw();
123
+ else {
124
+ chart.replaceChildren();
125
+ key.hidden = true;
126
+ }
127
+ return hasData;
128
+ }
@@ -0,0 +1,5 @@
1
+ import type { PublicHistoryEntry } from '../../json/wire/public-history-model.js';
2
+ import type { Period, TrendData, TrendView } from './viewer-trend-data.js';
3
+ export type { Period, TrendData, TrendView } from './viewer-trend-data.js';
4
+ /** Renders the whole page; returns the slot for the changed-line coverage history when that view is chosen. */
5
+ export declare function renderTrendsPage(container: HTMLElement, data: TrendData, selected: PublicHistoryEntry, requested: TrendView | undefined, requestedPeriod: Period | undefined): HTMLElement | null;
@@ -0,0 +1,89 @@
1
+ import { renderBarChart } from './viewer-chart.js';
2
+ import { element } from './viewer-dom.js';
3
+ import { splitter } from './viewer-layout.js';
4
+ import { definitionOf } from './viewer-metrics.js';
5
+ import { availableViews, charted, defaultPeriod, viewLabel, windowOf } from './viewer-trend-data.js';
6
+ import { periodControl, viewNavigation } from './viewer-trend-nav.js';
7
+ import { debtChanges, signedDuration, tickUnit, trendLegend } from './viewer-trend-points.js';
8
+ import { profileLines, profileSwitch, renderSeries } from './viewer-trend-series.js';
9
+ const definitions = {
10
+ 'debt-changes': 'Change in estimated remediation time from the previous inspection.',
11
+ 'diff-coverage': 'Coverage of added lines in saved pull request reviews, against each review threshold.',
12
+ };
13
+ /** The series the page opens on: the one asked for, else technical debt, else the first this history has. */
14
+ function chosenView(views, requested) {
15
+ if (requested && views.includes(requested))
16
+ return requested;
17
+ return views.includes('debt') ? 'debt' : views[0] ?? 'code-lines';
18
+ }
19
+ /** Remediation time as one bar per inspection's change; returns the legend under the chart. */
20
+ function drawDebtChanges({ data, selected, shown, frame, link }) {
21
+ const bars = debtChanges(data, shown, selected.sha, link);
22
+ const chart = element('div', 'chart');
23
+ const key = element('p', 'trend-key');
24
+ const note = element('p', 'detail legend');
25
+ frame.append(chart, key);
26
+ const changes = bars.some(bar => bar.boundary);
27
+ function draw() {
28
+ const lines = profileLines();
29
+ renderBarChart(chart, bars, { format: signedDuration, compact: data.compact, upIsWorse: true,
30
+ tickUnit: tickUnit(bars.map(bar => bar.value), 'effort'), boundaries: lines });
31
+ const text = trendLegend(bars, lines);
32
+ note.textContent = text;
33
+ note.hidden = text === '';
34
+ key.hidden = !changes;
35
+ key.replaceChildren(...changes ? [profileSwitch(lines, () => {
36
+ draw();
37
+ key.querySelector('.trend-key-profile')?.focus();
38
+ })] : []);
39
+ }
40
+ draw();
41
+ return note;
42
+ }
43
+ /**
44
+ * The same chart as the Overview: the series, its companion in grey, and a key that switches either line. The title
45
+ * repeats the item chosen in the sidebar; the key under the chart names each line. Returns the legend under the chart.
46
+ */
47
+ function drawSeries({ data, selected, shown, view, frame, link }) {
48
+ const chart = element('div', 'chart');
49
+ const key = element('p', 'trend-key');
50
+ const note = element('p', 'detail legend');
51
+ frame.append(chart, key);
52
+ const metric = view;
53
+ if (!renderSeries({ chart, key, note, data, shown, metric, selected: selected.sha, link }, { compact: data.compact })) {
54
+ chart.append(element('p', 'detail empty', 'No measurements for this series in the shown inspections.'));
55
+ }
56
+ return note;
57
+ }
58
+ /** Renders the whole page; returns the slot for the changed-line coverage history when that view is chosen. */
59
+ export function renderTrendsPage(container, data, selected, requested, requestedPeriod) {
60
+ const views = availableViews(data);
61
+ const view = chosenView(views, requested);
62
+ const period = requestedPeriod ?? defaultPeriod(data.reports.length);
63
+ const shown = charted(windowOf(data.reports, selected, period));
64
+ const link = (sha) => data.link(sha, view, period);
65
+ // The chart is the page; the series list is its sidebar, behind the same draggable separator as everywhere.
66
+ const layout = element('div', 'trends-layout fx-split');
67
+ const main = element('div', 'trend-main');
68
+ layout.append(main, splitter(layout), viewNavigation(data, views, view, selected, period));
69
+ const head = element('div', 'trend-head');
70
+ const heading = element('div');
71
+ heading.append(element('h2', 'trend-headline', viewLabel(view)));
72
+ head.append(heading);
73
+ // The title stands above the frame; the frame holds the period, the chart, its key, and what the series means.
74
+ const frame = element('div', 'trend-frame panel');
75
+ const tools = element('div', 'trend-frame-tools');
76
+ tools.append(periodControl(data, selected.sha, view, period));
77
+ frame.append(tools);
78
+ main.append(head, frame);
79
+ const page = { data, selected, shown, view, frame, link };
80
+ const slot = view === 'diff-coverage' ? element('div', 'trend-slot') : null;
81
+ if (slot)
82
+ frame.append(slot);
83
+ const legend = slot ? null : view === 'debt-changes' ? drawDebtChanges(page) : drawSeries(page);
84
+ frame.append(element('p', 'detail', definitions[view] ?? definitionOf(view)));
85
+ if (legend)
86
+ frame.append(legend);
87
+ container.replaceChildren(layout);
88
+ return slot;
89
+ }
@@ -0,0 +1 @@
1
+ export {};