repometry 0.4.2 → 0.6.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 (269) hide show
  1. package/README.md +36 -14
  2. package/package.json +1 -1
  3. package/target/main/resources/report/json/comparison-v1.schema.json +6 -6
  4. package/target/main/resources/report/json/file-metrics-v1.schema.json +7 -6
  5. package/target/main/resources/report/json/pull-review-v1.schema.json +5 -5
  6. package/target/main/resources/report/json/report-v2.schema.json +210 -11
  7. package/target/main/resources/report/json/repository-summary-v1.schema.json +161 -14
  8. package/target/main/resources/report/json/viewer-inspection-v1.schema.json +518 -6
  9. package/target/main/resources/viewer/styles.css +7 -2
  10. package/target/main/ts/api/git/changes.d.ts +1 -1
  11. package/target/main/ts/api/git/changes.js +3 -3
  12. package/target/main/ts/api/git/commit-metadata.js +6 -4
  13. package/target/main/ts/api/git/git.d.ts +2 -1
  14. package/target/main/ts/api/git/git.js +16 -4
  15. package/target/main/ts/api/git/inspection-source.d.ts +1 -1
  16. package/target/main/ts/api/git/inspection-source.js +4 -10
  17. package/target/main/ts/api/git/local.d.ts +1 -1
  18. package/target/main/ts/api/git/local.js +41 -7
  19. package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
  20. package/target/main/ts/api/process/docker-tool-runner.js +108 -0
  21. package/target/main/ts/api/process/failure.d.ts +1 -0
  22. package/target/main/ts/api/process/failure.js +12 -0
  23. package/target/main/ts/api/process/plugin.d.ts +10 -0
  24. package/target/main/ts/api/process/plugin.js +96 -0
  25. package/target/main/ts/api/worker/remote-executor.d.ts +1 -1
  26. package/target/main/ts/api/worker/remote-executor.js +2 -2
  27. package/target/main/ts/api/worker/worker-protocol.d.ts +2 -2
  28. package/target/main/ts/api/worker/worker-protocol.js +8 -8
  29. package/target/main/ts/api/worker/worker.d.ts +1 -1
  30. package/target/main/ts/api/worker/worker.js +4 -4
  31. package/target/main/ts/cli/main.js +4 -3
  32. package/target/main/ts/cli/reporting.d.ts +1 -1
  33. package/target/main/ts/cli/reporting.js +1 -1
  34. package/target/main/ts/compose/analysis-files.d.ts +13 -0
  35. package/target/main/ts/compose/analysis-files.js +95 -0
  36. package/target/main/ts/compose/analysis-imports.d.ts +7 -0
  37. package/target/main/ts/compose/analysis-imports.js +34 -0
  38. package/target/main/ts/compose/analysis-report.d.ts +5 -0
  39. package/target/main/ts/compose/analysis-report.js +78 -0
  40. package/target/main/ts/compose/analysis-repository.d.ts +6 -0
  41. package/target/main/ts/compose/analysis-repository.js +61 -0
  42. package/target/main/ts/compose/analysis-results.d.ts +38 -0
  43. package/target/main/ts/compose/analysis-results.js +78 -0
  44. package/target/main/ts/compose/analysis-sources.d.ts +73 -0
  45. package/target/main/ts/compose/analysis-sources.js +47 -0
  46. package/target/main/ts/compose/analyze-snapshot.d.ts +3 -2
  47. package/target/main/ts/compose/analyze-snapshot.js +19 -197
  48. package/target/main/ts/compose/diff-coverage.d.ts +2 -0
  49. package/target/main/ts/compose/diff-coverage.js +6 -4
  50. package/target/main/ts/compose/inspect.d.ts +5 -0
  51. package/target/main/ts/compose/inspect.js +14 -7
  52. package/target/main/ts/compose/languages.d.ts +29 -0
  53. package/target/main/ts/compose/languages.js +87 -0
  54. package/target/main/ts/compose/sources.js +14 -12
  55. package/target/main/ts/core/engine/execute.d.ts +3 -1
  56. package/target/main/ts/core/engine/execute.js +14 -2
  57. package/target/main/ts/core/engine/manifest.d.ts +2 -2
  58. package/target/main/ts/core/engine/manifest.js +25 -5
  59. package/target/main/ts/core/engine/operation-cache.d.ts +14 -0
  60. package/target/main/ts/core/engine/operation-cache.js +66 -0
  61. package/target/main/ts/core/engine/plan.d.ts +3 -4
  62. package/target/main/ts/core/engine/plan.js +28 -11
  63. package/target/main/ts/core/engine/plugin.d.ts +10 -2
  64. package/target/main/ts/core/engine/plugin.js +1 -3
  65. package/target/main/ts/core/engine/report-products.js +2 -13
  66. package/target/main/ts/core/model/clone-source.d.ts +1 -0
  67. package/target/main/ts/core/model/clone-source.js +2 -1
  68. package/target/main/ts/core/model/code-structure.d.ts +5 -0
  69. package/target/main/ts/core/model/code-structure.js +10 -1
  70. package/target/main/ts/core/model/finding-ignore.js +1 -1
  71. package/target/main/ts/core/model/finding.js +1 -1
  72. package/target/main/ts/core/model/language.d.ts +10 -0
  73. package/target/main/ts/core/model/language.js +6 -0
  74. package/target/main/ts/core/model/line-coverage.d.ts +5 -1
  75. package/target/main/ts/core/model/line-coverage.js +14 -11
  76. package/target/main/ts/core/model/measurement.d.ts +7 -6
  77. package/target/main/ts/core/model/measurement.js +18 -7
  78. package/target/main/ts/core/model/plugin-data.d.ts +5 -0
  79. package/target/main/ts/core/model/plugin-data.js +15 -1
  80. package/target/main/ts/core/model/quality-summary.js +6 -5
  81. package/target/main/ts/core/model/report.d.ts +1 -2
  82. package/target/main/ts/core/model/report.js +0 -1
  83. package/target/main/ts/core/model/scanner-import.js +1 -1
  84. package/target/main/ts/core/model/snapshot.d.ts +1 -2
  85. package/target/main/ts/core/model/snapshot.js +5 -7
  86. package/target/main/ts/core/model/source.d.ts +3 -0
  87. package/target/main/ts/core/model/source.js +15 -0
  88. package/target/main/ts/core/ports/tool-runner.d.ts +18 -0
  89. package/target/main/ts/core/ports/tool-runner.js +2 -0
  90. package/target/main/ts/core/usecases/compare.js +61 -17
  91. package/target/main/ts/core/usecases/inspect.js +2 -2
  92. package/target/main/ts/plugin.d.ts +10 -3
  93. package/target/main/ts/plugin.js +4 -2
  94. package/target/main/ts/plugins/coverage/coverage.d.ts +5 -2
  95. package/target/main/ts/plugins/coverage/coverage.js +35 -10
  96. package/target/main/ts/plugins/duplication/duplication.js +10 -4
  97. package/target/main/ts/plugins/language-js/babel-provider.js +8 -2
  98. package/target/main/ts/plugins/language-js/extensions.d.ts +3 -0
  99. package/target/main/ts/plugins/language-js/extensions.js +4 -0
  100. package/target/main/ts/plugins/language-js/function-facts.d.ts +1 -0
  101. package/target/main/ts/plugins/language-js/function-facts.js +30 -4
  102. package/target/main/ts/plugins/language-js/js-security.js +3 -2
  103. package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +11 -0
  104. package/target/main/ts/report/html/app/viewer-chart-bars.js +54 -0
  105. package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
  106. package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
  107. package/target/main/ts/report/html/app/viewer-chart-line.d.ts +24 -0
  108. package/target/main/ts/report/html/app/viewer-chart-line.js +89 -0
  109. package/target/main/ts/report/html/app/viewer-chart-points.d.ts +49 -0
  110. package/target/main/ts/report/html/app/viewer-chart-points.js +74 -0
  111. package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
  112. package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
  113. package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
  114. package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
  115. package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
  116. package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
  117. package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
  118. package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
  119. package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
  120. package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
  121. package/target/main/ts/report/html/app/viewer-chart.d.ts +4 -98
  122. package/target/main/ts/report/html/app/viewer-chart.js +16 -677
  123. package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
  124. package/target/main/ts/report/html/app/viewer-code-map.js +175 -0
  125. package/target/main/ts/report/html/app/viewer-columns.d.ts +38 -0
  126. package/target/main/ts/report/html/app/viewer-columns.js +92 -0
  127. package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
  128. package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
  129. package/target/main/ts/report/html/app/viewer-commits.d.ts +5 -9
  130. package/target/main/ts/report/html/app/viewer-commits.js +17 -216
  131. package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
  132. package/target/main/ts/report/html/app/viewer-controls.js +141 -0
  133. package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
  134. package/target/main/ts/report/html/app/viewer-copy.js +64 -0
  135. package/target/main/ts/report/html/app/viewer-data.d.ts +1 -1
  136. package/target/main/ts/report/html/app/viewer-data.js +2 -29
  137. package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
  138. package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
  139. package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
  140. package/target/main/ts/report/html/app/viewer-dom.js +99 -0
  141. package/target/main/ts/report/html/app/viewer-file-aside.d.ts +19 -0
  142. package/target/main/ts/report/html/app/viewer-file-aside.js +124 -0
  143. package/target/main/ts/report/html/app/viewer-file-figures.d.ts +15 -0
  144. package/target/main/ts/report/html/app/viewer-file-figures.js +60 -0
  145. package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
  146. package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
  147. package/target/main/ts/report/html/app/viewer-files.d.ts +2 -118
  148. package/target/main/ts/report/html/app/viewer-files.js +24 -2184
  149. package/target/main/ts/report/html/app/viewer-filter.d.ts +3 -51
  150. package/target/main/ts/report/html/app/viewer-filter.js +111 -450
  151. package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
  152. package/target/main/ts/report/html/app/viewer-hotspots.js +131 -0
  153. package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
  154. package/target/main/ts/report/html/app/viewer-inspection.js +36 -0
  155. package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
  156. package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
  157. package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
  158. package/target/main/ts/report/html/app/viewer-issues.js +173 -0
  159. package/target/main/ts/report/html/app/viewer-language-bar.d.ts +9 -0
  160. package/target/main/ts/report/html/app/viewer-language-bar.js +72 -0
  161. package/target/main/ts/report/html/app/viewer-languages.d.ts +27 -0
  162. package/target/main/ts/report/html/app/viewer-languages.js +93 -0
  163. package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
  164. package/target/main/ts/report/html/app/viewer-layout.js +134 -0
  165. package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
  166. package/target/main/ts/report/html/app/viewer-line-coverage.js +121 -0
  167. package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
  168. package/target/main/ts/report/html/app/viewer-locations.js +31 -0
  169. package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
  170. package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
  171. package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
  172. package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
  173. package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
  174. package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
  175. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +0 -20
  176. package/target/main/ts/report/html/app/viewer-metric-registry.js +7 -84
  177. package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
  178. package/target/main/ts/report/html/app/viewer-metrics-view.js +162 -0
  179. package/target/main/ts/report/html/app/viewer-metrics.d.ts +6 -1
  180. package/target/main/ts/report/html/app/viewer-metrics.js +53 -35
  181. package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
  182. package/target/main/ts/report/html/app/viewer-overview-cards.js +118 -0
  183. package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
  184. package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
  185. package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
  186. package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
  187. package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
  188. package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
  189. package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
  190. package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
  191. package/target/main/ts/report/html/app/viewer-profile.d.ts +2 -6
  192. package/target/main/ts/report/html/app/viewer-profile.js +6 -248
  193. package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
  194. package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
  195. package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
  196. package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
  197. package/target/main/ts/report/html/app/viewer-pulls.d.ts +0 -1
  198. package/target/main/ts/report/html/app/viewer-pulls.js +28 -178
  199. package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
  200. package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
  201. package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
  202. package/target/main/ts/report/html/app/viewer-route.js +55 -0
  203. package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
  204. package/target/main/ts/report/html/app/viewer-shell.js +116 -0
  205. package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
  206. package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
  207. package/target/main/ts/report/html/app/viewer-source.d.ts +0 -84
  208. package/target/main/ts/report/html/app/viewer-source.js +7 -365
  209. package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
  210. package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
  211. package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
  212. package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
  213. package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
  214. package/target/main/ts/report/html/app/viewer-table-cells.js +129 -0
  215. package/target/main/ts/report/html/app/viewer-table-rows.d.ts +54 -0
  216. package/target/main/ts/report/html/app/viewer-table-rows.js +95 -0
  217. package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +16 -0
  218. package/target/main/ts/report/html/app/viewer-tokenizer.js +192 -0
  219. package/target/main/ts/report/html/app/viewer-totals.d.ts +14 -0
  220. package/target/main/ts/report/html/app/viewer-totals.js +89 -0
  221. package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
  222. package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
  223. package/target/main/ts/report/html/app/viewer-trend-data.d.ts +54 -0
  224. package/target/main/ts/report/html/app/viewer-trend-data.js +109 -0
  225. package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
  226. package/target/main/ts/report/html/app/viewer-trend-nav.js +85 -0
  227. package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
  228. package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
  229. package/target/main/ts/report/html/app/viewer-trend-series.d.ts +26 -0
  230. package/target/main/ts/report/html/app/viewer-trend-series.js +98 -0
  231. package/target/main/ts/report/html/app/viewer-trends.d.ts +2 -70
  232. package/target/main/ts/report/html/app/viewer-trends.js +41 -392
  233. package/target/main/ts/report/html/app/viewer.js +152 -663
  234. package/target/main/ts/report/html/site/export-site.d.ts +3 -4
  235. package/target/main/ts/report/html/site/export-site.js +24 -41
  236. package/target/main/ts/report/html/site/exported-server.js +2 -1
  237. package/target/main/ts/report/html/site/local-server.d.ts +1 -1
  238. package/target/main/ts/report/html/site/local-server.js +13 -19
  239. package/target/main/ts/report/html/site/projects.js +8 -17
  240. package/target/main/ts/report/json/projections/commit-summary.d.ts +2 -2
  241. package/target/main/ts/report/json/projections/commit-summary.js +18 -19
  242. package/target/main/ts/report/json/projections/file-metrics.js +31 -24
  243. package/target/main/ts/report/json/projections/inspection-context.js +10 -1
  244. package/target/main/ts/report/json/projections/inspection-details.d.ts +1 -1
  245. package/target/main/ts/report/json/projections/inspection-details.js +2 -2
  246. package/target/main/ts/report/json/projections/metric-values.d.ts +1 -0
  247. package/target/main/ts/report/json/projections/metric-values.js +15 -5
  248. package/target/main/ts/report/json/store/local-store.js +2 -12
  249. package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
  250. package/target/main/ts/report/json/store/operation-cache.js +32 -0
  251. package/target/main/ts/report/json/store/pull-review-store.js +1 -2
  252. package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
  253. package/target/main/ts/report/json/store/replace-file.js +14 -0
  254. package/target/main/ts/report/json/validation/report.d.ts +1 -1
  255. package/target/main/ts/report/json/validation/report.js +10 -8
  256. package/target/main/ts/report/json/validation/summary-validation.js +1 -3
  257. package/target/main/ts/report/json/wire/file-metrics-model.d.ts +2 -0
  258. package/target/main/ts/report/json/wire/inspection-details-model.d.ts +0 -5
  259. package/target/main/ts/report/json/wire/public-history-model.d.ts +0 -6
  260. package/target/main/ts/report/json/wire/public-history-model.js +0 -1
  261. package/target/main/ts/report.d.ts +3 -3
  262. package/target/main/ts/report.js +2 -2
  263. package/target/main/resources/report/json/inspection-context-v1.schema.json +0 -172
  264. package/target/main/resources/report/json/public-history-v1.schema.json +0 -50
  265. package/target/main/resources/report/json/quality-history-v1.schema.json +0 -51
  266. package/target/main/resources/report/json/report-v1.schema.json +0 -65
  267. package/target/main/resources/report/json/viewer-details-v1.schema.json +0 -346
  268. package/target/main/ts/report/json/projections/public-history.d.ts +0 -4
  269. package/target/main/ts/report/json/projections/public-history.js +0 -17
@@ -1,5 +1,8 @@
1
- import { copyIcon, multiChoice, navigationButtons, searchField, splitter } from './viewer-files.js';
2
- import { count, duration, securityGrades, securityRisks } from './viewer-metrics.js';
1
+ import { count, element } from './viewer-dom.js';
2
+ import { splitter } from './viewer-layout.js';
3
+ import { duration } from './viewer-metrics.js';
4
+ import { badges } from './viewer-profile-badges.js';
5
+ import { pagedTable } from './viewer-profile-table.js';
3
6
  /** What each structural rule measures, and in what unit its limit and its cost are counted. */
4
7
  const ruleNames = {
5
8
  'function-complexity': ['Cognitive complexity of a function', 'point'],
@@ -25,7 +28,7 @@ export function renderProfile(container, data) {
25
28
  section.append(chips(scanners.map(({ name, version }) => version ? `${name} ${version}` : name)));
26
29
  main.append(section);
27
30
  }
28
- split.append(main, splitter(split), badges(data));
31
+ split.append(main, splitter(split), badges(data.latest, data.details));
29
32
  view.append(split);
30
33
  container.replaceChildren(view);
31
34
  }
@@ -113,113 +116,6 @@ function exclusions(profile, context) {
113
116
  }));
114
117
  return section;
115
118
  }
116
- const tableSize = 50;
117
- const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
118
- /**
119
- * A list that may run to tens of thousands of rows, as a profile's rules and patterns do in a monorepo: searched,
120
- * narrowed by one facet, sorted by any column, and paged, with the count beside the page buttons as in Metrics.
121
- * Only the page in view is built.
122
- */
123
- function pagedTable(spec) {
124
- const box = element('div', 'profile-table');
125
- if (!spec.rows.length) {
126
- box.append(element('p', 'detail', spec.empty));
127
- return box;
128
- }
129
- const haystacks = spec.rows.map(row => spec.search(row).toLowerCase());
130
- let page = 0;
131
- let sortBy = -1;
132
- let ascending = true;
133
- const reset = () => { page = 0; render(); };
134
- const tools = element('div', 'fx-tools profile-table-tools');
135
- const search = searchField(`Search ${spec.noun[1]}`, `Search ${spec.noun[1]}`);
136
- search.label.classList.add('fx-field-bare');
137
- search.input.addEventListener('input', reset);
138
- const facet = spec.facet && multiChoice(spec.facet.text, spec.facet.all, spec.facet.plural, [...spec.rows.reduce((counts, row) => {
139
- const key = spec.facet.key(row);
140
- return counts.set(key, (counts.get(key) ?? 0) + 1);
141
- }, new Map())].sort((a, b) => collator.compare(a[0], b[0])).map(([key, total]) => [key, key, total]), reset);
142
- // A short list needs no controls: it is read at a glance.
143
- if (spec.controls || spec.rows.length > 10)
144
- tools.append(search.label);
145
- if (facet && !facet.element.hidden)
146
- tools.append(facet.element);
147
- const table = element('table', 'fx-table profile-list');
148
- table.setAttribute('aria-label', spec.label);
149
- const head = element('tr');
150
- const headers = spec.columns.map((column, index) => {
151
- const cell = element('th', column.numeric ? 'numeric' : '');
152
- cell.scope = 'col';
153
- const button = element('button', 'fx-sort', column.label);
154
- button.type = 'button';
155
- button.addEventListener('click', () => {
156
- ascending = sortBy === index ? !ascending : !column.numeric;
157
- sortBy = index;
158
- reset();
159
- });
160
- cell.append(button);
161
- head.append(cell);
162
- return cell;
163
- });
164
- const thead = element('thead');
165
- thead.append(head);
166
- const body = element('tbody');
167
- table.append(thead, body);
168
- const frame = element('div', 'table-scroll fx-table-scroll');
169
- frame.append(table);
170
- const pager = element('div', 'fx-pager');
171
- const result = element('p', 'fx-note fx-results');
172
- result.setAttribute('aria-live', 'polite');
173
- const buttons = navigationButtons(`${spec.label} pages`, () => { page -= 1; render(); }, () => { page += 1; render(); });
174
- pager.append(result, buttons.section);
175
- if (tools.childElementCount)
176
- box.append(tools);
177
- box.append(frame, pager);
178
- function render() {
179
- const words = search.input.value.trim().toLowerCase().split(/\s+/).filter(Boolean);
180
- const chosen = facet?.values;
181
- let shown = spec.rows.flatMap((row, index) => (!chosen?.size || chosen.has(spec.facet.key(row)))
182
- && words.every(word => haystacks[index].includes(word)) ? [row] : []);
183
- if (sortBy >= 0) {
184
- const key = spec.columns[sortBy].sort;
185
- const direction = ascending ? 1 : -1;
186
- shown = shown.sort((a, b) => {
187
- const left = key(a);
188
- const right = key(b);
189
- return direction * (typeof left === 'number' && typeof right === 'number' ? left - right : collator.compare(String(left), String(right)));
190
- });
191
- }
192
- for (const [index, cell] of headers.entries()) {
193
- if (index === sortBy)
194
- cell.setAttribute('aria-sort', ascending ? 'ascending' : 'descending');
195
- else
196
- cell.removeAttribute('aria-sort');
197
- }
198
- const pages = Math.max(1, Math.ceil(shown.length / tableSize));
199
- page = Math.min(page, pages - 1);
200
- const visible = shown.slice(page * tableSize, (page + 1) * tableSize);
201
- body.replaceChildren(...visible.map(row => {
202
- const line = element('tr');
203
- for (const column of spec.columns) {
204
- const cell = element('td', column.numeric ? 'numeric' : '');
205
- cell.append(column.cell(row));
206
- line.append(cell);
207
- }
208
- return line;
209
- }));
210
- frame.hidden = shown.length === 0;
211
- const [one, many] = spec.noun;
212
- const filtered = shown.length !== spec.rows.length;
213
- result.textContent = shown.length === 0 ? `No ${many} match.`
214
- : shown.length > tableSize ? `${count(page * tableSize + 1)}–${count(page * tableSize + visible.length)} of ${count(shown.length)} ${many}`
215
- : filtered ? `${count(shown.length)} of ${count(spec.rows.length)} ${many}`
216
- : `${count(shown.length)} ${shown.length === 1 ? one : many}`;
217
- buttons.section.hidden = shown.length <= tableSize;
218
- buttons.update(page, pages);
219
- }
220
- render();
221
- return box;
222
- }
223
119
  /** Until the details arrive only the exclusions are known; the summary does not carry the profile itself. */
224
120
  function fallback(data) {
225
121
  const section = block('Files');
@@ -234,136 +130,6 @@ function fallback(data) {
234
130
  section.append(element('p', 'detail', 'This inspection did not record its profile.'));
235
131
  return section;
236
132
  }
237
- const formatKey = 'repometry.badge-format';
238
- /** The badges as a README shows them: each with the scale it grades by, and the snippet that embeds it. */
239
- function badges(data) {
240
- const panel = element('aside', 'fx-aside profile-aside');
241
- panel.setAttribute('aria-label', 'Badges');
242
- const heading = element('div', 'fx-aside-heading');
243
- heading.append(element('h2', '', 'Badges'));
244
- let format = 'markdown';
245
- try {
246
- if (localStorage.getItem(formatKey) === 'html')
247
- format = 'html';
248
- }
249
- catch {
250
- // Blocked storage only forgets the choice.
251
- }
252
- const snippets = [];
253
- const toggle = element('div', 'fx-segmented profile-format');
254
- toggle.setAttribute('role', 'group');
255
- toggle.setAttribute('aria-label', 'Snippet format');
256
- for (const [value, label] of [['markdown', 'Markdown'], ['html', 'HTML']]) {
257
- const button = element('button', '', label);
258
- button.type = 'button';
259
- button.setAttribute('aria-pressed', String(value === format));
260
- button.addEventListener('click', () => {
261
- format = value;
262
- for (const other of toggle.querySelectorAll('button'))
263
- other.setAttribute('aria-pressed', String(other === button));
264
- try {
265
- localStorage.setItem(formatKey, value);
266
- }
267
- catch {
268
- // As above.
269
- }
270
- for (const update of snippets)
271
- update();
272
- });
273
- toggle.append(button);
274
- }
275
- heading.append(toggle);
276
- panel.append(heading);
277
- const { report, quality, context } = data.latest;
278
- const lines = report.lineCoverage;
279
- const coverage = lines && lines.total > 0 ? lines.covered / lines.total : null;
280
- const ratio = quality?.maintainability?.debtRatio ?? null;
281
- const security = context?.security;
282
- const worst = !security ? null : security.critical ? 4 : security.high ? 3 : security.medium ? 2 : security.low || security.unknown ? 1 : 0;
283
- const areas = [
284
- ['maintainability', 'Maintainability', [['A', '<5%'], ['B', '<10%'], ['C', '<20%'], ['D', '<50%'], ['F', '50%+']],
285
- ratio === null ? null : [.05, .1, .2, .5, Infinity].findIndex(limit => ratio < limit), true],
286
- ['coverage', 'Coverage', [['A', '90%+'], ['B', '80%+'], ['C', '70%+'], ['D', '60%+'], ['F', '<60%']],
287
- coverage === null ? null : [.9, .8, .7, .6, -Infinity].findIndex(limit => coverage >= limit), true],
288
- ['security', 'Security', securityGrades.map((grade, index) => [grade, securityRisks[index]]), worst, security !== undefined],
289
- ];
290
- for (const [name, label, steps, current, published] of areas) {
291
- const section = element('section', 'fx-aside-section profile-badge-area');
292
- section.append(element('h3', '', label));
293
- if (published) {
294
- const image = element('img', 'profile-badge');
295
- image.src = `./${name}.svg`;
296
- image.alt = `${label} badge`;
297
- image.height = 22;
298
- section.append(image);
299
- }
300
- section.append(scale(steps, current));
301
- if (published) {
302
- const url = new URL(`./${name}.svg`, location.href).href;
303
- const home = new URL('./', location.href).href;
304
- const box = element('div', 'profile-snippet');
305
- const text = element('code');
306
- box.append(text, copyButton(`Copy the ${label.toLowerCase()} badge snippet`, () => text.textContent ?? ''));
307
- const update = () => {
308
- text.textContent = format === 'markdown' ? `[![${label}](${url})](${home})`
309
- : `<a href="${home}"><img src="${url}" alt="${label}"></a>`;
310
- };
311
- update();
312
- snippets.push(update);
313
- section.append(box);
314
- }
315
- else
316
- section.append(element('p', 'fx-note', 'No scanner report, so no badge.'));
317
- panel.append(section);
318
- }
319
- // Footnotes close the sidebar, under the last badge: how the maintainability grade's ratio is made, and what badges show.
320
- const model = data.details?.profile?.debtModel;
321
- panel.append(element('p', 'fx-note profile-badge-note', model
322
- ? `Debt ratio: remediation time over the time to write the code, by ${model.name === 'basic-cocomo-organic' ? 'basic COCOMO (organic)' : model.name}: ${model.scale} × KLOC^${model.exponent} person-months of ${count(Math.round(model.minutesPerPersonMonth / 60))} hours.`
323
- : 'Debt ratio: remediation time over the estimated time to write the code.'));
324
- panel.append(element('p', 'fx-note profile-footnote', 'Badges show the latest inspection; their links work once the report is hosted.'));
325
- return panel;
326
- }
327
- /** The scale as one strip in the grade colours, the latest inspection's step at full strength. */
328
- function scale(steps, current) {
329
- const box = element('div', 'profile-scale');
330
- const strip = element('div', 'profile-scale-strip');
331
- const words = element('div', 'profile-scale-words');
332
- for (const [index, [grade, range, word]] of steps.entries()) {
333
- const segment = element('span', 'profile-scale-grade', word ?? grade);
334
- segment.dataset.grade = grade;
335
- if (index === current)
336
- segment.setAttribute('aria-current', 'true');
337
- strip.append(segment);
338
- words.append(element('span', '', range));
339
- }
340
- box.append(strip, words);
341
- return box;
342
- }
343
- function copyButton(label, text) {
344
- const button = element('button', 'fx-copy profile-copy');
345
- button.type = 'button';
346
- button.title = label;
347
- button.setAttribute('aria-label', label);
348
- button.append(copyIcon());
349
- let reset;
350
- button.addEventListener('click', async () => {
351
- clearTimeout(reset);
352
- try {
353
- await navigator.clipboard.writeText(text());
354
- button.classList.add('fx-copied');
355
- reset = setTimeout(() => button.classList.remove('fx-copied'), 1500);
356
- }
357
- catch {
358
- // Without clipboard access the snippet is selected, ready for the copy shortcut.
359
- const range = document.createRange();
360
- range.selectNodeContents(button.previousElementSibling);
361
- getSelection()?.removeAllRanges();
362
- getSelection()?.addRange(range);
363
- }
364
- });
365
- return button;
366
- }
367
133
  function order(rule) {
368
134
  const index = ruleOrder.indexOf(rule);
369
135
  return index < 0 ? ruleOrder.length : index;
@@ -391,11 +157,3 @@ function none(text = 'None') {
391
157
  function code(text) {
392
158
  return element('code', '', text);
393
159
  }
394
- function element(tag, className, text) {
395
- const node = document.createElement(tag);
396
- if (className)
397
- node.className = className;
398
- if (text !== undefined)
399
- node.textContent = text;
400
- return node;
401
- }
@@ -0,0 +1,4 @@
1
+ import type { PullReview } from '../../json/wire/pull-review-model.js';
2
+ export declare function reviewFiles(review: PullReview): HTMLElement;
3
+ export declare function reviewIssues({ findings }: PullReview): HTMLElement;
4
+ export declare function node<K extends keyof HTMLElementTagNameMap>(name: K, text?: string, className?: string): HTMLElementTagNameMap[K];
@@ -0,0 +1,118 @@
1
+ import { lineCount } from './viewer-pull-trend.js';
2
+ const findingReasons = {
3
+ 'reports-unavailable': 'Save inspections for the base and head commits to compare findings.',
4
+ 'findings-unavailable': 'One or both revisions lack findings data.',
5
+ 'partial-inspection': 'One or both revisions have incomplete analysis.',
6
+ 'analysis-changed': 'The base and head used different analysis settings.',
7
+ };
8
+ export function reviewFiles(review) {
9
+ const section = node('section', '', 'pull-section');
10
+ const heading = node('h3', 'Changed files');
11
+ section.append(heading);
12
+ const { diff } = review;
13
+ if (diff.excludedPaths?.length) {
14
+ section.append(node('p', `Path exclusions · ${diff.excludedPaths.join(', ')}`, 'detail pull-exclusions'));
15
+ }
16
+ if (diff.files.length === 0 && diff.gaps.length === 0) {
17
+ section.append(node('p', diff.status === 'unavailable' ? 'Provide LCOV for this head revision to inspect its changed lines.'
18
+ : 'No added or modified source lines in the inspected scope.', 'detail'));
19
+ return section;
20
+ }
21
+ const files = new Map(diff.uncovered.map(file => [file.path, file.lines]));
22
+ const gaps = new Map(diff.gaps.map(gap => [gap.path, gap.reason]));
23
+ const rows = [...diff.files].sort((left, right) => missedCount(right) - missedCount(left) || right.addedLines - left.addedLines)
24
+ .map(record => {
25
+ const { path, addedLines, covered, total } = record;
26
+ const label = node('th');
27
+ const parts = path.split('/');
28
+ for (const [index, part] of parts.entries()) {
29
+ label.append(part);
30
+ if (index < parts.length - 1)
31
+ label.append('/', node('wbr'));
32
+ }
33
+ label.scope = 'row';
34
+ const missing = files.get(path);
35
+ const gap = gaps.get(path);
36
+ gaps.delete(path);
37
+ if (missing) {
38
+ const details = node('details', '', 'pull-missed-lines');
39
+ const ranges = lineRanges(missing);
40
+ details.append(node('summary', `${lineCount(missing.length)} missed ${missing.length === 1 ? 'line' : 'lines'}`), node('span', ranges.join(', ')));
41
+ label.append(details);
42
+ }
43
+ if (gap)
44
+ label.append(node('p', gap, 'detail'));
45
+ const row = node('tr');
46
+ row.append(label, cell(lineCount(addedLines), true), cell(covered === null || total === null ? '—' : `${lineCount(covered)} / ${lineCount(total)}`, true));
47
+ return row;
48
+ });
49
+ if (rows.length > 0)
50
+ section.append(table('Changed file coverage', ['File', 'Added lines', 'Covered / measured'], rows, 'pull-coverage-table'));
51
+ if (gaps.size > 0) {
52
+ const notes = node('ul', '', 'pull-gaps');
53
+ for (const [path, reason] of gaps)
54
+ notes.append(node('li', `${path} · ${reason}`));
55
+ section.append(node('h4', 'Coverage gaps'), notes);
56
+ }
57
+ return section;
58
+ }
59
+ export function reviewIssues({ findings }) {
60
+ const section = node('section', '', 'pull-section');
61
+ section.append(node('h3', 'New issues'));
62
+ if (findings.added === null || findings.added.length === 0) {
63
+ section.append(node('p', findings.reason ? findingReasons[findings.reason] : 'No new issues in the inspected scope.', 'detail'));
64
+ return section;
65
+ }
66
+ const rows = findings.added.map(finding => {
67
+ const row = node('tr');
68
+ const message = node('th', finding.message);
69
+ message.scope = 'row';
70
+ message.append(node('p', [finding.tool, finding.rule].join(' · '), 'detail'));
71
+ const location = finding.path ? `${finding.path}${finding.line ? `:${finding.line}` : ''}` : '—';
72
+ row.append(message, cell(location), cell(finding.level));
73
+ return row;
74
+ });
75
+ section.append(table('Newly introduced findings', ['Finding', 'Source', 'Severity'], rows));
76
+ return section;
77
+ }
78
+ function lineRanges(lines) {
79
+ const ranges = [];
80
+ for (let start = 0; start < lines.length;) {
81
+ let end = start;
82
+ while (lines[end + 1] === lines[end] + 1)
83
+ end++;
84
+ ranges.push(start === end ? String(lines[start]) : `${lines[start]}–${lines[end]}`);
85
+ start = end + 1;
86
+ }
87
+ return ranges;
88
+ }
89
+ function missedCount({ covered, total }) {
90
+ return covered === null || total === null ? -1 : total - covered;
91
+ }
92
+ function table(label, headers, rows, className = '') {
93
+ const table = node('table', '', `pull-table ${className}`.trim());
94
+ const thead = node('thead');
95
+ const headings = node('tr');
96
+ for (const text of headers) {
97
+ const th = node('th', text);
98
+ th.scope = 'col';
99
+ headings.append(th);
100
+ }
101
+ thead.append(headings);
102
+ const body = node('tbody');
103
+ body.append(...rows);
104
+ table.append(thead, body);
105
+ table.setAttribute('aria-label', label);
106
+ return table;
107
+ }
108
+ function cell(text, numeric = false) {
109
+ return node('td', text, numeric ? 'numeric' : '');
110
+ }
111
+ export function node(name, text = '', className = '') {
112
+ const element = document.createElement(name);
113
+ if (text)
114
+ element.textContent = text;
115
+ if (className)
116
+ element.className = className;
117
+ return element;
118
+ }
@@ -0,0 +1,5 @@
1
+ import type { PullReview } from '../../json/wire/pull-review-model.js';
2
+ /** A review's coverage as a percentage, from the 0–100 the review records. */
3
+ export declare function formatPercent(value: number | null): string;
4
+ export declare function lineCount(value: number): string;
5
+ export declare function renderDiffCoverageTrend(container: HTMLElement, records: readonly PullReview[]): void;
@@ -0,0 +1,63 @@
1
+ import { element } from './viewer-dom.js';
2
+ const whole = new Intl.NumberFormat();
3
+ const percentage = new Intl.NumberFormat(undefined, { style: 'percent', maximumFractionDigits: 1 });
4
+ const date = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' });
5
+ /** A review's coverage as a percentage, from the 0–100 the review records. */
6
+ export function formatPercent(value) {
7
+ return value === null ? 'Unavailable' : percentage.format(value / 100);
8
+ }
9
+ export function lineCount(value) {
10
+ return whole.format(value);
11
+ }
12
+ /** Why a review has no changed-line coverage to show. */
13
+ const unmeasured = { partial: 'Partial · Unmeasured', 'not-applicable': 'No measurable changes' };
14
+ function trendSubject(review) {
15
+ const subject = element('div', 'pull-trend-subject');
16
+ const time = element('time', 'detail', date.format(new Date(review.generatedAt)));
17
+ time.dateTime = review.generatedAt;
18
+ subject.append(element('strong', '', review.number === null ? review.head.slice(0, 7) : `#${review.number}`), time);
19
+ return subject;
20
+ }
21
+ function trendResult(diff) {
22
+ const value = element('div', 'pull-trend-result');
23
+ const { percent, status, covered, total } = diff;
24
+ if (percent === null) {
25
+ value.append(element('span', 'detail', unmeasured[status] ?? 'Coverage unavailable'));
26
+ return value;
27
+ }
28
+ const result = `${whole.format(covered)} / ${whole.format(total)} lines`;
29
+ value.append(element('strong', '', formatPercent(percent)), element('span', 'detail', status === 'partial' ? `Partial · ${result}` : result));
30
+ return value;
31
+ }
32
+ function trendTrack(diff) {
33
+ const track = element('div', 'pull-trend-track');
34
+ track.setAttribute('aria-hidden', 'true');
35
+ if (diff.percent === null) {
36
+ track.classList.add('pull-trend-empty');
37
+ return track;
38
+ }
39
+ const bar = element('div', 'pull-trend-bar');
40
+ bar.dataset.status = diff.status;
41
+ bar.style.inlineSize = `${diff.percent}%`;
42
+ track.append(bar);
43
+ return track;
44
+ }
45
+ export function renderDiffCoverageTrend(container, records) {
46
+ container.replaceChildren(element('h2', '', 'Changed-line coverage by pull request'));
47
+ const reviews = [...records].sort((left, right) => right.generatedAt.localeCompare(left.generatedAt)).slice(0, 12);
48
+ if (reviews.length === 0) {
49
+ container.append(element('p', 'detail', 'No saved PR reviews.'));
50
+ return;
51
+ }
52
+ const list = element('ol', 'pull-trend-list');
53
+ const axis = element('div', 'pull-trend-axis');
54
+ axis.setAttribute('aria-hidden', 'true');
55
+ for (const value of [0, 25, 50, 75, 100])
56
+ axis.append(element('span', '', `${value}%`));
57
+ container.append(axis, list);
58
+ for (const review of reviews) {
59
+ const row = element('li', 'pull-trend-row');
60
+ row.append(trendSubject(review), trendTrack(review.diff), trendResult(review.diff));
61
+ list.append(row);
62
+ }
63
+ }
@@ -1,3 +1,2 @@
1
1
  import type { PullReview } from '../../json/wire/pull-review-model.js';
2
2
  export declare function renderPulls(container: HTMLElement, records: readonly PullReview[]): void;
3
- export declare function renderDiffCoverageTrend(container: HTMLElement, records: readonly PullReview[]): void;