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
@@ -0,0 +1,95 @@
1
+ import { execute } from '../core/engine/execute.js';
2
+ import { plan } from '../core/engine/plan.js';
3
+ import { codeStructure } from '../core/model/code-structure.js';
4
+ import { sourceFile } from '../core/model/snapshot.js';
5
+ import { isClaimedText, maxClaimedFileBytes } from '../core/model/source.js';
6
+ import { fileQuality } from '../plugins/maintainability/maintainability.js';
7
+ import { oversizedClaim } from './analysis-results.js';
8
+ import { defaultProvider, inspectionKeys, pluginForScope, structuralInspections } from './analysis-sources.js';
9
+ const standardInspections = ['structure/size', 'structure/complexity', 'maintainability/file'];
10
+ const fileInput = new Map([['file', sourceFile.id]]);
11
+ const batchFileInput = new Map([...fileInput, ['syntax', codeStructure.id]]);
12
+ export const defaultFilePlan = filePlan(defaultProvider, []);
13
+ export async function inspectFiles(sources, batchFacts, results, withCoverage, cache) {
14
+ const plans = new Map([[filePlanKey(defaultProvider, []), defaultFilePlan]]);
15
+ const cloneSources = [];
16
+ const functionBodies = new Map();
17
+ for (const source of sources.sources) {
18
+ const plugins = matchedInspections(source, sources, results);
19
+ const { file, provider } = source;
20
+ if (!provider && !plugins.length)
21
+ continue;
22
+ const tasks = findFilePlan(provider, plugins, plans, results);
23
+ const facts = batchFacts.get(file.path);
24
+ const products = new Map([['file', { contract: sourceFile.id, value: file }]]);
25
+ if (facts)
26
+ products.set('syntax', { contract: codeStructure.id, value: facts });
27
+ const outcomes = await execute(tasks, products, cache);
28
+ const syntax = provider && outcomes.get(provider.key);
29
+ const bodies = recordFileSyntax(source, syntax, facts, results, withCoverage);
30
+ if (bodies !== undefined)
31
+ functionBodies.set(file.path, bodies);
32
+ collectFileProducts(tasks, outcomes, source, cloneSources, results);
33
+ }
34
+ return { cloneSources, functionBodies };
35
+ }
36
+ function matchedInspections({ file }, sources, results) {
37
+ const claimed = sources.perFile.filter(({ matches }) => matches(file.path));
38
+ if (claimed.length && file.bytes.byteLength > maxClaimedFileBytes)
39
+ results.diagnostics.push(oversizedClaim(file.path));
40
+ return isClaimedText(file.bytes) ? claimed.map(({ plugin }) => plugin) : [];
41
+ }
42
+ function findFilePlan(provider, plugins, plans, results) {
43
+ const key = filePlanKey(provider, plugins);
44
+ const cached = plans.get(key);
45
+ if (cached)
46
+ return cached;
47
+ const tasks = filePlan(provider, plugins);
48
+ plans.set(key, tasks);
49
+ for (const task of tasks) {
50
+ const consumesBatch = provider?.batch && [...task.inputs.values()].some(input => 'external' in input && input.external === 'syntax');
51
+ results.remember(task, consumesBatch ? provider.key : undefined);
52
+ }
53
+ return tasks;
54
+ }
55
+ function filePlan(provider, plugins) {
56
+ const inspections = plugins.flatMap(inspectionKeys);
57
+ if (!provider)
58
+ return plan({ plugins, select: inspections, inputs: fileInput });
59
+ const needsProvider = !provider.batch && plugins.every(plugin => plugin.id !== provider.plugin.id);
60
+ const syntax = provider.batch ? { external: 'syntax' } : { operation: provider.key };
61
+ const providers = needsProvider ? [pluginForScope(provider.plugin, 'file')] : [];
62
+ return plan({
63
+ plugins: [...providers, ...structuralInspections, ...plugins],
64
+ select: [...standardInspections, ...inspections],
65
+ inputs: provider.batch ? batchFileInput : fileInput,
66
+ bindings: new Map(standardInspections.map(operation => [operation, { syntax }])),
67
+ });
68
+ }
69
+ function filePlanKey(provider, plugins) {
70
+ return JSON.stringify([provider?.key ?? null, ...plugins.map(plugin => plugin.id)]);
71
+ }
72
+ function recordFileSyntax({ file, provider }, outcome, batch, results, withCoverage) {
73
+ const value = outcome?.state === 'completed' ? outcome.product.value : undefined;
74
+ const builtinParsed = provider === defaultProvider && value !== undefined;
75
+ const facts = batch ?? ((!builtinParsed || withCoverage) && codeStructure.accepts(value) ? value : undefined);
76
+ if (facts || builtinParsed)
77
+ results.parsed.add(file.path);
78
+ return withCoverage ? facts?.functionBodies : undefined;
79
+ }
80
+ function collectFileProducts(tasks, outcomes, { file, provider }, clones, results) {
81
+ for (const task of tasks) {
82
+ const outcome = outcomes.get(task.key);
83
+ results.record(task, outcome, file.path);
84
+ const source = cloneSource(outcome, provider);
85
+ if (source)
86
+ clones.push(source);
87
+ }
88
+ }
89
+ function cloneSource(outcome, provider) {
90
+ if (outcome.state !== 'completed' || outcome.product.contract !== fileQuality.id || !fileQuality.accepts(outcome.product.value))
91
+ return;
92
+ const source = outcome.product.value.cloneSource;
93
+ return provider && provider !== defaultProvider && source.scheme === undefined ? { ...source, scheme: provider.plugin.id } : source;
94
+ }
95
+ //# sourceMappingURL=analysis-files.js.map
@@ -0,0 +1,7 @@
1
+ import type { OperationCacheOptions } from '../core/engine/operation-cache.js';
2
+ import type { AnalysisInput } from '../core/usecases/inspect.js';
3
+ import type { FileAnalysis } from './analysis-files.js';
4
+ import type { AnalysisResults } from './analysis-results.js';
5
+ import type { AnalysisSources } from './analysis-sources.js';
6
+ export declare function inspectDuplication(files: FileAnalysis, results: AnalysisResults, cache?: OperationCacheOptions): Promise<void>;
7
+ export declare function importAnalysisCoverage({ coverage: input, excludedPaths, snapshot }: AnalysisInput, sources: AnalysisSources, files: FileAnalysis, results: AnalysisResults, cache?: OperationCacheOptions): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import { execute } from '../core/engine/execute.js';
2
+ import { plan } from '../core/engine/plan.js';
3
+ import { sourceLineCounts } from '../core/model/snapshot.js';
4
+ import { sourceExclusionMatcher } from '../core/profile/exclusions.js';
5
+ import { coverage, coverageResult, lcovInput } from '../plugins/coverage/coverage.js';
6
+ import { duplication, duplicationInput } from '../plugins/duplication/duplication.js';
7
+ const duplicationPlan = plan({ plugins: [duplication], select: ['duplication/detect'], inputs: new Map([['sources', duplicationInput.id]]) });
8
+ const coveragePlan = plan({ plugins: [coverage], select: ['lcov/import', 'lcov/lines'], inputs: new Map([['lcov', lcovInput.id]]) });
9
+ export async function inspectDuplication(files, results, cache) {
10
+ const inputs = new Map([['sources', { contract: duplicationInput.id, value: files.cloneSources }]]);
11
+ const outcomes = await execute(duplicationPlan, inputs, cache);
12
+ const [task] = duplicationPlan;
13
+ results.remember(task);
14
+ results.record(task, outcomes.get(task.key));
15
+ }
16
+ export async function importAnalysisCoverage({ coverage: input, excludedPaths = [], snapshot }, sources, files, results, cache) {
17
+ if (input === undefined)
18
+ return;
19
+ const value = { text: input.text, root: input.sourceRoot, sourceLines: sourceLineCounts(sources.sourceFiles),
20
+ codeLines: new Map(files.cloneSources.map(({ path, codeLines }) => [path, new Set(codeLines)])), functionBodies: files.functionBodies,
21
+ excludes: sourceExclusionMatcher(excludedPaths, snapshot.generatedExcluded) };
22
+ const outcomes = await execute(coveragePlan, new Map([['lcov', { contract: lcovInput.id, value }]]), cache);
23
+ for (const task of coveragePlan) {
24
+ results.remember(task);
25
+ results.record(task, outcomes.get(task.key));
26
+ }
27
+ const outcome = outcomes.get('lcov/import');
28
+ if (outcome?.state !== 'completed' || !coverageResult.accepts(outcome.product.value))
29
+ return;
30
+ for (const { path, reason } of outcome.product.value.gaps) {
31
+ results.diagnostics.push({ operation: 'lcov/import', state: 'partial', path, message: reason });
32
+ }
33
+ }
34
+ //# sourceMappingURL=analysis-imports.js.map
@@ -0,0 +1,5 @@
1
+ import type { Report } from '../core/model/report.js';
2
+ import type { AnalysisInput } from '../core/usecases/inspect.js';
3
+ import type { AnalysisResults } from './analysis-results.js';
4
+ import type { AnalysisSources } from './analysis-sources.js';
5
+ export declare function assembleAnalysisReport(input: AnalysisInput, sources: AnalysisSources, results: AnalysisResults): Report;
@@ -0,0 +1,78 @@
1
+ import { definitions } from '../core/model/measurement.js';
2
+ import { debtModel } from '../core/model/quality-summary.js';
3
+ import { reportSchema } from '../core/model/report.js';
4
+ import { comparePaths, digest, sourceDirectoriesExcluded, textLineCount } from '../core/model/snapshot.js';
5
+ import { defaultSourceExclusions, generatedSourcePolicy } from '../core/profile/exclusions.js';
6
+ import { duplicationSettings, structuralRules } from '../core/profile/maintainability.js';
7
+ import { parserDefaults } from '../plugins/language-js/babel-provider.js';
8
+ import { languageId } from './languages.js';
9
+ const measurementDefinitions = {
10
+ [definitions.lines]: 'Physical lines including blank lines and comments. A final line terminator does not add a line.',
11
+ [definitions.functions]: 'Babel function nodes with bodies, including nested functions and methods.',
12
+ [definitions.complexity]: 'One plus branches in the function body: if, ternary, loops, catch, non-default switch cases and logical operators. Nested functions are measured separately. Line and column are 1-based and columns count UTF-16 units.',
13
+ [definitions.coverage]: 'Distinct covered code lines divided by the distinct code lines listed in LCOV DA records. Hit counts are summed across records. A zero denominator has no ratio.',
14
+ [definitions.codeLines]: 'Nonblank physical lines after removing Babel comment spans and the interpreter directive. A line containing both code and a comment counts as code.',
15
+ [definitions.comments]: 'Physical lines containing only a Babel comment or interpreter directive.',
16
+ [definitions.classes]: 'Babel class declaration and expression nodes.',
17
+ [definitions.cognitiveComplexity]: 'Flow breaks plus nesting weight and logical operator sequences. Nested functions are measured separately. File complexity sums functions and module-level flow breaks.',
18
+ [definitions.duplicatedLines]: 'Distinct code lines inside repeated Babel syntax subtrees, including original and repeated occurrences. Identifier and literal spellings are ignored for similar-code matches.',
19
+ };
20
+ export function assembleAnalysisReport(input, sources, results) {
21
+ const pluginData = results.pluginData();
22
+ const { snapshot } = input;
23
+ const fileCount = sources.sourceFiles.length;
24
+ return {
25
+ schema: reportSchema,
26
+ subject: snapshot.subject,
27
+ generatedAt: new Date().toISOString(),
28
+ appliedConfig: appliedConfiguration(input, sources, results),
29
+ definitions: { ...Object.fromEntries((pluginData?.metrics ?? []).map(metric => [metric.id, metric.description ?? metric.label])),
30
+ ...measurementDefinitions },
31
+ scope: { files: fileCount, parsed: results.parsed.size },
32
+ status: inspectionStatus(fileCount, results),
33
+ measurements: results.measurements,
34
+ diagnostics: results.diagnostics,
35
+ findings: results.findings,
36
+ ...(pluginData === undefined ? {} : { pluginData: { ...pluginData, languages: sources.languages.catalog,
37
+ inventory: reportInventory(snapshot, sources, results) } }),
38
+ };
39
+ }
40
+ function appliedConfiguration({ snapshot, excludedOutput, excludedPaths = [], coverage }, { languages, claimedPlugins, plugins }, results) {
41
+ const securityScanners = results.securityScanners(claimedPlugins);
42
+ return {
43
+ profile: 'js-ts/v2', mode: snapshot.subject.kind,
44
+ source: { extensions: languages.extensions, ...(languages.globs.length ? { globs: languages.globs } : {}),
45
+ excludedDirectories: sourceDirectoriesExcluded, excludedOutput, excludedPaths,
46
+ defaultExclusions: defaultSourceExclusions, generatedSourcePolicy, generatedExcluded: snapshot.generatedExcluded ?? [] },
47
+ parser: parserDefaults,
48
+ maintainability: { structuralRules, duplication: duplicationSettings, debtModel, remediation: 'nonoverlapping-complexity/v1' },
49
+ coverage: coverage === undefined ? null : { inputDigest: digest(coverage.text), pathBase: coverage.sourceRoot,
50
+ merge: 'any-hit', hitCounts: 'sum', lines: 'code-only' },
51
+ ...(securityScanners.length ? { securityScanners } : {}),
52
+ plugins: plugins.map(pluginProvenance),
53
+ operations: results.operationRecords(),
54
+ };
55
+ }
56
+ function pluginProvenance({ id, version, api, tools, kinds, claims, settings, providesLanguages }) {
57
+ return { id, version, api, tools: tools ?? {}, kinds,
58
+ ...(claims === undefined ? {} : { claims }), ...(settings === undefined ? {} : { settings }),
59
+ ...(providesLanguages === undefined ? {} : { providesLanguages }) };
60
+ }
61
+ function inspectionStatus(fileCount, results) {
62
+ if (results.diagnostics.length > 0)
63
+ return 'partial';
64
+ return fileCount === 0 && !results.completedInspection ? 'not-applicable' : 'complete';
65
+ }
66
+ function reportInventory(snapshot, sources, results) {
67
+ const inventory = new Map((snapshot.inventory ?? []).map(({ path, lines, bytes }) => [path, { lines, bytes }]));
68
+ for (const { path, bytes } of snapshot.files) {
69
+ if (!inventory.has(path))
70
+ inventory.set(path, { lines: textLineCount(bytes), bytes: bytes.length });
71
+ }
72
+ return [...inventory].sort(([left], [right]) => comparePaths(left, right)).map(([path, { lines, bytes }]) => {
73
+ const provider = sources.providersByPath.get(path);
74
+ return { path, lines, ...(bytes === undefined ? {} : { bytes }), language: provider?.language(path) ?? languageId(path),
75
+ analysed: results.parsed.has(path) || results.inspected.has(path), ...(provider === undefined ? {} : { provider: provider.key }) };
76
+ });
77
+ }
78
+ //# sourceMappingURL=analysis-report.js.map
@@ -0,0 +1,6 @@
1
+ import type { OperationCacheOptions } from '../core/engine/operation-cache.js';
2
+ import type { CodeStructure } from '../core/model/code-structure.js';
3
+ import type { AnalysisResults } from './analysis-results.js';
4
+ import type { AnalysisSources } from './analysis-sources.js';
5
+ export declare function collectRepositorySyntax(sources: AnalysisSources, results: AnalysisResults, cache?: OperationCacheOptions): Promise<Map<string, CodeStructure>>;
6
+ export declare function inspectRepositories(sources: AnalysisSources, results: AnalysisResults, cache?: OperationCacheOptions): Promise<void>;
@@ -0,0 +1,61 @@
1
+ import { execute } from '../core/engine/execute.js';
2
+ import { plan } from '../core/engine/plan.js';
3
+ import { codeStructures } from '../core/model/code-structure.js';
4
+ import { sourceFiles } from '../core/model/snapshot.js';
5
+ import { isClaimedText } from '../core/model/source.js';
6
+ import { inspectionKeys } from './analysis-sources.js';
7
+ const repositoryInput = new Map([['files', sourceFiles.id]]);
8
+ export async function collectRepositorySyntax(sources, results, cache) {
9
+ const providers = new Map(sources.languages.providers.filter(provider => provider.batch).map(provider => [provider.plugin.id, provider]));
10
+ const facts = new Map();
11
+ for (const { plugin } of sources.repository) {
12
+ const provider = providers.get(plugin.id);
13
+ if (!provider)
14
+ continue;
15
+ const files = sources.sources.filter(source => source.provider === provider).map(({ file }) => file);
16
+ if (!files.length)
17
+ continue;
18
+ const outcomes = await runRepository(plugin, files, [provider.key, ...inspectionKeys(plugin)], results, cache);
19
+ const syntax = outcomes.get(provider.key);
20
+ if (syntax?.state === 'completed' && codeStructures.accepts(syntax.product.value)) {
21
+ collectFacts(facts, syntax.product.value, files, provider.key, results);
22
+ }
23
+ }
24
+ return facts;
25
+ }
26
+ export async function inspectRepositories(sources, results, cache) {
27
+ for (const { plugin, matches } of sources.repository) {
28
+ if (sources.languages.providers.some(provider => provider.batch && provider.plugin.id === plugin.id))
29
+ continue;
30
+ const select = inspectionKeys(plugin);
31
+ if (!select.length)
32
+ continue;
33
+ const files = sources.sources.map(({ file }) => file).filter(file => matches(file.path) && isClaimedText(file.bytes));
34
+ if (files.length)
35
+ await runRepository(plugin, files, select, results, cache);
36
+ }
37
+ }
38
+ async function runRepository(plugin, files, select, results, cache) {
39
+ const tasks = plan({ plugins: [plugin], select, inputs: repositoryInput });
40
+ const outcomes = await execute(tasks, new Map([['files', { contract: sourceFiles.id, value: files }]]), cache);
41
+ const paths = files.map(({ path }) => path);
42
+ for (const task of tasks) {
43
+ results.remember(task);
44
+ results.record(task, outcomes.get(task.key), undefined, paths);
45
+ }
46
+ return outcomes;
47
+ }
48
+ function collectFacts(target, values, files, operation, results) {
49
+ const planned = new Set(files.map(({ path }) => path));
50
+ if (values.some(({ path }) => !planned.has(path))) {
51
+ results.diagnostics.push({ operation, state: 'failed', message: 'Language provider returned a path outside its inputs' });
52
+ return;
53
+ }
54
+ for (const facts of values)
55
+ target.set(facts.path, facts);
56
+ for (const path of planned) {
57
+ if (!target.has(path))
58
+ results.diagnostics.push({ operation, state: 'failed', path, message: 'Language provider returned no structure for this file' });
59
+ }
60
+ }
61
+ //# sourceMappingURL=analysis-repository.js.map
@@ -0,0 +1,38 @@
1
+ import type { Outcome } from '../core/engine/execute.js';
2
+ import type { PlannedOperation } from '../core/engine/plan.js';
3
+ import type { Plugin } from '../core/engine/plugin.js';
4
+ import type { Finding } from '../core/model/finding.js';
5
+ import type { Measurement } from '../core/model/measurement.js';
6
+ import type { Diagnostic } from '../core/model/report.js';
7
+ export declare class AnalysisResults {
8
+ readonly measurements: Measurement[];
9
+ readonly findings: Finding[];
10
+ readonly diagnostics: Diagnostic[];
11
+ readonly parsed: Set<string>;
12
+ readonly inspected: Set<string>;
13
+ completedInspection: boolean;
14
+ private readonly products;
15
+ private readonly scanned;
16
+ private readonly scanOnly;
17
+ private readonly securityOperations;
18
+ private readonly usedPlans;
19
+ constructor(plugins: readonly Plugin[], claimed: readonly Plugin[], oversized: readonly string[]);
20
+ remember(task: PlannedOperation, syntaxProvider?: string): void;
21
+ operationRecords(): readonly ReturnType<typeof operationProvenance>[];
22
+ pluginData(): import("../core/model/plugin-data.js").PluginData | undefined;
23
+ securityScanners(plugins: readonly Plugin[]): {
24
+ name: string;
25
+ version: string;
26
+ }[];
27
+ record(task: PlannedOperation, outcome: Outcome, path?: string, paths?: readonly string[]): void;
28
+ private recordInspection;
29
+ }
30
+ export declare function operationProvenance(task: PlannedOperation, syntaxProvider?: string): {
31
+ key: string;
32
+ inputs: {
33
+ [k: string]: import("../core/engine/plan.js").InputBinding;
34
+ };
35
+ scope?: "repository" | undefined;
36
+ syntaxProvider?: string | undefined;
37
+ };
38
+ export declare function oversizedClaim(path: string): Diagnostic;
@@ -0,0 +1,78 @@
1
+ import { ReportProducts } from '../core/engine/report-products.js';
2
+ import { inspectionKeys } from './analysis-sources.js';
3
+ export class AnalysisResults {
4
+ measurements = [];
5
+ findings = [];
6
+ diagnostics;
7
+ parsed = new Set();
8
+ inspected = new Set();
9
+ completedInspection = false;
10
+ products;
11
+ scanned = new Set();
12
+ scanOnly;
13
+ securityOperations;
14
+ usedPlans = new Map();
15
+ constructor(plugins, claimed, oversized) {
16
+ this.products = new ReportProducts(plugins);
17
+ this.diagnostics = oversized.map(oversizedClaim);
18
+ this.scanOnly = new Set(plugins.filter(plugin => plugin.claims?.scanOnly).flatMap(({ id, operations }) => operations.map(operation => `${id}/${operation.id}`)));
19
+ this.securityOperations = new Map(claimed.filter(plugin => plugin.kinds.includes('security')).flatMap(plugin => inspectionKeys(plugin).map(key => [key, plugin.id])));
20
+ }
21
+ remember(task, syntaxProvider) {
22
+ this.usedPlans.set(JSON.stringify([task.key, [...task.inputs], syntaxProvider]), operationProvenance(task, syntaxProvider));
23
+ }
24
+ operationRecords() {
25
+ return [...this.usedPlans.values()];
26
+ }
27
+ pluginData() {
28
+ return this.products.result();
29
+ }
30
+ securityScanners(plugins) {
31
+ return plugins.filter(plugin => this.scanned.has(plugin.id)).map(({ id, version }) => ({ name: id, version }));
32
+ }
33
+ record(task, outcome, path, paths) {
34
+ if (outcome.state !== 'completed') {
35
+ this.diagnostics.push({ operation: task.key, state: outcome.state, message: outcome.reason,
36
+ ...(path === undefined ? {} : { path }) });
37
+ return;
38
+ }
39
+ try {
40
+ const stored = this.products.record(task, outcome.product, path);
41
+ this.recordInspection(task, outcome.diagnostics ?? [], path, paths);
42
+ if (stored) {
43
+ this.measurements.push(...stored.measurements);
44
+ this.findings.push(...stored.findings);
45
+ }
46
+ }
47
+ catch (error) {
48
+ this.diagnostics.push({ operation: task.key, state: 'failed', path, message: error instanceof Error ? error.message : String(error) });
49
+ }
50
+ }
51
+ recordInspection(task, messages, path, paths) {
52
+ for (const message of messages)
53
+ this.diagnostics.push({ operation: task.key, state: 'partial', message,
54
+ ...(path === undefined ? {} : { path }) });
55
+ const scanner = this.securityOperations.get(task.key);
56
+ if (scanner)
57
+ this.scanned.add(scanner);
58
+ if (task.operation.role !== 'inspection' || (path === undefined && !paths?.length))
59
+ return;
60
+ this.completedInspection = true;
61
+ if (this.scanOnly.has(task.key))
62
+ return;
63
+ if (path !== undefined)
64
+ this.inspected.add(path);
65
+ else
66
+ for (const file of paths ?? [])
67
+ this.inspected.add(file);
68
+ }
69
+ }
70
+ export function operationProvenance(task, syntaxProvider) {
71
+ return { key: task.key, inputs: Object.fromEntries(task.inputs),
72
+ ...(task.operation.scope === 'repository' ? { scope: task.operation.scope } : {}),
73
+ ...(syntaxProvider === undefined ? {} : { syntaxProvider }) };
74
+ }
75
+ export function oversizedClaim(path) {
76
+ return { operation: 'source/claims', state: 'partial', path, message: 'Plugin inspection skipped a file larger than 1 MiB' };
77
+ }
78
+ //# sourceMappingURL=analysis-results.js.map
@@ -0,0 +1,73 @@
1
+ import type { Operation, Plugin } from '../core/engine/plugin.js';
2
+ import type { SourceFile, SourceSnapshot } from '../core/model/source.js';
3
+ import type { LanguageProvider } from './languages.js';
4
+ export declare const structuralInspections: {
5
+ id: string;
6
+ version: string;
7
+ api: string;
8
+ operations: readonly Operation[];
9
+ rules?: readonly import("../core/engine/plugin.js").RuleDescriptor[];
10
+ config?: import("../core/engine/plugin.js").PluginConfigSchema;
11
+ settings?: import("../core/model/plugin-data.js").JsonValue;
12
+ kinds: readonly import("../core/engine/plugin.js").PluginKind[];
13
+ claims?: import("../core/engine/plugin.js").FileClaims;
14
+ providesLanguages?: readonly import("../plugin.js").ProvidedLanguage[];
15
+ produces: readonly import("../core/engine/plugin.js").ProductDeclaration[];
16
+ tools: {
17
+ '@babel/types': string;
18
+ };
19
+ }[];
20
+ export declare const defaultProvider: LanguageProvider;
21
+ export interface SelectedSource {
22
+ readonly file: SourceFile;
23
+ readonly provider: LanguageProvider | undefined;
24
+ }
25
+ export interface ClaimedPlugin {
26
+ readonly plugin: Plugin;
27
+ readonly matches: (path: string) => boolean;
28
+ }
29
+ export declare function inspectionFileMatcher(additional: readonly Plugin[], languages?: {
30
+ select(path: string): LanguageProvider | undefined;
31
+ isSource(path: string): boolean;
32
+ id(path: string): string;
33
+ readonly extensions: readonly string[];
34
+ readonly globs: readonly string[];
35
+ readonly catalog: readonly import("../plugin.js").LanguageDisplay[];
36
+ readonly providers: readonly LanguageProvider[];
37
+ }): (path: string) => boolean;
38
+ export declare function selectAnalysisSources(snapshot: SourceSnapshot, additional: readonly Plugin[], withCoverage: boolean): {
39
+ languages: {
40
+ select(path: string): LanguageProvider | undefined;
41
+ isSource(path: string): boolean;
42
+ id(path: string): string;
43
+ readonly extensions: readonly string[];
44
+ readonly globs: readonly string[];
45
+ readonly catalog: readonly import("../plugin.js").LanguageDisplay[];
46
+ readonly providers: readonly LanguageProvider[];
47
+ };
48
+ sources: SelectedSource[];
49
+ sourceFiles: SourceFile[];
50
+ providersByPath: Map<string, LanguageProvider>;
51
+ plugins: (Plugin | {
52
+ id: string;
53
+ version: string;
54
+ api: string;
55
+ operations: readonly Operation[];
56
+ rules?: readonly import("../core/engine/plugin.js").RuleDescriptor[];
57
+ config?: import("../core/engine/plugin.js").PluginConfigSchema;
58
+ settings?: import("../core/model/plugin-data.js").JsonValue;
59
+ kinds: readonly import("../core/engine/plugin.js").PluginKind[];
60
+ claims?: import("../core/engine/plugin.js").FileClaims;
61
+ providesLanguages?: readonly import("../plugin.js").ProvidedLanguage[];
62
+ produces: readonly import("../core/engine/plugin.js").ProductDeclaration[];
63
+ tools: {
64
+ '@babel/types': string;
65
+ };
66
+ })[];
67
+ claimedPlugins: Plugin[];
68
+ perFile: ClaimedPlugin[];
69
+ repository: ClaimedPlugin[];
70
+ };
71
+ export type AnalysisSources = ReturnType<typeof selectAnalysisSources>;
72
+ export declare function pluginForScope(plugin: Plugin, scope: NonNullable<Operation['scope']>): Plugin;
73
+ export declare function inspectionKeys(plugin: Plugin): string[];
@@ -0,0 +1,47 @@
1
+ import { plan } from '../core/engine/plan.js';
2
+ import { coverage } from '../plugins/coverage/coverage.js';
3
+ import { duplication } from '../plugins/duplication/duplication.js';
4
+ import { babelProvider, babelTypes } from '../plugins/language-js/babel-provider.js';
5
+ import { maintainability } from '../plugins/maintainability/maintainability.js';
6
+ import { structure } from '../plugins/structure/structure.js';
7
+ import { claimMatcher, defaultLanguages, languageRegistry } from './languages.js';
8
+ import { securityPlugins } from './security-plugins.js';
9
+ export const structuralInspections = [{ ...structure, tools: babelTypes }, { ...maintainability, tools: babelTypes }];
10
+ export const defaultProvider = defaultLanguages.providers[0];
11
+ export function inspectionFileMatcher(additional, languages = defaultLanguages) {
12
+ const matches = [...securityPlugins, ...additional].filter(plugin => !plugin.kinds.includes('language'))
13
+ .map(plugin => claimMatcher(plugin.claims, languages.id));
14
+ return path => matches.some(match => match(path));
15
+ }
16
+ export function selectAnalysisSources(snapshot, additional, withCoverage) {
17
+ const languages = additional.length ? languageRegistry(additional) : defaultLanguages;
18
+ const sources = snapshot.files.map(file => ({ file, provider: languages.select(file.path) }));
19
+ const providersByPath = new Map(sources.flatMap(({ file, provider }) => provider ? [[file.path, provider]] : []));
20
+ const sourceFiles = sources.flatMap(({ file, provider }) => provider ? [file] : []);
21
+ const claimedPlugins = [...securityPlugins.filter(plugin => !additional.includes(plugin)), ...additional];
22
+ const plugins = [babelProvider, ...structuralInspections, duplication, ...(withCoverage ? [coverage] : []), ...claimedPlugins];
23
+ validateRegistration(plugins, additional, withCoverage);
24
+ const claims = claimedPlugins.map(plugin => ({ plugin, matches: plugin.kinds.includes('language')
25
+ ? path => providersByPath.get(path)?.plugin.id === plugin.id : claimMatcher(plugin.claims, languages.id) }));
26
+ return { languages, sources, sourceFiles, providersByPath, plugins, claimedPlugins,
27
+ perFile: claimsForScope(claims, 'file'), repository: claimsForScope(claims, 'repository') };
28
+ }
29
+ function validateRegistration(plugins, additional, withCoverage) {
30
+ if (additional.length)
31
+ plan({ plugins, select: [], inputs: new Map() });
32
+ if (!withCoverage && additional.some(plugin => plugin.id === coverage.id)) {
33
+ throw new Error('An additional plugin uses a built-in plugin ID');
34
+ }
35
+ }
36
+ function claimsForScope(claims, scope) {
37
+ return claims.map(({ plugin, matches }) => ({ plugin: pluginForScope(plugin, scope), matches }))
38
+ .filter(({ plugin }) => plugin.operations.length > 0);
39
+ }
40
+ export function pluginForScope(plugin, scope) {
41
+ const operations = plugin.operations.filter(operation => (operation.scope ?? 'file') === scope);
42
+ return operations.length === plugin.operations.length ? plugin : { ...plugin, operations };
43
+ }
44
+ export function inspectionKeys(plugin) {
45
+ return plugin.operations.filter(operation => operation.role === 'inspection').map(operation => `${plugin.id}/${operation.id}`);
46
+ }
47
+ //# sourceMappingURL=analysis-sources.js.map
@@ -1,5 +1,6 @@
1
+ import type { OperationCacheOptions } from '../core/engine/operation-cache.js';
1
2
  import type { Plugin } from '../core/engine/plugin.js';
2
3
  import type { Report } from '../core/model/report.js';
3
4
  import type { AnalysisInput } from '../core/usecases/inspect.js';
4
- export declare function claimsNativeFile(path: string): boolean;
5
- export declare function analyzeSnapshot({ snapshot, excludedOutput, excludedPaths, coverage: inputCoverage }: AnalysisInput, additional?: readonly Plugin[]): Promise<Report>;
5
+ export { inspectionFileMatcher } from './analysis-sources.js';
6
+ export declare function analyzeSnapshot(input: AnalysisInput, additional?: readonly Plugin[], cache?: OperationCacheOptions): Promise<Report>;