repometry 0.0.0-dev.0 → 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 (281) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -1
  3. package/package.json +48 -7
  4. package/target/main/resources/report/json/compact-json-v1.schema.json +24 -0
  5. package/target/main/resources/report/json/comparison-v1.schema.json +65 -0
  6. package/target/main/resources/report/json/config-v1.schema.json +34 -0
  7. package/target/main/resources/report/json/diff-coverage-v1.schema.json +55 -0
  8. package/target/main/resources/report/json/file-metrics-v1.schema.json +134 -0
  9. package/target/main/resources/report/json/inspection-context-v1.schema.json +172 -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/public-history-v1.schema.json +50 -0
  13. package/target/main/resources/report/json/pull-review-v1.schema.json +97 -0
  14. package/target/main/resources/report/json/quality-history-v1.schema.json +51 -0
  15. package/target/main/resources/report/json/report-v1.schema.json +65 -0
  16. package/target/main/resources/report/json/report-v2.schema.json +238 -0
  17. package/target/main/resources/report/json/repository-summary-v1.schema.json +181 -0
  18. package/target/main/resources/report/json/viewer-details-v1.schema.json +343 -0
  19. package/target/main/resources/report/json/viewer-inspection-v1.schema.json +13 -0
  20. package/target/main/resources/viewer/files.css +578 -0
  21. package/target/main/resources/viewer/index.html +130 -0
  22. package/target/main/resources/viewer/projects.html +52 -0
  23. package/target/main/resources/viewer/styles.css +586 -0
  24. package/target/main/resources/viewer/viewer-pulls.css +64 -0
  25. package/target/main/ts/api/gh/github-pr-comment.d.ts +4 -0
  26. package/target/main/ts/api/gh/github-pr-comment.js +107 -0
  27. package/target/main/ts/api/gh/github.d.ts +6 -0
  28. package/target/main/ts/api/gh/github.js +91 -0
  29. package/target/main/ts/api/git/blob-batch.d.ts +10 -0
  30. package/target/main/ts/api/git/blob-batch.js +105 -0
  31. package/target/main/ts/api/git/changes.d.ts +22 -0
  32. package/target/main/ts/api/git/changes.js +107 -0
  33. package/target/main/ts/api/git/commit-metadata.d.ts +3 -0
  34. package/target/main/ts/api/git/commit-metadata.js +54 -0
  35. package/target/main/ts/api/git/git-churn.d.ts +9 -0
  36. package/target/main/ts/api/git/git-churn.js +70 -0
  37. package/target/main/ts/api/git/git-reader.d.ts +16 -0
  38. package/target/main/ts/api/git/git-reader.js +73 -0
  39. package/target/main/ts/api/git/git.d.ts +21 -0
  40. package/target/main/ts/api/git/git.js +152 -0
  41. package/target/main/ts/api/git/inspection-source.d.ts +15 -0
  42. package/target/main/ts/api/git/inspection-source.js +30 -0
  43. package/target/main/ts/api/git/local-sources.d.ts +5 -0
  44. package/target/main/ts/api/git/local-sources.js +46 -0
  45. package/target/main/ts/api/git/local.d.ts +3 -0
  46. package/target/main/ts/api/git/local.js +35 -0
  47. package/target/main/ts/api/git/metabranch-worktree.d.ts +1 -0
  48. package/target/main/ts/api/git/metabranch-worktree.js +34 -0
  49. package/target/main/ts/api/git/source-cache.d.ts +3 -0
  50. package/target/main/ts/api/git/source-cache.js +56 -0
  51. package/target/main/ts/api/import/finding-import.d.ts +9 -0
  52. package/target/main/ts/api/import/finding-import.js +226 -0
  53. package/target/main/ts/api/import/lcov-files.d.ts +5 -0
  54. package/target/main/ts/api/import/lcov-files.js +13 -0
  55. package/target/main/ts/api/import/profile-file.d.ts +4 -0
  56. package/target/main/ts/api/import/profile-file.js +16 -0
  57. package/target/main/ts/api/worker/remote-executor.d.ts +2 -0
  58. package/target/main/ts/api/worker/remote-executor.js +45 -0
  59. package/target/main/ts/api/worker/worker-protocol.d.ts +7 -0
  60. package/target/main/ts/api/worker/worker-protocol.js +101 -0
  61. package/target/main/ts/api/worker/worker.d.ts +5 -0
  62. package/target/main/ts/api/worker/worker.js +85 -0
  63. package/target/main/ts/cli/arguments.d.ts +28 -0
  64. package/target/main/ts/cli/arguments.js +110 -0
  65. package/target/main/ts/cli/config.d.ts +14 -0
  66. package/target/main/ts/cli/config.js +60 -0
  67. package/target/main/ts/cli/github-pr-comment.d.ts +1 -0
  68. package/target/main/ts/cli/github-pr-comment.js +12 -0
  69. package/target/main/ts/cli/imports.d.ts +7 -0
  70. package/target/main/ts/cli/imports.js +29 -0
  71. package/target/main/ts/cli/main.d.ts +2 -0
  72. package/target/main/ts/cli/main.js +343 -284
  73. package/target/main/ts/cli/reporting.d.ts +18 -0
  74. package/target/main/ts/cli/reporting.js +108 -0
  75. package/target/main/ts/cli/revisions.d.ts +6 -0
  76. package/target/main/ts/cli/revisions.js +15 -0
  77. package/target/main/ts/cli/store.d.ts +13 -0
  78. package/target/main/ts/cli/store.js +38 -0
  79. package/target/main/ts/compose/analyze-snapshot.d.ts +4 -0
  80. package/target/main/ts/compose/analyze-snapshot.js +163 -0
  81. package/target/main/ts/compose/attach-churn.d.ts +2 -0
  82. package/target/main/ts/compose/attach-churn.js +37 -0
  83. package/target/main/ts/compose/diff-coverage.d.ts +20 -0
  84. package/target/main/ts/compose/diff-coverage.js +56 -0
  85. package/target/main/ts/compose/inspect.d.ts +23 -0
  86. package/target/main/ts/compose/inspect.js +44 -0
  87. package/target/main/ts/compose/plugin-list.d.ts +6 -0
  88. package/target/main/ts/compose/plugin-list.js +9 -0
  89. package/target/main/ts/compose/prepare-metabranch.d.ts +9 -0
  90. package/target/main/ts/compose/prepare-metabranch.js +16 -0
  91. package/target/main/ts/compose/review.d.ts +16 -0
  92. package/target/main/ts/compose/review.js +38 -0
  93. package/target/main/ts/compose/sources.d.ts +3 -0
  94. package/target/main/ts/compose/sources.js +29 -0
  95. package/target/main/ts/core/engine/execute.d.ts +10 -0
  96. package/target/main/ts/core/engine/execute.js +49 -0
  97. package/target/main/ts/core/engine/manifest.d.ts +4 -0
  98. package/target/main/ts/core/engine/manifest.js +104 -0
  99. package/target/main/ts/core/engine/plan.d.ts +22 -0
  100. package/target/main/ts/core/engine/plan.js +106 -0
  101. package/target/main/ts/core/engine/plugin.d.ts +59 -0
  102. package/target/main/ts/core/engine/plugin.js +4 -0
  103. package/target/main/ts/core/engine/report-products.d.ts +16 -0
  104. package/target/main/ts/core/engine/report-products.js +85 -0
  105. package/target/main/ts/core/model/changes.d.ts +8 -0
  106. package/target/main/ts/core/model/changes.js +1 -0
  107. package/target/main/ts/core/model/churn.d.ts +11 -0
  108. package/target/main/ts/core/model/churn.js +5 -0
  109. package/target/main/ts/core/model/clone-source.d.ts +16 -0
  110. package/target/main/ts/core/model/clone-source.js +14 -0
  111. package/target/main/ts/core/model/code-structure.d.ts +30 -0
  112. package/target/main/ts/core/model/code-structure.js +31 -0
  113. package/target/main/ts/core/model/comparison.d.ts +24 -0
  114. package/target/main/ts/core/model/comparison.js +1 -0
  115. package/target/main/ts/core/model/diff-coverage.d.ts +23 -0
  116. package/target/main/ts/core/model/diff-coverage.js +1 -0
  117. package/target/main/ts/core/model/finding-ignore.d.ts +8 -0
  118. package/target/main/ts/core/model/finding-ignore.js +35 -0
  119. package/target/main/ts/core/model/finding.d.ts +28 -0
  120. package/target/main/ts/core/model/finding.js +29 -0
  121. package/target/main/ts/core/model/ignore-rule.d.ts +11 -0
  122. package/target/main/ts/core/model/ignore-rule.js +1 -0
  123. package/target/main/ts/core/model/measurement.d.ts +27 -0
  124. package/target/main/ts/core/model/measurement.js +24 -0
  125. package/target/main/ts/core/model/metric-descriptor.d.ts +17 -0
  126. package/target/main/ts/core/model/metric-descriptor.js +1 -0
  127. package/target/main/ts/core/model/plugin-data.d.ts +25 -0
  128. package/target/main/ts/core/model/plugin-data.js +1 -0
  129. package/target/main/ts/core/model/pull-review.d.ts +48 -0
  130. package/target/main/ts/core/model/pull-review.js +1 -0
  131. package/target/main/ts/core/model/quality-summary.d.ts +42 -0
  132. package/target/main/ts/core/model/quality-summary.js +64 -0
  133. package/target/main/ts/core/model/report.d.ts +32 -0
  134. package/target/main/ts/core/model/report.js +5 -0
  135. package/target/main/ts/core/model/scanner-import.d.ts +39 -0
  136. package/target/main/ts/core/model/scanner-import.js +28 -0
  137. package/target/main/ts/core/model/snapshot.d.ts +15 -0
  138. package/target/main/ts/core/model/snapshot.js +50 -0
  139. package/target/main/ts/core/model/source-locator.d.ts +7 -0
  140. package/target/main/ts/core/model/source-locator.js +1 -0
  141. package/target/main/ts/core/model/source.d.ts +23 -0
  142. package/target/main/ts/core/model/source.js +1 -0
  143. package/target/main/ts/core/ports/report.d.ts +9 -0
  144. package/target/main/ts/core/ports/report.js +1 -0
  145. package/target/main/ts/core/ports/source-provider.d.ts +14 -0
  146. package/target/main/ts/core/ports/source-provider.js +4 -0
  147. package/target/main/ts/core/profile/exclusions.d.ts +11 -0
  148. package/target/main/ts/core/profile/exclusions.js +57 -0
  149. package/target/main/ts/core/profile/maintainability.d.ts +31 -0
  150. package/target/main/ts/core/profile/maintainability.js +9 -0
  151. package/target/main/ts/core/profile/profile.d.ts +4 -0
  152. package/target/main/ts/core/profile/profile.js +10 -0
  153. package/target/main/ts/core/usecases/compare.d.ts +6 -0
  154. package/target/main/ts/core/usecases/compare.js +145 -0
  155. package/target/main/ts/core/usecases/diff-coverage-policy.d.ts +6 -0
  156. package/target/main/ts/core/usecases/diff-coverage-policy.js +10 -0
  157. package/target/main/ts/core/usecases/diff-coverage.d.ts +40 -0
  158. package/target/main/ts/core/usecases/diff-coverage.js +15 -0
  159. package/target/main/ts/core/usecases/inspect.d.ts +38 -0
  160. package/target/main/ts/core/usecases/inspect.js +41 -0
  161. package/target/main/ts/core/usecases/review.d.ts +31 -0
  162. package/target/main/ts/core/usecases/review.js +128 -0
  163. package/target/main/ts/index.d.ts +35 -0
  164. package/target/main/ts/index.js +17 -13
  165. package/target/main/ts/plugin.d.ts +14 -0
  166. package/target/main/ts/plugin.js +5 -0
  167. package/target/main/ts/plugins/coverage/coverage.d.ts +23 -0
  168. package/target/main/ts/plugins/coverage/coverage.js +120 -0
  169. package/target/main/ts/plugins/coverage/diff-coverage.d.ts +7 -0
  170. package/target/main/ts/plugins/coverage/diff-coverage.js +89 -0
  171. package/target/main/ts/plugins/duplication/duplication.d.ts +4 -0
  172. package/target/main/ts/plugins/duplication/duplication.js +93 -0
  173. package/target/main/ts/plugins/language-js/babel-provider.d.ts +10 -0
  174. package/target/main/ts/plugins/language-js/babel-provider.js +46 -0
  175. package/target/main/ts/plugins/language-js/clone-candidates.d.ts +3 -0
  176. package/target/main/ts/plugins/language-js/clone-candidates.js +64 -0
  177. package/target/main/ts/plugins/language-js/code-lines.d.ts +6 -0
  178. package/target/main/ts/plugins/language-js/code-lines.js +35 -0
  179. package/target/main/ts/plugins/language-js/function-facts.d.ts +8 -0
  180. package/target/main/ts/plugins/language-js/function-facts.js +60 -0
  181. package/target/main/ts/plugins/language-js/structural-observations.d.ts +8 -0
  182. package/target/main/ts/plugins/language-js/structural-observations.js +79 -0
  183. package/target/main/ts/plugins/maintainability/maintainability.d.ts +9 -0
  184. package/target/main/ts/plugins/maintainability/maintainability.js +42 -0
  185. package/target/main/ts/plugins/maintainability/structural-smells.d.ts +3 -0
  186. package/target/main/ts/plugins/maintainability/structural-smells.js +15 -0
  187. package/target/main/ts/plugins/source/forges.d.ts +4 -0
  188. package/target/main/ts/plugins/source/forges.js +79 -0
  189. package/target/main/ts/plugins/structure/structure.d.ts +2 -0
  190. package/target/main/ts/plugins/structure/structure.js +37 -0
  191. package/target/main/ts/report/html/app/viewer-access.d.ts +19 -0
  192. package/target/main/ts/report/html/app/viewer-access.js +25 -0
  193. package/target/main/ts/report/html/app/viewer-chart.d.ts +101 -0
  194. package/target/main/ts/report/html/app/viewer-chart.js +711 -0
  195. package/target/main/ts/report/html/app/viewer-commits.d.ts +36 -0
  196. package/target/main/ts/report/html/app/viewer-commits.js +280 -0
  197. package/target/main/ts/report/html/app/viewer-data.d.ts +23 -0
  198. package/target/main/ts/report/html/app/viewer-data.js +105 -0
  199. package/target/main/ts/report/html/app/viewer-files.d.ts +117 -0
  200. package/target/main/ts/report/html/app/viewer-files.js +2087 -0
  201. package/target/main/ts/report/html/app/viewer-filter.d.ts +113 -0
  202. package/target/main/ts/report/html/app/viewer-filter.js +492 -0
  203. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +68 -0
  204. package/target/main/ts/report/html/app/viewer-metric-registry.js +206 -0
  205. package/target/main/ts/report/html/app/viewer-metrics.d.ts +44 -0
  206. package/target/main/ts/report/html/app/viewer-metrics.js +172 -0
  207. package/target/main/ts/report/html/app/viewer-profile.d.ts +17 -0
  208. package/target/main/ts/report/html/app/viewer-profile.js +401 -0
  209. package/target/main/ts/report/html/app/viewer-projects.d.ts +1 -0
  210. package/target/main/ts/report/html/app/viewer-projects.js +90 -0
  211. package/target/main/ts/report/html/app/viewer-pulls.d.ts +3 -0
  212. package/target/main/ts/report/html/app/viewer-pulls.js +242 -0
  213. package/target/main/ts/report/html/app/viewer-source.d.ts +75 -0
  214. package/target/main/ts/report/html/app/viewer-source.js +313 -0
  215. package/target/main/ts/report/html/app/viewer-trends.d.ts +74 -0
  216. package/target/main/ts/report/html/app/viewer-trends.js +413 -0
  217. package/target/main/ts/report/html/app/viewer.d.ts +1 -0
  218. package/target/main/ts/report/html/app/viewer.js +794 -0
  219. package/target/main/ts/report/html/site/badges.d.ts +14 -0
  220. package/target/main/ts/report/html/site/badges.js +39 -0
  221. package/target/main/ts/report/html/site/export-site.d.ts +21 -0
  222. package/target/main/ts/report/html/site/export-site.js +157 -0
  223. package/target/main/ts/report/html/site/exported-server.d.ts +6 -0
  224. package/target/main/ts/report/html/site/exported-server.js +70 -0
  225. package/target/main/ts/report/html/site/local-server.d.ts +7 -0
  226. package/target/main/ts/report/html/site/local-server.js +64 -0
  227. package/target/main/ts/report/html/site/projects.d.ts +3 -0
  228. package/target/main/ts/report/html/site/projects.js +79 -0
  229. package/target/main/ts/report/html/site/server.d.ts +4 -0
  230. package/target/main/ts/report/html/site/server.js +64 -0
  231. package/target/main/ts/report/html/site/source-route.d.ts +6 -0
  232. package/target/main/ts/report/html/site/source-route.js +22 -0
  233. package/target/main/ts/report/json/projections/commit-summary.d.ts +11 -0
  234. package/target/main/ts/report/json/projections/commit-summary.js +118 -0
  235. package/target/main/ts/report/json/projections/components.d.ts +4 -0
  236. package/target/main/ts/report/json/projections/components.js +29 -0
  237. package/target/main/ts/report/json/projections/file-metrics.d.ts +5 -0
  238. package/target/main/ts/report/json/projections/file-metrics.js +243 -0
  239. package/target/main/ts/report/json/projections/inspection-context.d.ts +6 -0
  240. package/target/main/ts/report/json/projections/inspection-context.js +92 -0
  241. package/target/main/ts/report/json/projections/inspection-details.d.ts +11 -0
  242. package/target/main/ts/report/json/projections/inspection-details.js +69 -0
  243. package/target/main/ts/report/json/projections/metric-values.d.ts +7 -0
  244. package/target/main/ts/report/json/projections/metric-values.js +57 -0
  245. package/target/main/ts/report/json/projections/public-history.d.ts +4 -0
  246. package/target/main/ts/report/json/projections/public-history.js +16 -0
  247. package/target/main/ts/report/json/store/components.d.ts +2 -0
  248. package/target/main/ts/report/json/store/components.js +31 -0
  249. package/target/main/ts/report/json/store/local-store.d.ts +13 -0
  250. package/target/main/ts/report/json/store/local-store.js +179 -0
  251. package/target/main/ts/report/json/store/pull-review-store.d.ts +3 -0
  252. package/target/main/ts/report/json/store/pull-review-store.js +51 -0
  253. package/target/main/ts/report/json/validation/metabranch.d.ts +4 -0
  254. package/target/main/ts/report/json/validation/metabranch.js +7 -0
  255. package/target/main/ts/report/json/validation/report.d.ts +15 -0
  256. package/target/main/ts/report/json/validation/report.js +64 -0
  257. package/target/main/ts/report/json/validation/summary-validation.d.ts +4 -0
  258. package/target/main/ts/report/json/validation/summary-validation.js +27 -0
  259. package/target/main/ts/report/json/wire/compact-json.d.ts +11 -0
  260. package/target/main/ts/report/json/wire/compact-json.js +76 -0
  261. package/target/main/ts/report/json/wire/component-model.d.ts +9 -0
  262. package/target/main/ts/report/json/wire/component-model.js +1 -0
  263. package/target/main/ts/report/json/wire/domain-types.d.ts +2 -0
  264. package/target/main/ts/report/json/wire/domain-types.js +1 -0
  265. package/target/main/ts/report/json/wire/file-metrics-model.d.ts +77 -0
  266. package/target/main/ts/report/json/wire/file-metrics-model.js +1 -0
  267. package/target/main/ts/report/json/wire/inspection-context-model.d.ts +26 -0
  268. package/target/main/ts/report/json/wire/inspection-context-model.js +1 -0
  269. package/target/main/ts/report/json/wire/inspection-details-model.d.ts +82 -0
  270. package/target/main/ts/report/json/wire/inspection-details-model.js +1 -0
  271. package/target/main/ts/report/json/wire/project-model.d.ts +7 -0
  272. package/target/main/ts/report/json/wire/project-model.js +1 -0
  273. package/target/main/ts/report/json/wire/public-history-model.d.ts +42 -0
  274. package/target/main/ts/report/json/wire/public-history-model.js +6 -0
  275. package/target/main/ts/report/json/wire/pull-review-model.d.ts +7 -0
  276. package/target/main/ts/report/json/wire/pull-review-model.js +1 -0
  277. package/target/main/ts/report/json/wire/summary-model.d.ts +45 -0
  278. package/target/main/ts/report/json/wire/summary-model.js +1 -0
  279. package/target/main/ts/report.d.ts +11 -0
  280. package/target/main/ts/report.js +5 -0
  281. package/index.js +0 -1
@@ -0,0 +1,31 @@
1
+ import { isRecord } from '../engine/plugin.js';
2
+ import { isCloneSource } from './clone-source.js';
3
+ export const structuralCheckIds = [
4
+ 'function-parameters', 'return-statements', 'boolean-logic', 'nested-control-flow',
5
+ 'function-complexity', 'file-complexity',
6
+ ];
7
+ const checkIds = new Set(structuralCheckIds);
8
+ function isCount(value) {
9
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
10
+ }
11
+ function isPosition(value) {
12
+ return value === undefined || (isCount(value) && value > 0);
13
+ }
14
+ function isFunctionComplexity(value) {
15
+ return isRecord(value) && typeof value.name === 'string' && isCount(value.value)
16
+ && isPosition(value.line) && isPosition(value.column);
17
+ }
18
+ function isObservation(value) {
19
+ return isRecord(value) && typeof value.rule === 'string' && checkIds.has(value.rule)
20
+ && typeof value.label === 'string' && isCount(value.value) && isPosition(value.line) && isPosition(value.endLine);
21
+ }
22
+ export const codeStructure = {
23
+ id: 'repometry.code-structure/v1',
24
+ accepts: (value) => isRecord(value)
25
+ && typeof value.path === 'string' && isCount(value.lines) && isCount(value.functions) && isCount(value.classes)
26
+ && isCount(value.cognitiveComplexity) && isCount(value.commentLines)
27
+ && Array.isArray(value.cyclomaticFunctions) && value.cyclomaticFunctions.every(isFunctionComplexity)
28
+ && Array.isArray(value.cognitiveFunctions) && value.cognitiveFunctions.every(isFunctionComplexity)
29
+ && Array.isArray(value.observations) && value.observations.every(isObservation)
30
+ && isCloneSource(value.clones) && value.clones.path === value.path,
31
+ };
@@ -0,0 +1,24 @@
1
+ import type { Report } from './report.js';
2
+ export declare const comparisonSchema = "urn:repometry:schema:comparison:1";
3
+ export interface Observation {
4
+ readonly status: 'complete' | 'partial' | 'not-applicable' | 'unavailable';
5
+ readonly value: number | null;
6
+ readonly covered?: number;
7
+ readonly total?: number;
8
+ }
9
+ export interface MetricComparison {
10
+ readonly definition: string;
11
+ readonly unit: 'count' | 'percent';
12
+ readonly baseline: Observation;
13
+ readonly current: Observation;
14
+ readonly status: 'comparable' | 'incompatible' | 'unavailable';
15
+ readonly reason: 'observations-unavailable' | 'source-scope-unknown' | 'source-scope-changed' | 'method-unknown' | 'method-changed' | null;
16
+ readonly delta: number | null;
17
+ }
18
+ export type ComparisonSubject = Pick<Report, 'subject' | 'generatedAt' | 'status' | 'scope'>;
19
+ export interface InspectionComparison {
20
+ readonly schema: typeof comparisonSchema;
21
+ readonly baseline: ComparisonSubject;
22
+ readonly current: ComparisonSubject;
23
+ readonly metrics: Readonly<Record<'physicalLines' | 'functions' | 'maxCyclomaticComplexity' | 'lineCoverage', MetricComparison>>;
24
+ }
@@ -0,0 +1 @@
1
+ export const comparisonSchema = 'urn:repometry:schema:comparison:1';
@@ -0,0 +1,23 @@
1
+ export interface FileCoverage {
2
+ readonly path: string;
3
+ readonly addedLines: number;
4
+ readonly covered: number | null;
5
+ readonly total: number | null;
6
+ }
7
+ export interface DiffCoverage {
8
+ readonly status: 'complete' | 'partial' | 'not-applicable';
9
+ readonly covered: number;
10
+ readonly total: number;
11
+ readonly percent: number | null;
12
+ readonly files: readonly FileCoverage[];
13
+ readonly gaps: readonly {
14
+ readonly path: string;
15
+ readonly reason: string;
16
+ }[];
17
+ }
18
+ export interface DiffCoverageResult extends DiffCoverage {
19
+ readonly uncovered: readonly {
20
+ readonly path: string;
21
+ readonly lines: readonly number[];
22
+ }[];
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { Finding } from './finding.js';
2
+ import type { FindingIgnoreRule, IgnoredFinding } from './ignore-rule.js';
3
+ export type { FindingIgnoreRule, IgnoredFinding } from './ignore-rule.js';
4
+ export declare function normalizeFindingIgnore(value: unknown): readonly FindingIgnoreRule[];
5
+ export declare function partitionFindings(items: readonly Finding[], ignore: readonly FindingIgnoreRule[]): {
6
+ findings: readonly Finding[];
7
+ ignoredFindings: readonly IgnoredFinding[];
8
+ };
@@ -0,0 +1,35 @@
1
+ import { isRecord } from '../engine/plugin.js';
2
+ import { exclusionMatcher, normalizeExclusions } from '../profile/exclusions.js';
3
+ const fields = new Set(['tool', 'rule', 'path', 'reason']);
4
+ export function normalizeFindingIgnore(value) {
5
+ if (!Array.isArray(value))
6
+ throw new Error('Profile ignore must be an array of finding rules');
7
+ return value.map((item) => {
8
+ if (!isRecord(item) || Object.entries(item).some(([key, value]) => !fields.has(key) || typeof value !== 'string' || value.trim() === '' || /[\0\r\n]/.test(value))) {
9
+ throw new Error('Finding ignore rules accept tool, rule, path and reason strings');
10
+ }
11
+ const { tool, rule, path, reason } = item;
12
+ if (tool === undefined && rule === undefined && path === undefined) {
13
+ throw new Error('Choose at least one of tool, rule or path for a finding ignore rule');
14
+ }
15
+ return { ...(tool !== undefined && { tool }), ...(rule !== undefined && { rule }),
16
+ ...(path !== undefined && { path: normalizeExclusions([path])[0] }), ...(reason !== undefined && { reason }) };
17
+ });
18
+ }
19
+ export function partitionFindings(items, ignore) {
20
+ const findings = [];
21
+ const ignoredFindings = [];
22
+ const matches = ignore.map(({ tool, rule, path }) => {
23
+ const matchesPath = path === undefined ? undefined : exclusionMatcher([path]);
24
+ return (item) => (tool === undefined || tool === item.tool) && (rule === undefined || rule === item.rule)
25
+ && (matchesPath === undefined || (item.path !== undefined && matchesPath(item.path)));
26
+ });
27
+ for (const finding of items) {
28
+ const matchedRule = matches.findIndex(match => match(finding));
29
+ if (matchedRule < 0)
30
+ findings.push(finding);
31
+ else
32
+ ignoredFindings.push({ finding, matchedRule });
33
+ }
34
+ return { findings, ignoredFindings };
35
+ }
@@ -0,0 +1,28 @@
1
+ import type { DataContract } from '../engine/plugin.js';
2
+ import type { Measurement } from './measurement.js';
3
+ export declare const findingCategories: readonly ['structure', 'duplication', 'lint', 'security', 'dependency', 'secret', 'infrastructure'];
4
+ export declare const findingLevels: readonly ['low', 'medium', 'high', 'unknown'];
5
+ export interface FindingLocation {
6
+ readonly path: string;
7
+ readonly line: number;
8
+ readonly endLine: number;
9
+ }
10
+ export interface Finding {
11
+ readonly tool: string;
12
+ readonly rule: string;
13
+ readonly category: typeof findingCategories[number];
14
+ readonly level: typeof findingLevels[number];
15
+ readonly message: string;
16
+ readonly path?: string;
17
+ readonly line?: number;
18
+ readonly endLine?: number;
19
+ readonly effortMinutes?: number;
20
+ readonly related?: readonly FindingLocation[];
21
+ }
22
+ export declare function isSensitiveFinding(category: Finding['category']): boolean;
23
+ export declare function isFinding(value: unknown): value is Finding;
24
+ export interface FindingResult {
25
+ readonly measurements: readonly Measurement[];
26
+ readonly findings: readonly Finding[];
27
+ }
28
+ export declare const findingResult: DataContract<FindingResult>;
@@ -0,0 +1,29 @@
1
+ import { isRecord } from '../engine/plugin.js';
2
+ import { measurements } from './measurement.js';
3
+ export const findingCategories = ['structure', 'duplication', 'lint', 'security', 'dependency', 'secret', 'infrastructure'];
4
+ export const findingLevels = ['low', 'medium', 'high', 'unknown'];
5
+ export function isSensitiveFinding(category) {
6
+ return category === 'security' || category === 'dependency' || category === 'secret' || category === 'infrastructure';
7
+ }
8
+ function count(value, minimum) {
9
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= minimum;
10
+ }
11
+ function isLocation(value) {
12
+ return isRecord(value) && typeof value.path === 'string' && value.path.length > 0
13
+ && count(value.line, 1) && count(value.endLine, value.line);
14
+ }
15
+ export function isFinding(value) {
16
+ return isRecord(value) && typeof value.tool === 'string' && value.tool.length > 0
17
+ && typeof value.rule === 'string' && value.rule.length > 0 && typeof value.message === 'string' && value.message.length > 0
18
+ && findingCategories.some(category => category === value.category) && findingLevels.some(level => level === value.level)
19
+ && (value.path === undefined || (typeof value.path === 'string' && value.path.length > 0))
20
+ && (value.line === undefined || (value.path !== undefined && count(value.line, 1)))
21
+ && (value.endLine === undefined || (typeof value.line === 'number' && count(value.endLine, value.line)))
22
+ && (value.effortMinutes === undefined || count(value.effortMinutes, 0))
23
+ && (value.related === undefined || (Array.isArray(value.related) && value.related.every(isLocation)));
24
+ }
25
+ export const findingResult = {
26
+ id: 'repometry.findings-and-measurements/v1',
27
+ accepts: (value) => isRecord(value) && measurements.accepts(value.measurements)
28
+ && Array.isArray(value.findings) && value.findings.every(isFinding),
29
+ };
@@ -0,0 +1,11 @@
1
+ import type { Finding } from './finding.js';
2
+ export interface FindingIgnoreRule {
3
+ readonly tool?: string;
4
+ readonly rule?: string;
5
+ readonly path?: string;
6
+ readonly reason?: string;
7
+ }
8
+ export interface IgnoredFinding {
9
+ readonly finding: Finding;
10
+ readonly matchedRule: number;
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { DataContract } from '../engine/plugin.js';
2
+ export declare const definitions: {
3
+ readonly lines: 'repometry.physical-lines/v1';
4
+ readonly functions: 'repometry.functions/v1';
5
+ readonly complexity: 'repometry.cyclomatic-babel/v1';
6
+ readonly coverage: 'repometry.lcov-line-coverage/v1';
7
+ readonly coveredLines: 'repometry.lcov-covered-lines/v1';
8
+ readonly coverableLines: 'repometry.lcov-coverable-lines/v1';
9
+ readonly codeLines: 'repometry.code-lines-babel/v1';
10
+ readonly comments: 'repometry.comment-lines-babel/v1';
11
+ readonly classes: 'repometry.classes-babel/v1';
12
+ readonly cognitiveComplexity: 'repometry.cognitive-babel/v1';
13
+ readonly duplicatedLines: 'repometry.duplicated-lines-babel/v1';
14
+ readonly churn: 'repometry.git-change-frequency/v1';
15
+ };
16
+ export interface Measurement {
17
+ readonly definition: string;
18
+ readonly target: 'repository' | 'file' | 'function';
19
+ readonly value: number | null;
20
+ readonly path?: string;
21
+ readonly line?: number;
22
+ readonly column?: number;
23
+ readonly name?: string;
24
+ readonly covered?: number;
25
+ readonly total?: number;
26
+ }
27
+ export declare const measurements: DataContract<readonly Measurement[]>;
@@ -0,0 +1,24 @@
1
+ import { isRecord } from '../engine/plugin.js';
2
+ export const definitions = {
3
+ lines: 'repometry.physical-lines/v1',
4
+ functions: 'repometry.functions/v1',
5
+ complexity: 'repometry.cyclomatic-babel/v1',
6
+ coverage: 'repometry.lcov-line-coverage/v1',
7
+ coveredLines: 'repometry.lcov-covered-lines/v1',
8
+ coverableLines: 'repometry.lcov-coverable-lines/v1',
9
+ codeLines: 'repometry.code-lines-babel/v1',
10
+ comments: 'repometry.comment-lines-babel/v1',
11
+ classes: 'repometry.classes-babel/v1',
12
+ cognitiveComplexity: 'repometry.cognitive-babel/v1',
13
+ duplicatedLines: 'repometry.duplicated-lines-babel/v1',
14
+ churn: 'repometry.git-change-frequency/v1',
15
+ };
16
+ function isMeasurement(value) {
17
+ return isRecord(value) && typeof value.definition === 'string'
18
+ && (value.target === 'repository' || value.target === 'file' || value.target === 'function')
19
+ && (value.value === null || (typeof value.value === 'number' && Number.isFinite(value.value)));
20
+ }
21
+ export const measurements = {
22
+ id: 'repometry.measurements/v1',
23
+ accepts: (value) => Array.isArray(value) && value.every(isMeasurement),
24
+ };
@@ -0,0 +1,17 @@
1
+ export type MetricScope = 'repository' | 'file' | 'function';
2
+ export interface MetricDescriptor {
3
+ readonly id: string;
4
+ readonly label: string;
5
+ readonly short?: string;
6
+ readonly description?: string;
7
+ readonly unit: 'count' | 'ratio' | 'minutes';
8
+ readonly scope: MetricScope;
9
+ readonly aggregate: 'sum' | 'max' | 'none';
10
+ readonly ratio?: {
11
+ readonly of: string;
12
+ readonly over: string;
13
+ };
14
+ readonly better: 'lower' | 'higher' | 'none';
15
+ readonly bands?: readonly [number, number, number, number];
16
+ readonly group?: string;
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { MetricDescriptor, PluginConfigSchema, RuleDescriptor } from '../engine/plugin.js';
2
+ import type { InventoryFile } from './source.js';
3
+ export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
4
+ readonly [key: string]: JsonValue;
5
+ };
6
+ export interface PersistedProduct {
7
+ readonly operation: string;
8
+ readonly path?: string;
9
+ readonly value: JsonValue;
10
+ }
11
+ export interface PluginData {
12
+ readonly metrics: readonly MetricDescriptor[];
13
+ readonly measured: readonly string[];
14
+ readonly privateMetrics?: readonly string[];
15
+ readonly rules: readonly {
16
+ readonly plugin: string;
17
+ readonly rules: readonly RuleDescriptor[];
18
+ }[];
19
+ readonly products: Readonly<Record<string, readonly PersistedProduct[]>>;
20
+ readonly contracts?: Readonly<Record<string, PluginConfigSchema>>;
21
+ readonly inventory?: readonly (InventoryFile & {
22
+ readonly language: string;
23
+ readonly analysed: boolean;
24
+ })[];
25
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ import type { DiffCoverage } from './diff-coverage.js';
2
+ import type { InspectionComparison } from './comparison.js';
3
+ import type { Finding } from './finding.js';
4
+ export declare const pullReviewSchema = "urn:repometry:schema:pull-review:1";
5
+ type LineCoverage = InspectionComparison['metrics']['lineCoverage'];
6
+ type GateStatus = 'passed' | 'failed' | 'not-applicable' | 'indeterminate';
7
+ export interface PullReview {
8
+ readonly schema: typeof pullReviewSchema;
9
+ readonly number: number | null;
10
+ readonly generatedAt: string;
11
+ readonly base: string;
12
+ readonly mergeBase: string;
13
+ readonly head: string;
14
+ readonly coverage: {
15
+ readonly base: LineCoverage['baseline'] | null;
16
+ readonly head: LineCoverage['current'] | null;
17
+ readonly delta: number | null;
18
+ readonly reason: LineCoverage['reason'] | 'reports-unavailable' | 'head-coverage-changed';
19
+ readonly gate: {
20
+ readonly status: GateStatus;
21
+ readonly maxDrop: number;
22
+ } | null;
23
+ };
24
+ readonly diff: Pick<DiffCoverage, 'covered' | 'total' | 'percent' | 'files' | 'gaps'> & {
25
+ readonly status: DiffCoverage['status'] | 'unavailable';
26
+ readonly excludedPaths: readonly string[] | null;
27
+ readonly coverageInputDigest: string | null;
28
+ readonly uncovered: readonly {
29
+ readonly path: string;
30
+ readonly lines: readonly number[];
31
+ }[];
32
+ readonly gate: {
33
+ readonly status: GateStatus;
34
+ readonly minimumPercent: number;
35
+ readonly minimumLines: number;
36
+ } | null;
37
+ };
38
+ readonly findings: {
39
+ readonly added: readonly Finding[] | null;
40
+ readonly qualityCount: number | null;
41
+ readonly reason: 'reports-unavailable' | 'findings-unavailable' | 'partial-inspection' | 'analysis-changed' | null;
42
+ readonly gate: {
43
+ readonly status: GateStatus;
44
+ readonly maximum: number;
45
+ } | null;
46
+ };
47
+ }
48
+ export {};
@@ -0,0 +1 @@
1
+ export const pullReviewSchema = 'urn:repometry:schema:pull-review:1';
@@ -0,0 +1,42 @@
1
+ import type { Report } from './report.js';
2
+ export type Grade = 'A' | 'B' | 'C' | 'D' | 'F';
3
+ export interface QualitySummary {
4
+ readonly codeLines: number | null;
5
+ readonly comments: number | null;
6
+ readonly classes: number | null;
7
+ readonly cognitiveComplexity: number | null;
8
+ readonly duplication: {
9
+ readonly duplicatedLines: number;
10
+ readonly codeLines: number;
11
+ readonly ratio: number | null;
12
+ } | null;
13
+ readonly maintainability: {
14
+ readonly smells: number;
15
+ readonly effortMinutes: number;
16
+ readonly debtRatio: number | null;
17
+ readonly grade: Grade | null;
18
+ } | null;
19
+ }
20
+ interface DebtModel {
21
+ readonly name: 'basic-cocomo-organic';
22
+ readonly scale: number;
23
+ readonly exponent: number;
24
+ readonly minutesPerPersonMonth: number;
25
+ }
26
+ export declare const debtModel: DebtModel;
27
+ export declare function qualitySummary(report: Report): QualitySummary;
28
+ export declare function technicalDebtRatio(effortMinutes: number, codeLines: number, model?: DebtModel): number | null;
29
+ export declare function maintainabilityGrade(debtRatio: number): Grade;
30
+ export declare function coverageGrade(ratio: number): Grade;
31
+ /**
32
+ * Security as a grade, not a risk level: A with no findings, then B, C, D and F by the worst severity found
33
+ * (low or unclassified, medium, high, critical). A high risk is a low grade.
34
+ */
35
+ export declare function securityGrade(counts: {
36
+ readonly critical?: number;
37
+ readonly high: number;
38
+ readonly medium: number;
39
+ readonly low: number;
40
+ readonly unknown: number;
41
+ }): Grade;
42
+ export {};
@@ -0,0 +1,64 @@
1
+ import { isRecord } from '../engine/plugin.js';
2
+ import { definitions } from './measurement.js';
3
+ export const debtModel = { name: 'basic-cocomo-organic', scale: 2.4, exponent: 1.05, minutesPerPersonMonth: 9600 };
4
+ export function qualitySummary(report) {
5
+ const totals = new Map();
6
+ let codeMeasuredFiles = 0;
7
+ let duplicationMeasuredFiles = 0;
8
+ for (const item of report.measurements) {
9
+ if (item.target !== 'file' || item.value === null || !Number.isSafeInteger(item.value) || item.value < 0)
10
+ continue;
11
+ if (item.definition === definitions.codeLines)
12
+ codeMeasuredFiles++;
13
+ if (item.definition === definitions.duplicatedLines)
14
+ duplicationMeasuredFiles++;
15
+ totals.set(item.definition, (totals.get(item.definition) ?? 0) + item.value);
16
+ }
17
+ const codeLines = totals.get(definitions.codeLines) ?? null;
18
+ const duplicatedLines = totals.get(definitions.duplicatedLines) ?? null;
19
+ const smells = report.findings?.filter(finding => finding.category === 'duplication' || finding.category === 'structure');
20
+ const effortMinutes = smells?.reduce((sum, finding) => sum + (finding.effortMinutes ?? 0), 0) ?? 0;
21
+ const hasCompleteData = codeMeasuredFiles === report.scope.files && duplicationMeasuredFiles === report.scope.files;
22
+ const savedConfig = report.appliedConfig.maintainability;
23
+ const model = isRecord(savedConfig) ? readDebtModel(savedConfig.debtModel) : null;
24
+ const debtRatio = !hasCompleteData || codeLines === null || model === null || smells?.some(finding => finding.effortMinutes === undefined)
25
+ ? null : technicalDebtRatio(effortMinutes, codeLines, model);
26
+ return {
27
+ codeLines,
28
+ comments: totals.get(definitions.comments) ?? null,
29
+ classes: totals.get(definitions.classes) ?? null,
30
+ cognitiveComplexity: totals.get(definitions.cognitiveComplexity) ?? null,
31
+ duplication: duplicatedLines === null || codeLines === null || codeMeasuredFiles !== duplicationMeasuredFiles
32
+ ? null : { duplicatedLines, codeLines, ratio: codeLines === 0 || duplicatedLines > codeLines ? null : duplicatedLines / codeLines },
33
+ maintainability: smells === undefined || codeLines === null ? null : { smells: smells.length, effortMinutes, debtRatio,
34
+ grade: debtRatio === null ? null : maintainabilityGrade(debtRatio) },
35
+ };
36
+ }
37
+ export function technicalDebtRatio(effortMinutes, codeLines, model = debtModel) {
38
+ if (codeLines <= 0)
39
+ return null;
40
+ const ratio = effortMinutes / (model.scale * (codeLines / 1000) ** model.exponent * model.minutesPerPersonMonth);
41
+ return Number.isFinite(ratio) ? ratio : null;
42
+ }
43
+ export function maintainabilityGrade(debtRatio) {
44
+ return debtRatio < 0.05 ? 'A' : debtRatio < 0.1 ? 'B' : debtRatio < 0.2 ? 'C' : debtRatio < 0.5 ? 'D' : 'F';
45
+ }
46
+ export function coverageGrade(ratio) {
47
+ return ratio >= 0.9 ? 'A' : ratio >= 0.8 ? 'B' : ratio >= 0.7 ? 'C' : ratio >= 0.6 ? 'D' : 'F';
48
+ }
49
+ /**
50
+ * Security as a grade, not a risk level: A with no findings, then B, C, D and F by the worst severity found
51
+ * (low or unclassified, medium, high, critical). A high risk is a low grade.
52
+ */
53
+ export function securityGrade(counts) {
54
+ return counts.critical ? 'F' : counts.high ? 'D' : counts.medium ? 'C' : counts.low || counts.unknown ? 'B' : 'A';
55
+ }
56
+ function readDebtModel(model) {
57
+ if (!isRecord(model) || model.name !== 'basic-cocomo-organic' || !positiveNumber(model.scale)
58
+ || !positiveNumber(model.exponent) || !positiveNumber(model.minutesPerPersonMonth))
59
+ return null;
60
+ return { name: model.name, scale: model.scale, exponent: model.exponent, minutesPerPersonMonth: model.minutesPerPersonMonth };
61
+ }
62
+ function positiveNumber(value) {
63
+ return typeof value === 'number' && Number.isFinite(value) && value > 0;
64
+ }
@@ -0,0 +1,32 @@
1
+ import type { Measurement } from './measurement.js';
2
+ import type { Finding } from './finding.js';
3
+ import type { IgnoredFinding } from './ignore-rule.js';
4
+ import type { PluginData } from './plugin-data.js';
5
+ import type { Subject } from './source.js';
6
+ export declare const legacyReportSchema = "urn:repometry:schema:report:1";
7
+ export declare const reportSchema = "urn:repometry:schema:report:2";
8
+ export interface Diagnostic {
9
+ readonly operation: string;
10
+ readonly state: 'failed' | 'blocked' | 'partial';
11
+ readonly message: string;
12
+ readonly path?: string;
13
+ }
14
+ export interface Report {
15
+ readonly schema: typeof reportSchema | typeof legacyReportSchema;
16
+ readonly subject: Subject;
17
+ readonly generatedAt: string;
18
+ readonly committedAt?: string;
19
+ readonly appliedConfig: Readonly<Record<string, unknown>>;
20
+ readonly definitions: Readonly<Record<string, string>>;
21
+ readonly scope: {
22
+ readonly files: number;
23
+ readonly parsed: number;
24
+ };
25
+ readonly status: 'complete' | 'partial' | 'not-applicable';
26
+ readonly measurements: readonly Measurement[];
27
+ readonly diagnostics: readonly Diagnostic[];
28
+ readonly findings?: readonly Finding[];
29
+ readonly ignoredFindings?: readonly IgnoredFinding[];
30
+ readonly pluginData?: PluginData;
31
+ }
32
+ export declare function validSubjectId(kind: Subject['kind'], id: string): boolean;
@@ -0,0 +1,5 @@
1
+ export const legacyReportSchema = 'urn:repometry:schema:report:1';
2
+ export const reportSchema = 'urn:repometry:schema:report:2';
3
+ export function validSubjectId(kind, id) {
4
+ return /^[a-f0-9]{64}$/.test(id) || (kind === 'commit' && /^[a-f0-9]{40}$/.test(id));
5
+ }
@@ -0,0 +1,39 @@
1
+ import type { Finding } from './finding.js';
2
+ export type FindingInput = {
3
+ readonly file: string;
4
+ readonly toolVersion?: string;
5
+ readonly settingsDigest?: string;
6
+ readonly scope?: string;
7
+ } & ({
8
+ readonly format: 'sarif';
9
+ readonly category: 'lint' | 'security' | 'secret';
10
+ } | {
11
+ readonly format: 'eslint';
12
+ readonly category: 'lint';
13
+ } | {
14
+ readonly format: 'osv';
15
+ readonly category: 'dependency';
16
+ });
17
+ export interface Scanner {
18
+ readonly name: string;
19
+ readonly version: string | null;
20
+ }
21
+ interface ImportMethod {
22
+ readonly format: FindingInput['format'];
23
+ readonly category: Finding['category'];
24
+ readonly tools: readonly Scanner[];
25
+ readonly settingsDigest: string | null;
26
+ readonly scope: string | null;
27
+ }
28
+ export interface ImportMetadata extends ImportMethod {
29
+ readonly inputDigest: string;
30
+ readonly reported: number;
31
+ readonly imported: number;
32
+ readonly unmapped: number;
33
+ readonly units: number;
34
+ }
35
+ /** Keep scanner identity in profile comparisons while dropping the per-snapshot inputs and counts. */
36
+ export declare function findingImportMethods(value: unknown): readonly ImportMethod[];
37
+ export declare function uniqueScanners(tools: readonly Scanner[]): Scanner[];
38
+ export declare function scannerText(value: unknown): string | undefined;
39
+ export {};
@@ -0,0 +1,28 @@
1
+ import { isRecord } from '../engine/plugin.js';
2
+ import { findingCategories } from './finding.js';
3
+ /** Keep scanner identity in profile comparisons while dropping the per-snapshot inputs and counts. */
4
+ export function findingImportMethods(value) {
5
+ if (!Array.isArray(value))
6
+ return [];
7
+ const methods = new Map();
8
+ for (const item of value) {
9
+ if (!isRecord(item) || (item.format !== 'sarif' && item.format !== 'eslint' && item.format !== 'osv'))
10
+ continue;
11
+ const category = findingCategories.find(candidate => candidate === item.category);
12
+ if (!category || !Array.isArray(item.tools))
13
+ continue;
14
+ const tools = item.tools.filter((tool) => isRecord(tool) && typeof tool.name === 'string'
15
+ && (tool.version === null || typeof tool.version === 'string'));
16
+ const method = { category, format: item.format, tools: uniqueScanners(tools),
17
+ settingsDigest: scannerText(item.settingsDigest) ?? null, scope: scannerText(item.scope) ?? null };
18
+ methods.set(JSON.stringify(method), method);
19
+ }
20
+ return [...methods].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([, value]) => value);
21
+ }
22
+ export function uniqueScanners(tools) {
23
+ return [...new Map(tools.map(({ name, version }) => [JSON.stringify([name, version]), { name, version }]))]
24
+ .sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([, tool]) => tool);
25
+ }
26
+ export function scannerText(value) {
27
+ return typeof value === 'string' && value.trim() !== '' ? value : undefined;
28
+ }
@@ -0,0 +1,15 @@
1
+ import type { DataContract } from '../engine/plugin.js';
2
+ import type { SourceFile, SourceSnapshot } from './source.js';
3
+ export type { Subject, SourceFile, SourceSnapshot } from './source.js';
4
+ export declare const sourceFile: DataContract<SourceFile>;
5
+ export declare const sourceDirectoriesExcluded: readonly ['.git', '.repometry', 'node_modules', 'target'];
6
+ export declare const sourceExtensions: readonly ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.mts', '.cts', '.tsx'];
7
+ export declare function isSourcePath(path: string): boolean;
8
+ export declare function isExcludedDirectory(name: string): boolean;
9
+ export declare function digest(bytes: Uint8Array | string): string;
10
+ export declare function utf8(bytes: Uint8Array): string;
11
+ export declare function physicalLines(text: string): number;
12
+ export declare function sourceLineCounts(files: readonly SourceFile[]): ReadonlyMap<string, number>;
13
+ export declare function textLineCount(bytes: Uint8Array): number | null;
14
+ export declare function comparePaths(left: string, right: string): number;
15
+ export declare function workingSnapshot(files: SourceFile[]): SourceSnapshot;