repometry 0.6.2 → 0.8.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 (153) hide show
  1. package/README.md +3 -0
  2. package/package.json +1 -1
  3. package/target/main/resources/config/process-plugins-v1.schema.json +79 -0
  4. package/target/main/resources/languages/go/parser.go +602 -0
  5. package/target/main/resources/languages/python/parser.py +312 -0
  6. package/target/main/resources/report/json/report-v2.schema.json +21 -1
  7. package/target/main/resources/report/json/repository-summary-v1.schema.json +9 -0
  8. package/target/main/resources/report/json/viewer-inspection-v1.schema.json +12 -3
  9. package/target/main/resources/viewer/files.css +7 -0
  10. package/target/main/resources/viewer/index.html +1 -1
  11. package/target/main/resources/viewer/styles.css +1 -0
  12. package/target/main/ts/api/git/git-reader.d.ts +10 -2
  13. package/target/main/ts/api/git/git-reader.js +74 -35
  14. package/target/main/ts/api/git/git.d.ts +19 -1
  15. package/target/main/ts/api/git/git.js +97 -7
  16. package/target/main/ts/api/import/go-cover.d.ts +13 -0
  17. package/target/main/ts/api/import/go-cover.js +150 -0
  18. package/target/main/ts/api/import/lcov-files.d.ts +6 -1
  19. package/target/main/ts/api/import/lcov-files.js +27 -7
  20. package/target/main/ts/api/process/docker-tool-runner.js +5 -21
  21. package/target/main/ts/api/process/host-language-runner.d.ts +13 -0
  22. package/target/main/ts/api/process/host-language-runner.js +176 -0
  23. package/target/main/ts/api/process/plugin.d.ts +4 -1
  24. package/target/main/ts/api/process/plugin.js +7 -3
  25. package/target/main/ts/api/process/tool-snapshot.d.ts +3 -0
  26. package/target/main/ts/api/process/tool-snapshot.js +26 -0
  27. package/target/main/ts/cli/config.d.ts +1 -0
  28. package/target/main/ts/cli/config.js +3 -2
  29. package/target/main/ts/cli/imports.d.ts +1 -0
  30. package/target/main/ts/cli/imports.js +5 -2
  31. package/target/main/ts/cli/main.js +76 -27
  32. package/target/main/ts/cli/reporting.js +3 -3
  33. package/target/main/ts/compose/analysis-files.d.ts +3 -1
  34. package/target/main/ts/compose/analysis-files.js +46 -12
  35. package/target/main/ts/compose/analysis-imports.js +4 -2
  36. package/target/main/ts/compose/analysis-report.d.ts +1 -0
  37. package/target/main/ts/compose/analysis-report.js +20 -15
  38. package/target/main/ts/compose/analysis-repository.d.ts +2 -1
  39. package/target/main/ts/compose/analysis-repository.js +42 -4
  40. package/target/main/ts/compose/analysis-results.d.ts +4 -1
  41. package/target/main/ts/compose/analysis-results.js +3 -0
  42. package/target/main/ts/compose/analysis-sources.d.ts +5 -0
  43. package/target/main/ts/compose/analysis-sources.js +11 -3
  44. package/target/main/ts/compose/analyze-snapshot.d.ts +2 -1
  45. package/target/main/ts/compose/analyze-snapshot.js +5 -3
  46. package/target/main/ts/compose/diff-coverage.d.ts +2 -1
  47. package/target/main/ts/compose/diff-coverage.js +8 -6
  48. package/target/main/ts/compose/history-cache.d.ts +29 -0
  49. package/target/main/ts/compose/history-cache.js +57 -0
  50. package/target/main/ts/compose/inspect.d.ts +6 -1
  51. package/target/main/ts/compose/inspect.js +10 -10
  52. package/target/main/ts/compose/inspection-coverage.d.ts +9 -0
  53. package/target/main/ts/compose/inspection-coverage.js +9 -0
  54. package/target/main/ts/compose/languages.d.ts +6 -1
  55. package/target/main/ts/compose/languages.js +23 -7
  56. package/target/main/ts/compose/native-language-plugins.d.ts +6 -0
  57. package/target/main/ts/compose/native-language-plugins.js +40 -0
  58. package/target/main/ts/compose/plugin-list.d.ts +7 -3
  59. package/target/main/ts/compose/plugin-list.js +13 -3
  60. package/target/main/ts/compose/prepare-metabranch.js +1 -1
  61. package/target/main/ts/compose/process-plugins.d.ts +2 -0
  62. package/target/main/ts/compose/process-plugins.js +64 -0
  63. package/target/main/ts/compose/review.d.ts +1 -2
  64. package/target/main/ts/compose/review.js +2 -2
  65. package/target/main/ts/compose/structure-measures.d.ts +5 -0
  66. package/target/main/ts/compose/structure-measures.js +57 -0
  67. package/target/main/ts/core/engine/manifest.js +5 -1
  68. package/target/main/ts/core/engine/plan.js +5 -6
  69. package/target/main/ts/core/engine/plugin.d.ts +2 -0
  70. package/target/main/ts/core/model/clone-source.js +0 -1
  71. package/target/main/ts/core/model/code-structure.d.ts +14 -9
  72. package/target/main/ts/core/model/code-structure.js +23 -10
  73. package/target/main/ts/core/model/file-types.d.ts +1 -0
  74. package/target/main/ts/core/model/file-types.js +14 -3
  75. package/target/main/ts/core/model/language.d.ts +2 -0
  76. package/target/main/ts/core/model/plugin-data.d.ts +2 -0
  77. package/target/main/ts/core/model/quality-summary.d.ts +4 -0
  78. package/target/main/ts/core/model/quality-summary.js +55 -29
  79. package/target/main/ts/core/model/report.d.ts +6 -0
  80. package/target/main/ts/core/model/source.d.ts +2 -0
  81. package/target/main/ts/core/usecases/inspect.d.ts +1 -1
  82. package/target/main/ts/core/usecases/inspect.js +1 -1
  83. package/target/main/ts/plugin.d.ts +1 -1
  84. package/target/main/ts/plugins/coverage/coverage.d.ts +2 -1
  85. package/target/main/ts/plugins/coverage/coverage.js +40 -30
  86. package/target/main/ts/plugins/language-js/function-facts.d.ts +1 -1
  87. package/target/main/ts/plugins/language-js/function-facts.js +0 -1
  88. package/target/main/ts/plugins/language-js/js-security.js +25 -37
  89. package/target/main/ts/plugins/language-js/structural-observations.js +5 -4
  90. package/target/main/ts/plugins/maintainability/maintainability.d.ts +1 -1
  91. package/target/main/ts/plugins/maintainability/maintainability.js +9 -8
  92. package/target/main/ts/plugins/security/dockerfile.js +51 -52
  93. package/target/main/ts/plugins/structure/structure.js +2 -2
  94. package/target/main/ts/report/html/app/viewer-code-map.js +6 -5
  95. package/target/main/ts/report/html/app/viewer-columns.d.ts +2 -0
  96. package/target/main/ts/report/html/app/viewer-columns.js +9 -4
  97. package/target/main/ts/report/html/app/viewer-data.d.ts +2 -1
  98. package/target/main/ts/report/html/app/viewer-data.js +1 -1
  99. package/target/main/ts/report/html/app/viewer-file-aside.d.ts +5 -9
  100. package/target/main/ts/report/html/app/viewer-file-aside.js +18 -8
  101. package/target/main/ts/report/html/app/viewer-file-figures.d.ts +2 -0
  102. package/target/main/ts/report/html/app/viewer-file-figures.js +6 -1
  103. package/target/main/ts/report/html/app/viewer-hotspots.js +7 -5
  104. package/target/main/ts/report/html/app/viewer-inspection.js +1 -1
  105. package/target/main/ts/report/html/app/viewer-issue-group.js +2 -2
  106. package/target/main/ts/report/html/app/viewer-language-bar.d.ts +2 -0
  107. package/target/main/ts/report/html/app/viewer-language-bar.js +5 -1
  108. package/target/main/ts/report/html/app/viewer-languages.d.ts +3 -2
  109. package/target/main/ts/report/html/app/viewer-languages.js +14 -7
  110. package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +4 -4
  111. package/target/main/ts/report/html/app/viewer-line-coverage.js +11 -24
  112. package/target/main/ts/report/html/app/viewer-map-scale.d.ts +1 -1
  113. package/target/main/ts/report/html/app/viewer-map-scale.js +1 -1
  114. package/target/main/ts/report/html/app/viewer-map-shape.d.ts +2 -2
  115. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +0 -3
  116. package/target/main/ts/report/html/app/viewer-metric-registry.js +0 -9
  117. package/target/main/ts/report/html/app/viewer-metrics-view.js +1 -4
  118. package/target/main/ts/report/html/app/viewer-metrics.d.ts +2 -0
  119. package/target/main/ts/report/html/app/viewer-metrics.js +5 -0
  120. package/target/main/ts/report/html/app/viewer-overview-cards.js +4 -1
  121. package/target/main/ts/report/html/app/viewer-overview-hotspots.js +2 -2
  122. package/target/main/ts/report/html/app/viewer-profile.js +22 -1
  123. package/target/main/ts/report/html/app/viewer-source-view.js +7 -6
  124. package/target/main/ts/report/html/app/viewer-table-cells.js +8 -2
  125. package/target/main/ts/report/html/app/viewer-table-rows.d.ts +2 -0
  126. package/target/main/ts/report/html/app/viewer-table-rows.js +7 -5
  127. package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +2 -5
  128. package/target/main/ts/report/html/app/viewer-tokenizer.js +9 -12
  129. package/target/main/ts/report/html/app/viewer-totals.d.ts +6 -0
  130. package/target/main/ts/report/html/app/viewer-totals.js +11 -0
  131. package/target/main/ts/report/html/app/viewer-trend-data.d.ts +1 -1
  132. package/target/main/ts/report/html/app/viewer-trend-data.js +1 -1
  133. package/target/main/ts/report/html/app/viewer-trend-nav.js +3 -2
  134. package/target/main/ts/report/html/app/viewer.js +1 -7
  135. package/target/main/ts/report/json/projections/commit-summary.d.ts +1 -0
  136. package/target/main/ts/report/json/projections/commit-summary.js +10 -0
  137. package/target/main/ts/report/json/projections/file-metrics.js +56 -45
  138. package/target/main/ts/report/json/projections/inspection-details.js +33 -14
  139. package/target/main/ts/report/json/projections/metric-values.d.ts +1 -0
  140. package/target/main/ts/report/json/projections/metric-values.js +36 -3
  141. package/target/main/ts/report/json/store/directory.d.ts +3 -0
  142. package/target/main/ts/report/json/store/directory.js +19 -0
  143. package/target/main/ts/report/json/store/local-store.d.ts +14 -2
  144. package/target/main/ts/report/json/store/local-store.js +74 -60
  145. package/target/main/ts/report/json/store/object-store.d.ts +14 -0
  146. package/target/main/ts/report/json/store/object-store.js +73 -0
  147. package/target/main/ts/report/json/store/report-tree.d.ts +46 -0
  148. package/target/main/ts/report/json/store/report-tree.js +290 -0
  149. package/target/main/ts/report/json/store/store-check.d.ts +32 -0
  150. package/target/main/ts/report/json/store/store-check.js +144 -0
  151. package/target/main/ts/report/json/validation/report.d.ts +6 -1
  152. package/target/main/ts/report/json/validation/report.js +10 -4
  153. package/target/main/ts/report/json/wire/inspection-details-model.d.ts +9 -1
@@ -5,6 +5,8 @@ export class AnalysisResults {
5
5
  findings = [];
6
6
  diagnostics;
7
7
  parsed = new Set();
8
+ ruleSkips = [];
9
+ unmeasured = new Map();
8
10
  inspected = new Set();
9
11
  completedInspection = false;
10
12
  products;
@@ -69,6 +71,7 @@ export class AnalysisResults {
69
71
  }
70
72
  export function operationProvenance(task, syntaxProvider) {
71
73
  return { key: task.key, inputs: Object.fromEntries(task.inputs),
74
+ ...(task.operation.implementation === undefined ? {} : { implementation: task.operation.implementation }),
72
75
  ...(task.operation.scope === 'repository' ? { scope: task.operation.scope } : {}),
73
76
  ...(syntaxProvider === undefined ? {} : { syntaxProvider }) };
74
77
  }
@@ -19,6 +19,8 @@ export declare function inspectionFileMatcher(additional: readonly Plugin[], lan
19
19
  readonly globs: readonly string[];
20
20
  readonly catalog: readonly import("../plugin.js").LanguageDisplay[];
21
21
  readonly providers: readonly LanguageProvider[];
22
+ readonly native: readonly import("./native-language-plugins.js").NativeLanguagePlugin[];
23
+ skipped(path: string): boolean;
22
24
  }): (path: string) => boolean;
23
25
  export declare function selectAnalysisSources(snapshot: SourceSnapshot, additional: readonly Plugin[], withCoverage: boolean): {
24
26
  languages: {
@@ -29,9 +31,12 @@ export declare function selectAnalysisSources(snapshot: SourceSnapshot, addition
29
31
  readonly globs: readonly string[];
30
32
  readonly catalog: readonly import("../plugin.js").LanguageDisplay[];
31
33
  readonly providers: readonly LanguageProvider[];
34
+ readonly native: readonly import("./native-language-plugins.js").NativeLanguagePlugin[];
35
+ skipped(path: string): boolean;
32
36
  };
33
37
  sources: SelectedSource[];
34
38
  sourceFiles: SourceFile[];
39
+ unavailableFiles: Set<string>;
35
40
  providersByPath: Map<string, LanguageProvider>;
36
41
  plugins: Plugin[];
37
42
  claimedPlugins: Plugin[];
@@ -13,16 +13,24 @@ export function inspectionFileMatcher(additional, languages = defaultLanguages)
13
13
  return path => matches.some(match => match(path));
14
14
  }
15
15
  export function selectAnalysisSources(snapshot, additional, withCoverage) {
16
- const languages = additional.length ? languageRegistry(additional) : defaultLanguages;
16
+ const languages = languageRegistry(additional);
17
17
  const sources = snapshot.files.map(file => ({ file, provider: languages.select(file.path) }));
18
18
  const providersByPath = new Map(sources.flatMap(({ file, provider }) => provider ? [[file.path, provider]] : []));
19
+ const unavailableFiles = new Set(sources.filter(({ file, provider }) => !provider && languages.skipped(file.path))
20
+ .map(({ file }) => file.path));
19
21
  const sourceFiles = sources.flatMap(({ file, provider }) => provider ? [file] : []);
20
- const claimedPlugins = [...securityPlugins.filter(plugin => !additional.includes(plugin)), ...additional];
22
+ const bound = new Map(languages.providers.map(({ plugin }) => [plugin.id, plugin]));
23
+ const native = languages.native.flatMap(({ id }) => {
24
+ const plugin = bound.get(id);
25
+ return plugin ? [plugin] : [];
26
+ });
27
+ const claimedPlugins = [...securityPlugins.filter(plugin => !additional.includes(plugin)), ...native,
28
+ ...additional.map(plugin => bound.get(plugin.id) ?? plugin)];
21
29
  const plugins = [defaultProvider.plugin, ...structuralInspections, duplication, ...(withCoverage ? [coverage] : []), ...claimedPlugins];
22
30
  validateRegistration(plugins, additional, withCoverage);
23
31
  const claims = claimedPlugins.map(plugin => ({ plugin, matches: plugin.kinds.includes('language')
24
32
  ? path => providersByPath.get(path)?.plugin.id === plugin.id : claimMatcher(plugin.claims, languages.id) }));
25
- return { languages, sources, sourceFiles, providersByPath, plugins, claimedPlugins,
33
+ return { languages, sources, sourceFiles, unavailableFiles, providersByPath, plugins, claimedPlugins,
26
34
  perFile: claimsForScope(claims, 'file'), repository: claimsForScope(claims, 'repository') };
27
35
  }
28
36
  function validateRegistration(plugins, additional, withCoverage) {
@@ -2,5 +2,6 @@ import type { OperationCacheOptions } from '../core/engine/operation-cache.js';
2
2
  import type { Plugin } from '../core/engine/plugin.js';
3
3
  import type { Report } from '../core/model/report.js';
4
4
  import type { AnalysisInput } from '../core/usecases/inspect.js';
5
+ import type { HistoryCache } from './history-cache.js';
5
6
  export { inspectionFileMatcher } from './analysis-sources.js';
6
- export declare function analyzeSnapshot(input: AnalysisInput, additional?: readonly Plugin[], cache?: OperationCacheOptions): Promise<Report>;
7
+ export declare function analyzeSnapshot(input: AnalysisInput, additional?: readonly Plugin[], cache?: OperationCacheOptions, history?: HistoryCache): Promise<Report>;
@@ -4,15 +4,17 @@ import { collectRepositorySyntax, inspectRepositories } from './analysis-reposit
4
4
  import { assembleAnalysisReport } from './analysis-report.js';
5
5
  import { AnalysisResults } from './analysis-results.js';
6
6
  import { selectAnalysisSources } from './analysis-sources.js';
7
+ import { historyProfile } from './history-cache.js';
7
8
  export { inspectionFileMatcher } from './analysis-sources.js';
8
- export async function analyzeSnapshot(input, additional = [], cache) {
9
+ export async function analyzeSnapshot(input, additional = [], cache, history) {
9
10
  const withCoverage = input.coverage !== undefined;
10
11
  const sources = selectAnalysisSources(input.snapshot, additional, withCoverage);
12
+ const reusable = history?.begin(input.snapshot, historyProfile(input, sources, cache?.configurationDigest));
11
13
  const results = new AnalysisResults(sources.plugins, sources.claimedPlugins, input.snapshot.oversizedClaims ?? []);
12
14
  for (const task of defaultFilePlan)
13
15
  results.remember(task);
14
- const batchFacts = await collectRepositorySyntax(sources, results, cache);
15
- const files = await inspectFiles(sources, batchFacts, results, withCoverage, cache);
16
+ const batchFacts = await collectRepositorySyntax(sources, results, cache, reusable);
17
+ const files = await inspectFiles(sources, batchFacts, results, withCoverage, cache, reusable);
16
18
  await inspectRepositories(sources, results, cache);
17
19
  await inspectDuplication(files, results, cache);
18
20
  await importAnalysisCoverage(input, sources, files, results, cache);
@@ -7,7 +7,8 @@ export interface DiffCoverageRequest {
7
7
  readonly directory: string;
8
8
  readonly revision: string;
9
9
  readonly base: string;
10
- readonly lcov: LcovFiles;
10
+ readonly lcov?: LcovFiles;
11
+ readonly goCover?: LcovFiles;
11
12
  readonly exclude?: readonly string[];
12
13
  readonly minimumPercent?: number;
13
14
  readonly plugins?: readonly Plugin[];
@@ -7,8 +7,8 @@ import { coverage, lcovInput } from '../plugins/coverage/coverage.js';
7
7
  import { changesInput, diffCoverage, diffCoverageResult } from '../plugins/coverage/diff-coverage.js';
8
8
  import { diffMethod, findMergeBase, readChanges } from '../api/git/changes.js';
9
9
  import { gitText, physicalGitRoot, readGitCommit, resolveGitCommit } from '../api/git/git.js';
10
- import { readLcovFiles } from '../api/import/lcov-files.js';
11
- import { defaultLanguages, languageRegistry } from './languages.js';
10
+ import { readInspectionCoverage } from './inspection-coverage.js';
11
+ import { languageRegistry } from './languages.js';
12
12
  export { diffCoverageSchema } from '../core/usecases/diff-coverage.js';
13
13
  const operation = 'diff-coverage/measure';
14
14
  const steps = plan({ plugins: [diffCoverage], select: [operation],
@@ -37,16 +37,18 @@ export async function measureChangedLines(request, overrides) {
37
37
  }
38
38
  async function readInputs(request, excludedPaths, excludes) {
39
39
  const root = await physicalGitRoot(request.directory);
40
- const [requestedBase, head, lcov, gitVersion] = await Promise.all([
40
+ const [requestedBase, head, gitVersion] = await Promise.all([
41
41
  resolveGitCommit(root, request.base),
42
42
  resolveGitCommit(root, request.revision),
43
- readLcovFiles(request.lcov),
44
43
  gitText(root, ['--version']).then(text => text.trim()),
45
44
  ]);
46
45
  const base = await findMergeBase(root, requestedBase, head);
47
- const { isSource, extensions, globs } = request.plugins?.length ? languageRegistry(request.plugins) : defaultLanguages;
46
+ const { isSource, extensions, globs } = languageRegistry(request.plugins ?? []);
48
47
  const snapshot = await readGitCommit(root, head, excludes, isSource);
49
- const changes = await readChanges(root, base, snapshot, sourceExclusionMatcher(excludedPaths, snapshot.generatedExcluded), isSource);
48
+ const [lcov, changes] = await Promise.all([
49
+ readInspectionCoverage(request, { root, snapshot }),
50
+ readChanges(root, base, snapshot, sourceExclusionMatcher(excludedPaths, snapshot.generatedExcluded), isSource),
51
+ ]);
50
52
  return { requestedBase, base, head, snapshot, changes, root, lcovText: lcov.text, appliedConfig: {
51
53
  source: { extensions, ...(globs.length ? { globs } : {}), excludedDirectories: sourceDirectoriesExcluded, excludedPaths,
52
54
  defaultExclusions: defaultSourceExclusions, generatedSourcePolicy, generatedExcluded: snapshot.generatedExcluded ?? [] },
@@ -0,0 +1,29 @@
1
+ import type { Outcome } from '../core/engine/execute.js';
2
+ import type { CodeStructure } from '../core/model/code-structure.js';
3
+ import type { SourceSnapshot } from '../core/model/source.js';
4
+ import type { AnalysisInput } from '../core/usecases/inspect.js';
5
+ import type { AnalysisSources } from './analysis-sources.js';
6
+ import type { LanguageProvider } from './languages.js';
7
+ interface FileResult {
8
+ readonly blob: string;
9
+ syntax?: CodeStructure;
10
+ outcomes?: ReadonlyMap<string, Outcome>;
11
+ }
12
+ export declare class HistoryFiles {
13
+ private readonly ids;
14
+ private readonly previous?;
15
+ readonly current: Map<string, FileResult>;
16
+ constructor(ids: ReadonlyMap<string, string>, previous?: ReadonlyMap<string, FileResult> | undefined);
17
+ read(path: string): FileResult | undefined;
18
+ retain(path: string, result: Omit<FileResult, 'blob'>): void;
19
+ }
20
+ /** One range keeps at most two adjacent snapshots' results during inspection. */
21
+ export declare class HistoryCache {
22
+ private readonly configuration?;
23
+ private previous?;
24
+ constructor(configuration?: unknown);
25
+ begin(snapshot: SourceSnapshot, profile: string): HistoryFiles | undefined;
26
+ }
27
+ export declare function historyProfile(input: AnalysisInput, sources: AnalysisSources, operationConfiguration?: string): string;
28
+ export declare function canReuseBatch(provider: LanguageProvider): boolean;
29
+ export {};
@@ -0,0 +1,57 @@
1
+ import { debtModel } from '../core/model/quality-summary.js';
2
+ import { digest, sourceDirectoriesExcluded } from '../core/model/snapshot.js';
3
+ import { defaultSourceExclusions, generatedSourcePolicy } from '../core/profile/exclusions.js';
4
+ import { duplicationSettings, structuralRules } from '../core/profile/maintainability.js';
5
+ import { analysisProfile } from './analysis-report.js';
6
+ export class HistoryFiles {
7
+ ids;
8
+ previous;
9
+ current = new Map();
10
+ constructor(ids, previous) {
11
+ this.ids = ids;
12
+ this.previous = previous;
13
+ }
14
+ read(path) {
15
+ const result = this.previous?.get(path);
16
+ return result?.blob === this.ids.get(path) ? result : undefined;
17
+ }
18
+ retain(path, result) {
19
+ const blob = this.ids.get(path);
20
+ if (blob !== undefined)
21
+ this.current.set(path, { ...this.current.get(path), ...result, blob });
22
+ }
23
+ }
24
+ /** One range keeps at most two adjacent snapshots' results during inspection. */
25
+ export class HistoryCache {
26
+ configuration;
27
+ previous;
28
+ constructor(configuration) {
29
+ this.configuration = configuration;
30
+ }
31
+ begin(snapshot, profile) {
32
+ if (snapshot.subject.kind !== 'commit' || snapshot.blobIds === undefined)
33
+ return undefined;
34
+ const key = digest(JSON.stringify([this.configuration, profile]));
35
+ const files = new HistoryFiles(snapshot.blobIds, this.previous?.profile === key ? this.previous.files.current : undefined);
36
+ this.previous = { profile: key, files };
37
+ return files;
38
+ }
39
+ }
40
+ export function historyProfile(input, sources, operationConfiguration) {
41
+ return JSON.stringify([process.version, analysisProfile, input.excludedPaths, input.excludedOutput,
42
+ sourceDirectoriesExcluded, defaultSourceExclusions, generatedSourcePolicy, structuralRules, duplicationSettings, debtModel,
43
+ operationConfiguration, sources.plugins.map(pluginIdentity),
44
+ sources.languages.native.filter(plugin => plugin.unavailableReason !== undefined).map(pluginIdentity)]);
45
+ }
46
+ function pluginIdentity({ operations, ...manifest }) {
47
+ return { ...manifest, operations: operations.map(({ execute, inputs, output, ...operation }) => ({ ...operation,
48
+ inputs: Object.entries(inputs).map(([port, contract]) => [port, contract.id]), output: output.id,
49
+ implementation: operation.implementation ?? execute.toString(),
50
+ })) };
51
+ }
52
+ export function canReuseBatch(provider) {
53
+ return provider.operation.fileIndependent === true
54
+ && !provider.plugin.operations.some(operation => operation.scope === 'repository' && operation.role === 'inspection')
55
+ && provider.plugin.produces.some(product => product.contract === provider.operation.output.id && product.persistence === 'transient');
56
+ }
57
+ //# sourceMappingURL=history-cache.js.map
@@ -5,6 +5,7 @@ import type { FindingIgnoreRule } from '../core/model/finding-ignore.js';
5
5
  import type { Report } from '../core/model/report.js';
6
6
  import type { FindingInput } from '../core/model/scanner-import.js';
7
7
  import type { AnalysisExecutor, InspectionPorts } from '../core/usecases/inspect.js';
8
+ import type { HistoryCache } from './history-cache.js';
8
9
  export { analyzeSnapshot } from './analyze-snapshot.js';
9
10
  export type { AnalysisExecutor, AnalysisInput, InspectionPorts } from '../core/usecases/inspect.js';
10
11
  export interface InspectRequest {
@@ -16,6 +17,7 @@ export interface InspectRequest {
16
17
  readonly revision: string;
17
18
  };
18
19
  readonly lcov?: LcovFiles;
20
+ readonly goCover?: LcovFiles;
19
21
  readonly exclude?: readonly string[];
20
22
  readonly findingInputs?: readonly FindingInput[];
21
23
  readonly findingRoot?: string;
@@ -24,5 +26,8 @@ export interface InspectRequest {
24
26
  readonly plugins?: readonly Plugin[];
25
27
  readonly operationCache?: OperationCacheOptions;
26
28
  }
27
- export declare function inspect(request: InspectRequest, overrides?: AnalysisExecutor | Partial<InspectionPorts>): Promise<Report>;
29
+ export declare function inspect(request: InspectRequest, overrides?: AnalysisExecutor | Partial<InspectionPorts>, { history, deferSummary }?: {
30
+ history?: HistoryCache;
31
+ deferSummary?: boolean;
32
+ }): Promise<Report>;
28
33
  export declare function attachFindings(report: Report, inputs: readonly FindingInput[], root: string, findingRoot: string, excludes: (path: string) => boolean): Promise<Report>;
@@ -2,37 +2,37 @@ import { resolve } from 'node:path';
2
2
  import { gitTreeFiles } from '../api/git/git.js';
3
3
  import { readInspectionSource } from '../api/git/inspection-source.js';
4
4
  import { importFindings } from '../api/import/finding-import.js';
5
- import { readLcovFiles } from '../api/import/lcov-files.js';
5
+ import { readInspectionCoverage } from './inspection-coverage.js';
6
6
  import { reportSchema } from '../core/model/report.js';
7
7
  import { isExcludedDirectory } from '../core/model/snapshot.js';
8
8
  import { executeInspection } from '../core/usecases/inspect.js';
9
9
  import { LocalReportStore } from '../report/json/store/local-store.js';
10
10
  import { analyzeSnapshot, inspectionFileMatcher } from './analyze-snapshot.js';
11
11
  import { attachChurn } from './attach-churn.js';
12
- import { defaultLanguages, languageRegistry } from './languages.js';
12
+ import { languageRegistry } from './languages.js';
13
13
  export { analyzeSnapshot } from './analyze-snapshot.js';
14
- export async function inspect(request, overrides) {
15
- const { lcov, findingInputs = [], plugins = [], operationCache } = request;
14
+ export async function inspect(request, overrides, { history, deferSummary = false } = {}) {
15
+ const { lcov, goCover, findingInputs = [], plugins = [], operationCache } = request;
16
16
  if ((plugins.length || operationCache) && (typeof overrides === 'function' || overrides?.analyze)) {
17
17
  throw new Error('Configure plugins and the operation cache on the custom executor');
18
18
  }
19
- const languages = plugins.length ? languageRegistry(plugins) : defaultLanguages;
19
+ const languages = languageRegistry(plugins);
20
20
  const claims = inspectionFileMatcher(plugins, languages);
21
21
  const { isSource } = languages;
22
22
  const ports = {
23
- readSource: excludes => readSource(request, excludes, isSource, claims),
24
- analyze: input => analyzeSnapshot(input, plugins, operationCache),
25
- ...(lcov === undefined ? {} : { readCoverage: () => readLcovFiles(lcov) }),
23
+ readSource: excludes => readSource(request, excludes, isSource, claims, deferSummary),
24
+ analyze: input => analyzeSnapshot(input, plugins, operationCache, history),
25
+ ...(lcov === undefined && goCover === undefined ? {} : { readCoverage: source => readInspectionCoverage({ lcov, goCover }, source) }),
26
26
  ...(findingInputs.length === 0 ? {} : { importFindings: (report, root, excludes) => attachFindings(report, findingInputs, root, request.findingRoot === undefined ? root : resolve(request.findingRoot), excludes) }),
27
27
  recordChurn: (report, root, paths) => attachChurn(report, root, paths.filter(isSource)),
28
28
  ...(typeof overrides === 'function' ? { analyze: overrides } : overrides),
29
29
  };
30
30
  return executeInspection(request, ports);
31
31
  }
32
- async function readSource(request, excludes, isSource, claims) {
32
+ async function readSource(request, excludes, isSource, claims, deferSummary) {
33
33
  const source = await readInspectionSource(request, excludes, isSource, claims);
34
34
  const store = new LocalReportStore(source.output);
35
- return { ...source, save: (report) => store.save(report) };
35
+ return { ...source, save: (report) => store.save(report, { deferSummary }) };
36
36
  }
37
37
  export async function attachFindings(report, inputs, root, findingRoot, excludes) {
38
38
  const known = report.subject.kind === 'commit'
@@ -0,0 +1,9 @@
1
+ import type { CoverageInputs } from '../api/import/lcov-files.js';
2
+ import type { SourceSnapshot } from '../core/model/source.js';
3
+ export declare function readInspectionCoverage(inputs: CoverageInputs, { root, snapshot }: {
4
+ root: string;
5
+ snapshot: SourceSnapshot;
6
+ }): Promise<{
7
+ text: string;
8
+ inputDigests: string[];
9
+ }>;
@@ -0,0 +1,9 @@
1
+ import { gitText } from '../api/git/git.js';
2
+ import { readCoverageFiles } from '../api/import/lcov-files.js';
3
+ export function readInspectionCoverage(inputs, { root, snapshot }) {
4
+ const { subject } = snapshot;
5
+ const readCommittedManifest = subject.kind === 'commit'
6
+ ? (path) => gitText(root, ['cat-file', 'blob', `${subject.id}:${path}`]) : undefined;
7
+ return readCoverageFiles(inputs, { root, snapshot, readCommittedManifest });
8
+ }
9
+ //# sourceMappingURL=inspection-coverage.js.map
@@ -1,6 +1,7 @@
1
1
  import type { FileClaims, Operation, Plugin } from '../core/engine/plugin.js';
2
2
  import { fileTypeId } from '../core/model/file-types.js';
3
3
  import type { LanguageDisplay } from '../core/model/language.js';
4
+ import type { NativeLanguagePlugin } from './native-language-plugins.js';
4
5
  export interface LanguageProvider {
5
6
  readonly plugin: Plugin;
6
7
  readonly operation: Operation;
@@ -16,8 +17,10 @@ export declare const defaultLanguages: {
16
17
  readonly globs: readonly string[];
17
18
  readonly catalog: readonly LanguageDisplay[];
18
19
  readonly providers: readonly LanguageProvider[];
20
+ readonly native: readonly NativeLanguagePlugin[];
21
+ skipped(path: string): boolean;
19
22
  };
20
- export declare function languageRegistry(plugins: readonly Plugin[]): {
23
+ export declare function languageRegistry(plugins: readonly Plugin[], includeNative?: boolean): {
21
24
  select(path: string): LanguageProvider | undefined;
22
25
  isSource(path: string): boolean;
23
26
  id(path: string): string;
@@ -25,5 +28,7 @@ export declare function languageRegistry(plugins: readonly Plugin[]): {
25
28
  readonly globs: readonly string[];
26
29
  readonly catalog: readonly LanguageDisplay[];
27
30
  readonly providers: readonly LanguageProvider[];
31
+ readonly native: readonly NativeLanguagePlugin[];
32
+ skipped(path: string): boolean;
28
33
  };
29
34
  export declare function claimMatcher(claims: FileClaims | undefined, identify?: typeof fileTypeId): (path: string) => boolean;
@@ -3,10 +3,19 @@ import { fileTypeId } from '../core/model/file-types.js';
3
3
  import { codeStructure, codeStructures } from '../core/model/code-structure.js';
4
4
  import { isExcludedDirectory } from '../core/model/snapshot.js';
5
5
  import { exclusionMatcher } from '../core/profile/exclusions.js';
6
+ import { nativeLanguagePlugins } from './native-language-plugins.js';
7
+ import { restrictStructureMeasures } from './structure-measures.js';
6
8
  import { babelProvider } from '../plugins/language-js/babel-provider.js';
7
- export const defaultLanguages = languageRegistry([]);
8
- export function languageRegistry(plugins) {
9
- const entries = [babelProvider, ...plugins.filter(plugin => plugin.kinds?.includes('language'))].map(plugin => {
9
+ export const defaultLanguages = languageRegistry([], false);
10
+ export function languageRegistry(plugins, includeNative = true) {
11
+ const languagePlugins = plugins.filter(plugin => plugin.kinds?.includes('language'));
12
+ const configured = new Set(languagePlugins.flatMap(plugin => plugin.providesLanguages?.map(language => language.id) ?? []));
13
+ const native = includeNative ? nativeLanguagePlugins().filter(plugin => plugin.providesLanguages?.every(language => !configured.has(language.id))) : [];
14
+ const nativeIds = new Set(native.map(({ id }) => id));
15
+ const unavailable = native.filter(plugin => plugin.unavailableReason !== undefined).flatMap(plugin => plugin.providesLanguages ?? []);
16
+ const skippedClaims = unavailable.map(claim => claimMatcher(claim));
17
+ const enabled = native.filter(plugin => plugin.unavailableReason === undefined);
18
+ const entries = [babelProvider, ...languagePlugins, ...enabled].map(plugin => {
10
19
  const operations = plugin.operations.filter(operation => operation.role === 'provider'
11
20
  && operation.output.id === (operation.scope === 'repository' ? codeStructures.id : codeStructure.id));
12
21
  const [operation] = operations;
@@ -26,11 +35,13 @@ export function languageRegistry(plugins) {
26
35
  }
27
36
  return found;
28
37
  }
29
- const provider = { plugin, operation, key: `${plugin.id}/${operation.id}`, batch: operation.scope === 'repository', language };
38
+ const bound = restrictStructureMeasures(operation, declared, language);
39
+ const executable = bound === operation ? plugin : { ...plugin, operations: plugin.operations.map(item => item === operation ? bound : item) };
40
+ const provider = { plugin: executable, operation: bound, key: `${plugin.id}/${operation.id}`, batch: operation.scope === 'repository', language };
30
41
  const claims = declared.length ? declared : [plugin.claims];
31
42
  return { provider, claims, matches: declared.length ? (path) => language(path) !== undefined : claimMatcher(plugin.claims) };
32
43
  });
33
- const claims = entries.flatMap(entry => entry.claims);
44
+ const claims = [...entries.flatMap(entry => entry.claims), ...unavailable];
34
45
  const extensions = [...new Set(claims.flatMap(entry => entry.extensions ?? []))];
35
46
  const globs = [...new Set(claims.flatMap(entry => entry.globs ?? []))];
36
47
  const providers = entries.map(({ provider }) => provider);
@@ -39,8 +50,11 @@ export function languageRegistry(plugins) {
39
50
  })));
40
51
  if (new Set(catalog.map(({ id }) => id)).size !== catalog.length)
41
52
  throw new Error('Duplicate provided language ID');
42
- return { select, isSource: path => select(path) !== undefined, id: path => select(path)?.language(path) ?? fileTypeId(path), extensions, globs,
43
- catalog, providers };
53
+ return { select, isSource: path => select(path) !== undefined || skipped(path), id: path => select(path)?.language(path) ?? fileTypeId(path), extensions, globs,
54
+ catalog, providers, native, skipped };
55
+ function skipped(path) {
56
+ return skippedClaims.some(matches => matches(path)) && !path.split('/').slice(0, -1).some(isExcludedDirectory);
57
+ }
44
58
  function select(path) {
45
59
  let selected;
46
60
  for (const { provider, matches } of entries) {
@@ -48,6 +62,8 @@ export function languageRegistry(plugins) {
48
62
  continue;
49
63
  if (!selected && path.split('/').slice(0, -1).some(isExcludedDirectory))
50
64
  return undefined;
65
+ if (selected && nativeIds.has(provider.plugin.id))
66
+ continue;
51
67
  if (selected)
52
68
  throw new Error(`Multiple language providers claim ${path}: ${selected.plugin.id}, ${provider.plugin.id}`);
53
69
  selected = provider;
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '../core/engine/plugin.js';
2
+ export interface NativeLanguagePlugin extends Plugin {
3
+ readonly unavailableReason?: string;
4
+ }
5
+ export declare const nativeLanguageIds: ("go-ast" | "python-ast")[];
6
+ export declare function nativeLanguagePlugins(): readonly NativeLanguagePlugin[];
@@ -0,0 +1,40 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { HostLanguageRunner, hostToolPath, hostToolVersion } from '../api/process/host-language-runner.js';
4
+ import { bindProcessPlugin } from '../api/process/plugin.js';
5
+ import { pluginApi } from '../core/engine/plugin.js';
6
+ import { codeStructures } from '../core/model/code-structure.js';
7
+ import { fileTypes } from '../core/model/file-types.js';
8
+ import { duplicationSettings } from '../core/profile/maintainability.js';
9
+ import { digest, sourceFiles } from '../core/model/snapshot.js';
10
+ const measures = ['functions', 'cyclomaticComplexity', 'cognitiveComplexity', 'commentLines', 'codeLines',
11
+ 'structuralRules', 'duplication'];
12
+ const descriptors = [
13
+ { id: 'go-ast', language: 'go', binary: 'go', args: ['run'], versionArgs: ['version'], script: 'go/parser.go', measures },
14
+ { id: 'python-ast', language: 'python', binary: 'python3', args: ['-I', '-S'], versionArgs: ['--version'],
15
+ script: 'python/parser.py', measures: [...measures, 'classes'] },
16
+ ];
17
+ export const nativeLanguageIds = descriptors.map(({ id }) => id);
18
+ let cached;
19
+ export function nativeLanguagePlugins() {
20
+ const path = hostToolPath();
21
+ if (cached?.path !== path)
22
+ cached = { path, plugins: descriptors.map(descriptor => createPlugin(descriptor, path)) };
23
+ return cached.plugins;
24
+ }
25
+ function createPlugin({ id, language, binary, args, versionArgs, script, measures }, path) {
26
+ const declaration = { ...fileTypes.find(type => type.id === language), measures };
27
+ const manifest = { id, version: '1.1.0', api: pluginApi, kinds: ['language'],
28
+ settings: { duplication: duplicationSettings },
29
+ providesLanguages: [declaration], produces: [{ contract: codeStructures.id, persistence: 'transient' }] };
30
+ const version = hostToolVersion(binary, versionArgs, path)?.match(/\b(?:go|Python\s+)(\d+(?:\.\d+)+(?:[a-z][\w.-]*)?)/i)?.[1];
31
+ if (version === undefined) {
32
+ return { ...manifest, operations: [], unavailableReason: `${binary} not found on PATH` };
33
+ }
34
+ const parser = fileURLToPath(new URL(`../resources/languages/${script}`, import.meta.resolve('repometry/plugin')));
35
+ return bindProcessPlugin({ ...manifest, tools: { [binary]: version }, operations: [{ id: 'parse', role: 'provider',
36
+ scope: 'repository', fileIndependent: true, inputs: { files: sourceFiles }, output: codeStructures,
37
+ argv: [binary, ...args], timeoutMs: 90_000, maxOutputBytes: 16 * 1024 * 1024, implementation: digest(readFileSync(parser)),
38
+ }] }, new HostLanguageRunner(path, parser));
39
+ }
40
+ //# sourceMappingURL=native-language-plugins.js.map
@@ -1,6 +1,10 @@
1
- export declare const builtInPlugins: {
1
+ import type { Plugin } from '../core/engine/plugin.js';
2
+ export declare const builtInPluginIds: Set<string>;
3
+ export declare function effectivePlugins(additional: readonly Plugin[]): {
2
4
  id: string;
3
5
  version: string;
4
- kinds: readonly import("../plugin.js").PluginKind[];
5
- claims?: import("../plugin.js").FileClaims | undefined;
6
+ kinds: readonly import("../core/engine/plugin.js").PluginKind[];
7
+ claims?: import("../core/engine/plugin.js").FileClaims | undefined;
8
+ providesLanguages?: readonly import("../plugin.js").ProvidedLanguage[] | undefined;
9
+ unavailableReason?: string | undefined;
6
10
  }[];
@@ -3,9 +3,19 @@ import { diffCoverage } from '../plugins/coverage/diff-coverage.js';
3
3
  import { duplication } from '../plugins/duplication/duplication.js';
4
4
  import { maintainability } from '../plugins/maintainability/maintainability.js';
5
5
  import { structure } from '../plugins/structure/structure.js';
6
- import { defaultLanguages } from './languages.js';
6
+ import { nativeLanguageIds } from './native-language-plugins.js';
7
+ import { defaultLanguages, languageRegistry } from './languages.js';
7
8
  import { sourceProviders } from './sources.js';
8
9
  import { securityPlugins } from './security-plugins.js';
9
- export const builtInPlugins = [...defaultLanguages.providers.map(({ plugin }) => plugin), structure, maintainability, duplication, coverage, diffCoverage, ...securityPlugins, ...sourceProviders]
10
- .map(({ id, version, kinds, claims }) => ({ id, version, kinds, ...(claims ? { claims } : {}) }));
10
+ const builtInPlugins = [...defaultLanguages.providers.map(({ plugin }) => plugin), structure, maintainability, duplication, coverage,
11
+ diffCoverage, ...securityPlugins, ...sourceProviders];
12
+ export const builtInPluginIds = new Set([...builtInPlugins.map(({ id }) => id), ...nativeLanguageIds]);
13
+ export function effectivePlugins(additional) {
14
+ const native = languageRegistry(additional).native.map(plugin => ({ ...describePlugin(plugin), ...(plugin.tools ? { tools: plugin.tools } : {}) }));
15
+ return [...builtInPlugins.map(describePlugin), ...native, ...additional.map(describePlugin)];
16
+ }
17
+ function describePlugin({ id, version, kinds, claims, providesLanguages, unavailableReason }) {
18
+ return { id, version, kinds, ...(claims ? { claims } : {}), ...(providesLanguages ? { providesLanguages } : {}),
19
+ ...(unavailableReason ? { unavailableReason } : {}) };
20
+ }
11
21
  //# sourceMappingURL=plugin-list.js.map
@@ -12,6 +12,6 @@ export async function prepareMetabranch({ repository, worktree, branch, report }
12
12
  }
13
13
  const target = await openMetabranchWorktree(repository, worktree, branch, report.subject.id);
14
14
  await new LocalReportStore(target).save(report);
15
- return ['manifest.json', 'summary.json', `commits/${report.subject.id}/report.json`];
15
+ return ['manifest.json', 'summary.json', 'objects', `commits/${report.subject.id}/report.json`];
16
16
  }
17
17
  //# sourceMappingURL=prepare-metabranch.js.map
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from '../core/engine/plugin.js';
2
+ export declare function readProcessPlugins(value: unknown): readonly Plugin[];
@@ -0,0 +1,64 @@
1
+ import { Ajv2020 } from 'ajv/dist/2020.js';
2
+ import schema from '../../resources/config/process-plugins-v1.schema.json' with { type: 'json' };
3
+ import { DockerToolRunner } from '../api/process/docker-tool-runner.js';
4
+ import { processPlugin } from '../api/process/plugin.js';
5
+ import { pluginApi } from '../core/engine/plugin.js';
6
+ import { codeStructure, codeStructures } from '../core/model/code-structure.js';
7
+ import { sourceFile, sourceFiles } from '../core/model/snapshot.js';
8
+ import { languageRegistry } from './languages.js';
9
+ import { builtInPluginIds } from './plugin-list.js';
10
+ let check;
11
+ export function readProcessPlugins(value) {
12
+ if (value === undefined)
13
+ return [];
14
+ const validate = check ??= new Ajv2020().compile(schema);
15
+ if (!validate(value)) {
16
+ const error = validate.errors?.[0];
17
+ throw new Error(`Config plugins${error?.instancePath ?? ''} ${error?.message ?? 'is invalid'}`);
18
+ }
19
+ const ids = new Set(builtInPluginIds);
20
+ const plugins = value.map((definition, index) => {
21
+ if (ids.has(definition.id))
22
+ throw new Error(`Config plugins/${index}/id duplicates plugin ${definition.id}`);
23
+ ids.add(definition.id);
24
+ return configuredPlugin(definition, index);
25
+ });
26
+ languageRegistry(plugins, false);
27
+ return plugins;
28
+ }
29
+ function configuredPlugin(definition, index) {
30
+ const { id, version, image, command, scope, fileIndependent, claims, limits = {}, tools, settings, providesLanguages } = definition;
31
+ const base = `Config plugins/${index}`;
32
+ if (!command[0]?.trim())
33
+ throw new Error(`${base}/command/0 must name an executable`);
34
+ const languages = providesLanguages.map((language, languageIndex) => {
35
+ const selectors = providesLanguages.length === 1 ? { ...claims, ...language } : language;
36
+ if (!selectors.extensions?.length && !selectors.globs?.length) {
37
+ throw new Error(`${base}/providesLanguages/${languageIndex} must claim an extension or glob`);
38
+ }
39
+ return selectors;
40
+ });
41
+ const effective = effectiveClaims(languages, claims, base);
42
+ const repository = scope === 'repository';
43
+ const output = repository ? codeStructures : codeStructure;
44
+ return processPlugin({ id, version, api: pluginApi, kinds: ['language'], tools, claims: effective, providesLanguages: languages,
45
+ ...(settings === undefined ? {} : { settings }),
46
+ produces: [{ contract: output.id, persistence: 'transient' }],
47
+ operations: [{ id: 'parse', role: 'provider', scope, fileIndependent, inputs: repository ? { files: sourceFiles } : { source: sourceFile },
48
+ output, argv: command, timeoutMs: limits.timeoutMs ?? 30_000, maxOutputBytes: limits.maxOutputBytes ?? 8 * 1024 * 1024 }],
49
+ }, new DockerToolRunner(image, { memoryBytes: limits.memoryBytes ?? 512 * 1024 * 1024, pidsLimit: limits.pidsLimit ?? 128 }));
50
+ }
51
+ function effectiveClaims(languages, declared, base) {
52
+ const selectors = {};
53
+ for (const key of ['extensions', 'globs']) {
54
+ const union = new Set(languages.flatMap(language => language[key] ?? []));
55
+ const expected = declared?.[key];
56
+ if (expected !== undefined && (expected.length !== union.size || expected.some(value => !union.has(value)))) {
57
+ throw new Error(`${base}/claims/${key} must match the claims of its languages`);
58
+ }
59
+ if (union.size)
60
+ selectors[key] = [...union];
61
+ }
62
+ return selectors;
63
+ }
64
+ //# sourceMappingURL=process-plugins.js.map
@@ -3,8 +3,7 @@ import type { ReportReader } from '../core/ports/report.js';
3
3
  import type { ReviewPorts } from '../core/usecases/review.js';
4
4
  import type { DiffCoverageRequest } from './diff-coverage.js';
5
5
  export { projectReview, reviewExitCode } from '../core/usecases/review.js';
6
- export interface ReviewRequest extends Omit<DiffCoverageRequest, 'lcov'> {
7
- readonly lcov?: DiffCoverageRequest['lcov'];
6
+ export interface ReviewRequest extends DiffCoverageRequest {
8
7
  readonly number?: number;
9
8
  readonly minimumLines?: number;
10
9
  readonly maxCoverageDrop?: number;
@@ -13,7 +13,7 @@ export async function reviewPull(request, current, baseline = current) {
13
13
  }
14
14
  export async function review(request, overrides) {
15
15
  const store = new LocalReportStore(resolve(request.output ?? resolve(request.directory, '.repometry')));
16
- const { lcov } = request;
16
+ const { lcov, goCover } = request;
17
17
  return executeReview(request, {
18
18
  readHead: id => readIfAvailable(store, id),
19
19
  readBase: id => readIfAvailable(store, id),
@@ -22,7 +22,7 @@ export async function review(request, overrides) {
22
22
  const [head, base] = await Promise.all([resolveGitCommit(directory, request.revision), resolveGitCommit(directory, request.base)]);
23
23
  return { head, base, mergeBase: () => findMergeBase(directory, base, head) };
24
24
  },
25
- ...(lcov === undefined ? {} : { measureChanged: () => measureChangedLines({ ...request, lcov }) }),
25
+ ...(lcov === undefined && goCover === undefined ? {} : { measureChanged: () => measureChangedLines(request) }),
26
26
  ...overrides,
27
27
  });
28
28
  }
@@ -0,0 +1,5 @@
1
+ import type { Operation } from '../core/engine/plugin.js';
2
+ import type { CodeStructure, StructureMeasure } from '../core/model/code-structure.js';
3
+ import type { ProvidedLanguage } from '../core/model/language.js';
4
+ export declare function restrictStructureMeasures(operation: Operation, declared: readonly ProvidedLanguage[], language: (path: string) => string | undefined): Operation;
5
+ export declare function unmeasuredStructure(facts: CodeStructure): readonly StructureMeasure[];