repometry 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -17
- package/package.json +1 -1
- package/target/main/resources/report/json/comparison-v1.schema.json +6 -6
- package/target/main/resources/report/json/file-metrics-v1.schema.json +7 -6
- package/target/main/resources/report/json/pull-review-v1.schema.json +5 -5
- package/target/main/resources/report/json/report-v2.schema.json +197 -10
- package/target/main/resources/report/json/repository-summary-v1.schema.json +161 -14
- package/target/main/resources/report/json/viewer-inspection-v1.schema.json +518 -6
- package/target/main/resources/viewer/styles.css +5 -0
- package/target/main/ts/api/git/changes.d.ts +1 -1
- package/target/main/ts/api/git/changes.js +3 -3
- package/target/main/ts/api/git/commit-metadata.js +6 -4
- package/target/main/ts/api/git/git.d.ts +1 -1
- package/target/main/ts/api/git/git.js +4 -4
- package/target/main/ts/api/git/inspection-source.d.ts +1 -1
- package/target/main/ts/api/git/inspection-source.js +3 -3
- package/target/main/ts/api/git/local.d.ts +1 -1
- package/target/main/ts/api/git/local.js +4 -4
- package/target/main/ts/api/worker/remote-executor.d.ts +1 -1
- package/target/main/ts/api/worker/remote-executor.js +2 -2
- package/target/main/ts/api/worker/worker-protocol.d.ts +2 -2
- package/target/main/ts/api/worker/worker-protocol.js +8 -8
- package/target/main/ts/api/worker/worker.d.ts +1 -1
- package/target/main/ts/api/worker/worker.js +4 -4
- package/target/main/ts/cli/main.js +4 -3
- package/target/main/ts/cli/reporting.d.ts +1 -1
- package/target/main/ts/cli/reporting.js +1 -1
- package/target/main/ts/compose/analysis-files.d.ts +13 -0
- package/target/main/ts/compose/analysis-files.js +95 -0
- package/target/main/ts/compose/analysis-imports.d.ts +7 -0
- package/target/main/ts/compose/analysis-imports.js +34 -0
- package/target/main/ts/compose/analysis-report.d.ts +5 -0
- package/target/main/ts/compose/analysis-report.js +78 -0
- package/target/main/ts/compose/analysis-repository.d.ts +6 -0
- package/target/main/ts/compose/analysis-repository.js +61 -0
- package/target/main/ts/compose/analysis-results.d.ts +38 -0
- package/target/main/ts/compose/analysis-results.js +78 -0
- package/target/main/ts/compose/analysis-sources.d.ts +73 -0
- package/target/main/ts/compose/analysis-sources.js +47 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +2 -2
- package/target/main/ts/compose/analyze-snapshot.js +19 -250
- package/target/main/ts/compose/diff-coverage.d.ts +2 -0
- package/target/main/ts/compose/diff-coverage.js +6 -4
- package/target/main/ts/compose/inspect.js +8 -5
- package/target/main/ts/compose/languages.d.ts +29 -0
- package/target/main/ts/compose/languages.js +87 -0
- package/target/main/ts/compose/sources.js +14 -12
- package/target/main/ts/core/engine/manifest.d.ts +2 -2
- package/target/main/ts/core/engine/manifest.js +25 -5
- package/target/main/ts/core/engine/plan.d.ts +2 -4
- package/target/main/ts/core/engine/plan.js +13 -15
- package/target/main/ts/core/engine/plugin.d.ts +2 -1
- package/target/main/ts/core/model/clone-source.d.ts +1 -0
- package/target/main/ts/core/model/clone-source.js +1 -0
- package/target/main/ts/core/model/code-structure.d.ts +2 -0
- package/target/main/ts/core/model/code-structure.js +6 -0
- package/target/main/ts/core/model/language.d.ts +10 -0
- package/target/main/ts/core/model/language.js +6 -0
- package/target/main/ts/core/model/measurement.d.ts +7 -6
- package/target/main/ts/core/model/measurement.js +17 -6
- package/target/main/ts/core/model/plugin-data.d.ts +3 -0
- package/target/main/ts/core/model/quality-summary.js +5 -4
- package/target/main/ts/core/model/report.d.ts +1 -2
- package/target/main/ts/core/model/report.js +0 -1
- package/target/main/ts/core/model/snapshot.d.ts +0 -2
- package/target/main/ts/core/model/snapshot.js +0 -6
- package/target/main/ts/core/usecases/compare.js +61 -17
- package/target/main/ts/core/usecases/inspect.js +2 -2
- package/target/main/ts/plugin.d.ts +3 -2
- package/target/main/ts/plugin.js +1 -1
- package/target/main/ts/plugins/duplication/duplication.js +10 -4
- package/target/main/ts/plugins/language-js/babel-provider.js +8 -2
- package/target/main/ts/plugins/language-js/extensions.d.ts +3 -0
- package/target/main/ts/plugins/language-js/extensions.js +4 -0
- package/target/main/ts/plugins/language-js/js-security.js +3 -2
- package/target/main/ts/report/html/app/viewer-data.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-data.js +2 -29
- package/target/main/ts/report/html/app/viewer-metric-registry.js +7 -7
- package/target/main/ts/report/html/app/viewer-overview-cards.js +8 -2
- package/target/main/ts/report/html/app/viewer-route.d.ts +2 -2
- package/target/main/ts/report/html/app/viewer-route.js +3 -3
- package/target/main/ts/report/html/app/viewer-trend-data.d.ts +6 -1
- package/target/main/ts/report/html/app/viewer-trend-data.js +6 -2
- package/target/main/ts/report/html/app/viewer.js +3 -3
- package/target/main/ts/report/html/site/export-site.d.ts +3 -4
- package/target/main/ts/report/html/site/export-site.js +24 -41
- package/target/main/ts/report/html/site/exported-server.js +2 -1
- package/target/main/ts/report/html/site/local-server.d.ts +1 -1
- package/target/main/ts/report/html/site/local-server.js +13 -19
- package/target/main/ts/report/html/site/projects.js +8 -17
- package/target/main/ts/report/json/projections/commit-summary.d.ts +2 -2
- package/target/main/ts/report/json/projections/commit-summary.js +18 -19
- package/target/main/ts/report/json/projections/file-metrics.js +31 -24
- package/target/main/ts/report/json/projections/inspection-context.js +10 -1
- package/target/main/ts/report/json/projections/inspection-details.d.ts +1 -1
- package/target/main/ts/report/json/projections/inspection-details.js +2 -2
- package/target/main/ts/report/json/projections/metric-values.d.ts +1 -0
- package/target/main/ts/report/json/projections/metric-values.js +15 -5
- package/target/main/ts/report/json/store/pull-review-store.js +1 -2
- package/target/main/ts/report/json/validation/report.d.ts +1 -1
- package/target/main/ts/report/json/validation/report.js +10 -8
- package/target/main/ts/report/json/validation/summary-validation.js +1 -3
- package/target/main/ts/report/json/wire/file-metrics-model.d.ts +2 -0
- package/target/main/ts/report/json/wire/inspection-details-model.d.ts +0 -5
- package/target/main/ts/report/json/wire/public-history-model.d.ts +0 -6
- package/target/main/ts/report/json/wire/public-history-model.js +0 -1
- package/target/main/ts/report.d.ts +2 -3
- package/target/main/ts/report.js +1 -2
- package/target/main/resources/report/json/inspection-context-v1.schema.json +0 -172
- package/target/main/resources/report/json/public-history-v1.schema.json +0 -50
- package/target/main/resources/report/json/quality-history-v1.schema.json +0 -51
- package/target/main/resources/report/json/report-v1.schema.json +0 -65
- package/target/main/resources/report/json/viewer-details-v1.schema.json +0 -346
- package/target/main/ts/report/json/projections/public-history.d.ts +0 -4
- package/target/main/ts/report/json/projections/public-history.js +0 -17
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { lstat, readdir, realpath, readFile } from 'node:fs/promises';
|
|
2
2
|
import { isAbsolute, join, posix, relative, sep } from 'node:path';
|
|
3
|
-
import { comparePaths, isExcludedDirectory,
|
|
3
|
+
import { comparePaths, isExcludedDirectory, workingSnapshot } from '../../core/model/snapshot.js';
|
|
4
4
|
import { isClaimedText, maxClaimedFileBytes } from '../../core/model/source.js';
|
|
5
5
|
import { isGeneratedSource } from '../../core/profile/exclusions.js';
|
|
6
6
|
export function containsPath(parent, path) {
|
|
7
7
|
const rest = relative(parent, path);
|
|
8
8
|
return rest === '' || (!isAbsolute(rest) && rest !== '..' && !rest.startsWith(`..${sep}`));
|
|
9
9
|
}
|
|
10
|
-
export async function readWorkingTree(directory, output, excludes, claims, gitPaths) {
|
|
10
|
+
export async function readWorkingTree(directory, output, excludes, isSource, claims, gitPaths) {
|
|
11
11
|
const root = await realpath(directory);
|
|
12
12
|
const files = [];
|
|
13
13
|
const generatedExcluded = [];
|
|
@@ -28,7 +28,7 @@ export async function readWorkingTree(directory, output, excludes, claims, gitPa
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
async function read(path, absolute, size) {
|
|
31
|
-
if (
|
|
31
|
+
if (isSource(path)) {
|
|
32
32
|
const bytes = await readFile(absolute);
|
|
33
33
|
if (isGeneratedSource(bytes))
|
|
34
34
|
generatedExcluded.push(path);
|
|
@@ -66,7 +66,7 @@ export async function readWorkingTree(directory, output, excludes, claims, gitPa
|
|
|
66
66
|
const absolute = join(root, path);
|
|
67
67
|
if (excludes(path) || !containsPath(root, absolute) || containsPath(output, absolute))
|
|
68
68
|
continue;
|
|
69
|
-
if (!(
|
|
69
|
+
if (!(isSource(path) || claims?.(path)) || !await regularDirectory(posix.dirname(path)))
|
|
70
70
|
continue;
|
|
71
71
|
const stat = await statIfPresent(absolute);
|
|
72
72
|
if (stat?.isFile())
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { AnalysisExecutor } from '../../core/usecases/inspect.js';
|
|
2
|
-
export declare function remoteExecutor(endpoint: string, token: string): AnalysisExecutor;
|
|
2
|
+
export declare function remoteExecutor(endpoint: string, token: string, isSource: (path: string) => boolean): AnalysisExecutor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readReport } from '../../report/json/validation/report.js';
|
|
2
2
|
import { encodeWorkerInput, maxWorkerInput, maxWorkerResult, workerRoute } from './worker-protocol.js';
|
|
3
|
-
export function remoteExecutor(endpoint, token) {
|
|
3
|
+
export function remoteExecutor(endpoint, token, isSource) {
|
|
4
4
|
const base = new URL(endpoint);
|
|
5
5
|
const local = ['127.0.0.1', '[::1]', 'localhost'].includes(base.hostname);
|
|
6
6
|
if (base.protocol !== 'https:' && !(base.protocol === 'http:' && local)) {
|
|
@@ -10,7 +10,7 @@ export function remoteExecutor(endpoint, token) {
|
|
|
10
10
|
throw new Error('Invalid worker base URL');
|
|
11
11
|
base.pathname = base.pathname.replace(/\/+$/, '') + workerRoute;
|
|
12
12
|
return async (input) => {
|
|
13
|
-
const body = encodeWorkerInput(input);
|
|
13
|
+
const body = encodeWorkerInput(input, isSource);
|
|
14
14
|
if (Buffer.byteLength(body) > maxWorkerInput)
|
|
15
15
|
throw new Error('Worker input exceeds 16 MiB');
|
|
16
16
|
const response = await fetch(base, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
@@ -3,5 +3,5 @@ export declare const workerRoute = "/v1/inspect";
|
|
|
3
3
|
export declare const maxWorkerInput: number;
|
|
4
4
|
export declare const maxWorkerResult: number;
|
|
5
5
|
export declare function workerToken(value?: string | undefined): string;
|
|
6
|
-
export declare function encodeWorkerInput(input: AnalysisInput): string;
|
|
7
|
-
export declare function decodeWorkerInput(value: unknown): AnalysisInput;
|
|
6
|
+
export declare function encodeWorkerInput(input: AnalysisInput, isSource: (path: string) => boolean): string;
|
|
7
|
+
export declare function decodeWorkerInput(value: unknown, isSource: (path: string) => boolean): AnalysisInput;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isRecord } from '../../core/engine/plugin.js';
|
|
2
2
|
import { validSubjectId } from '../../report/json/validation/report.js';
|
|
3
3
|
import { exclusionMatcher, normalizeExclusions, sourceExclusionMatcher } from '../../core/profile/exclusions.js';
|
|
4
|
-
import { comparePaths, isExcludedDirectory,
|
|
4
|
+
import { comparePaths, isExcludedDirectory, workingSnapshot } from '../../core/model/snapshot.js';
|
|
5
5
|
import { isClaimedText } from '../../core/model/source.js';
|
|
6
6
|
const schemaV1 = 'urn:repometry:schema:worker-input:1';
|
|
7
7
|
const schemaV2 = 'urn:repometry:schema:worker-input:2';
|
|
@@ -14,17 +14,17 @@ export function workerToken(value = process.env.REPOMETRY_WORKER_TOKEN) {
|
|
|
14
14
|
throw new Error('Set REPOMETRY_WORKER_TOKEN before using the worker');
|
|
15
15
|
return value;
|
|
16
16
|
}
|
|
17
|
-
export function encodeWorkerInput(input) {
|
|
17
|
+
export function encodeWorkerInput(input, isSource) {
|
|
18
18
|
const { subject, files, inventory, generatedExcluded, oversizedClaims } = input.snapshot;
|
|
19
19
|
const excludedPaths = input.excludedPaths ?? [];
|
|
20
|
-
const hasClaims = oversizedClaims?.length || files.some(file => !
|
|
20
|
+
const hasClaims = oversizedClaims?.length || files.some(file => !isSource(file.path));
|
|
21
21
|
const profile = hasClaims ? { schema: schemaV3, excludedPaths, oversizedClaims: oversizedClaims ?? [] }
|
|
22
22
|
: excludedPaths.length === 0 ? { schema: schemaV1 } : { schema: schemaV2, excludedPaths };
|
|
23
23
|
return JSON.stringify({ ...profile, subject, excludedOutput: input.excludedOutput, coverage: input.coverage ?? null,
|
|
24
24
|
files: files.map(({ path, bytes }) => ({ path, base64: Buffer.from(bytes).toString('base64') })),
|
|
25
25
|
...(inventory === undefined ? {} : { inventory }), ...(generatedExcluded?.length ? { generatedExcluded } : {}) });
|
|
26
26
|
}
|
|
27
|
-
export function decodeWorkerInput(value) {
|
|
27
|
+
export function decodeWorkerInput(value, isSource) {
|
|
28
28
|
if (!isRecord(value) || (value.schema !== schemaV1 && value.schema !== schemaV2 && value.schema !== schemaV3)
|
|
29
29
|
|| !isSubject(value.subject) || !Array.isArray(value.files)) {
|
|
30
30
|
throw new Error('Invalid worker input envelope');
|
|
@@ -48,7 +48,7 @@ export function decodeWorkerInput(value) {
|
|
|
48
48
|
const bytes = Buffer.from(item.base64, 'base64');
|
|
49
49
|
if (bytes.toString('base64') !== item.base64)
|
|
50
50
|
throw new Error('Invalid worker source encoding');
|
|
51
|
-
if (!
|
|
51
|
+
if (!isSource(item.path) && (value.schema !== schemaV3 || !isClaimedText(bytes) || excludedParent(item.path))) {
|
|
52
52
|
throw new Error('Invalid worker claimed file');
|
|
53
53
|
}
|
|
54
54
|
paths.add(item.path);
|
|
@@ -59,7 +59,7 @@ export function decodeWorkerInput(value) {
|
|
|
59
59
|
}
|
|
60
60
|
files.sort((a, b) => comparePaths(a.path, b.path));
|
|
61
61
|
const inventory = readInventory(value.inventory, excludes);
|
|
62
|
-
const generatedExcluded = readGeneratedExclusions(value.generatedExcluded, paths, inventory);
|
|
62
|
+
const generatedExcluded = readGeneratedExclusions(value.generatedExcluded, paths, isSource, inventory);
|
|
63
63
|
const oversizedClaims = value.schema === schemaV3 ? readOversizedClaims(value.oversizedClaims, paths, excludes) : [];
|
|
64
64
|
return { snapshot: { subject, files, ...(inventory === undefined ? {} : { inventory }), generatedExcluded,
|
|
65
65
|
...(oversizedClaims.length ? { oversizedClaims } : {}) },
|
|
@@ -80,7 +80,7 @@ function readOversizedClaims(value, paths, excludes) {
|
|
|
80
80
|
function excludedParent(path) {
|
|
81
81
|
return path.split('/').slice(0, -1).some(isExcludedDirectory);
|
|
82
82
|
}
|
|
83
|
-
function readGeneratedExclusions(value, sourcePaths, inventory) {
|
|
83
|
+
function readGeneratedExclusions(value, sourcePaths, isSource, inventory) {
|
|
84
84
|
if (value === undefined)
|
|
85
85
|
return [];
|
|
86
86
|
if (!Array.isArray(value))
|
|
@@ -88,7 +88,7 @@ function readGeneratedExclusions(value, sourcePaths, inventory) {
|
|
|
88
88
|
const listed = new Set([...sourcePaths, ...(inventory ?? []).map(file => file.path)]);
|
|
89
89
|
const excluded = new Set();
|
|
90
90
|
for (const path of value) {
|
|
91
|
-
if (typeof path !== 'string' || !safePath(path) || !
|
|
91
|
+
if (typeof path !== 'string' || !safePath(path) || !isSource(path) || listed.has(path) || excluded.has(path)) {
|
|
92
92
|
throw new Error('Invalid worker generated exclusion');
|
|
93
93
|
}
|
|
94
94
|
excluded.add(path);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnalysisExecutor } from '../../core/usecases/inspect.js';
|
|
2
|
-
export declare function serveWorker(host: '127.0.0.1' | '0.0.0.0', port: number, token: string, analyze: AnalysisExecutor): Promise<{
|
|
2
|
+
export declare function serveWorker(host: '127.0.0.1' | '0.0.0.0', port: number, token: string, analyze: AnalysisExecutor, isSource: (path: string) => boolean): Promise<{
|
|
3
3
|
url: string;
|
|
4
4
|
close: () => void;
|
|
5
5
|
}>;
|
|
@@ -2,7 +2,7 @@ import { timingSafeEqual } from 'node:crypto';
|
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
3
|
import { utf8 } from '../../core/model/snapshot.js';
|
|
4
4
|
import { decodeWorkerInput, maxWorkerInput, maxWorkerResult, workerRoute } from './worker-protocol.js';
|
|
5
|
-
export async function serveWorker(host, port, token, analyze) {
|
|
5
|
+
export async function serveWorker(host, port, token, analyze, isSource) {
|
|
6
6
|
let busy = false;
|
|
7
7
|
const server = createServer({ headersTimeout: 10_000, requestTimeout: 30_000, connectionsCheckingInterval: 5_000 }, (request, response) => {
|
|
8
8
|
if (request.url !== workerRoute) {
|
|
@@ -22,7 +22,7 @@ export async function serveWorker(host, port, token, analyze) {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
busy = true;
|
|
25
|
-
void handle(request, response, analyze).finally(() => { busy = false; });
|
|
25
|
+
void handle(request, response, analyze, isSource).finally(() => { busy = false; });
|
|
26
26
|
});
|
|
27
27
|
await new Promise((resolve, reject) => {
|
|
28
28
|
server.once('error', reject);
|
|
@@ -35,7 +35,7 @@ export async function serveWorker(host, port, token, analyze) {
|
|
|
35
35
|
}
|
|
36
36
|
return { url: `http://${host}:${address.port}/`, close: () => server.close() };
|
|
37
37
|
}
|
|
38
|
-
async function handle(request, response, analyze) {
|
|
38
|
+
async function handle(request, response, analyze, isSource) {
|
|
39
39
|
const declared = Number(request.headers['content-length']);
|
|
40
40
|
if (declared > maxWorkerInput) {
|
|
41
41
|
reply(response, 413, 'Worker input exceeds 16 MiB');
|
|
@@ -54,7 +54,7 @@ async function handle(request, response, analyze) {
|
|
|
54
54
|
}
|
|
55
55
|
parts.push(bytes);
|
|
56
56
|
}
|
|
57
|
-
payload = decodeWorkerInput(JSON.parse(utf8(Buffer.concat(parts))));
|
|
57
|
+
payload = decodeWorkerInput(JSON.parse(utf8(Buffer.concat(parts))), isSource);
|
|
58
58
|
}
|
|
59
59
|
catch {
|
|
60
60
|
reply(response, 400, 'Invalid worker input');
|
|
@@ -8,6 +8,7 @@ import { writeGitHubDiffCoverage, writeGitHubResult, writeGitHubReview } from '.
|
|
|
8
8
|
import { remoteExecutor } from '../api/worker/remote-executor.js';
|
|
9
9
|
import { serveWorker } from '../api/worker/worker.js';
|
|
10
10
|
import { workerToken } from '../api/worker/worker-protocol.js';
|
|
11
|
+
import { defaultLanguages } from '../compose/languages.js';
|
|
11
12
|
import { analyzeSnapshot, attachFindings, inspect } from '../compose/inspect.js';
|
|
12
13
|
import { measureDiffCoverage } from '../compose/diff-coverage.js';
|
|
13
14
|
import { prepareMetabranch } from '../compose/prepare-metabranch.js';
|
|
@@ -139,7 +140,7 @@ const commands = {
|
|
|
139
140
|
const host = input.text('listen') ?? '127.0.0.1';
|
|
140
141
|
if (host !== '127.0.0.1' && host !== '0.0.0.0')
|
|
141
142
|
throw new Error('--listen must be 127.0.0.1 or 0.0.0.0');
|
|
142
|
-
announce(await serveWorker(host, port(input.text('port') ?? '7331'), workerToken(), analyzeSnapshot));
|
|
143
|
+
announce(await serveWorker(host, port(input.text('port') ?? '7331'), workerToken(), analyzeSnapshot, defaultLanguages.isSource));
|
|
143
144
|
} },
|
|
144
145
|
};
|
|
145
146
|
async function context(input) {
|
|
@@ -172,7 +173,7 @@ async function analyze(input) {
|
|
|
172
173
|
const report = skipped ? await store.reader.read({ kind: 'commit', id: savedId })
|
|
173
174
|
: await inspect({ directory, output, source: input.flag('working-tree') ? { workingTree: true } : { revision },
|
|
174
175
|
lcov, exclude: [...config.exclude, ...input.many('exclude')], ignore: config.ignore,
|
|
175
|
-
findingInputs: findings, findingRoot: importRoot ? resolve(directory, importRoot) : undefined }, worker === undefined ? undefined : remoteExecutor(worker, workerToken()));
|
|
176
|
+
findingInputs: findings, findingRoot: importRoot ? resolve(directory, importRoot) : undefined }, worker === undefined ? undefined : remoteExecutor(worker, workerToken(), defaultLanguages.isSource));
|
|
176
177
|
if (github)
|
|
177
178
|
await writeGitHubResult(report);
|
|
178
179
|
const requested = input.many('report');
|
|
@@ -199,7 +200,7 @@ async function analyzeRange(input, range) {
|
|
|
199
200
|
if (!commits.length)
|
|
200
201
|
process.stderr.write(`No commits in ${range.base}..${range.head}.\n`);
|
|
201
202
|
const worker = input.text('worker');
|
|
202
|
-
const executor = worker === undefined ? undefined : remoteExecutor(worker, workerToken());
|
|
203
|
+
const executor = worker === undefined ? undefined : remoteExecutor(worker, workerToken(), defaultLanguages.isSource);
|
|
203
204
|
const exclude = [...config.exclude, ...input.many('exclude')];
|
|
204
205
|
const analyzed = [], partial = [], skipped = [];
|
|
205
206
|
const failed = [];
|
|
@@ -3,7 +3,7 @@ import type { Invocation } from './arguments.js';
|
|
|
3
3
|
import type { Store } from './store.js';
|
|
4
4
|
declare const reporters: {
|
|
5
5
|
readonly html: '.repometry/report/html';
|
|
6
|
-
readonly json: '.repometry/report/
|
|
6
|
+
readonly json: '.repometry/report/summary.json';
|
|
7
7
|
};
|
|
8
8
|
export declare const reporterIds: string[];
|
|
9
9
|
export declare function outputReports(root: string, store: Store, requested: readonly string[], input: Invocation, config: Awaited<ReturnType<typeof readConfig>>): Promise<{
|
|
@@ -12,7 +12,7 @@ import { readComponents } from '../report/json/store/components.js';
|
|
|
12
12
|
import { listPullReviews } from '../report/json/store/pull-review-store.js';
|
|
13
13
|
import { readConfig } from './config.js';
|
|
14
14
|
import { findRepository, invocationDirectory, isDirectory, selectStore } from './store.js';
|
|
15
|
-
const reporters = { html: '.repometry/report/html', json: '.repometry/report/
|
|
15
|
+
const reporters = { html: '.repometry/report/html', json: '.repometry/report/summary.json' };
|
|
16
16
|
export const reporterIds = Object.keys(reporters);
|
|
17
17
|
export async function outputReports(root, store, requested, input, config) {
|
|
18
18
|
const output = input.text('output');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OperationCacheOptions } from '../core/engine/operation-cache.js';
|
|
2
|
+
import type { PlannedOperation } from '../core/engine/plan.js';
|
|
3
|
+
import type { CloneSource } from '../core/model/clone-source.js';
|
|
4
|
+
import type { CodeStructure } from '../core/model/code-structure.js';
|
|
5
|
+
import type { SourceLineRange } from '../core/model/source.js';
|
|
6
|
+
import type { AnalysisResults } from './analysis-results.js';
|
|
7
|
+
import type { AnalysisSources } from './analysis-sources.js';
|
|
8
|
+
export declare const defaultFilePlan: readonly PlannedOperation[];
|
|
9
|
+
export interface FileAnalysis {
|
|
10
|
+
readonly cloneSources: readonly CloneSource[];
|
|
11
|
+
readonly functionBodies: ReadonlyMap<string, readonly SourceLineRange[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare function inspectFiles(sources: AnalysisSources, batchFacts: ReadonlyMap<string, CodeStructure>, results: AnalysisResults, withCoverage: boolean, cache?: OperationCacheOptions): Promise<FileAnalysis>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { execute } from '../core/engine/execute.js';
|
|
2
|
+
import { plan } from '../core/engine/plan.js';
|
|
3
|
+
import { codeStructure } from '../core/model/code-structure.js';
|
|
4
|
+
import { sourceFile } from '../core/model/snapshot.js';
|
|
5
|
+
import { isClaimedText, maxClaimedFileBytes } from '../core/model/source.js';
|
|
6
|
+
import { fileQuality } from '../plugins/maintainability/maintainability.js';
|
|
7
|
+
import { oversizedClaim } from './analysis-results.js';
|
|
8
|
+
import { defaultProvider, inspectionKeys, pluginForScope, structuralInspections } from './analysis-sources.js';
|
|
9
|
+
const standardInspections = ['structure/size', 'structure/complexity', 'maintainability/file'];
|
|
10
|
+
const fileInput = new Map([['file', sourceFile.id]]);
|
|
11
|
+
const batchFileInput = new Map([...fileInput, ['syntax', codeStructure.id]]);
|
|
12
|
+
export const defaultFilePlan = filePlan(defaultProvider, []);
|
|
13
|
+
export async function inspectFiles(sources, batchFacts, results, withCoverage, cache) {
|
|
14
|
+
const plans = new Map([[filePlanKey(defaultProvider, []), defaultFilePlan]]);
|
|
15
|
+
const cloneSources = [];
|
|
16
|
+
const functionBodies = new Map();
|
|
17
|
+
for (const source of sources.sources) {
|
|
18
|
+
const plugins = matchedInspections(source, sources, results);
|
|
19
|
+
const { file, provider } = source;
|
|
20
|
+
if (!provider && !plugins.length)
|
|
21
|
+
continue;
|
|
22
|
+
const tasks = findFilePlan(provider, plugins, plans, results);
|
|
23
|
+
const facts = batchFacts.get(file.path);
|
|
24
|
+
const products = new Map([['file', { contract: sourceFile.id, value: file }]]);
|
|
25
|
+
if (facts)
|
|
26
|
+
products.set('syntax', { contract: codeStructure.id, value: facts });
|
|
27
|
+
const outcomes = await execute(tasks, products, cache);
|
|
28
|
+
const syntax = provider && outcomes.get(provider.key);
|
|
29
|
+
const bodies = recordFileSyntax(source, syntax, facts, results, withCoverage);
|
|
30
|
+
if (bodies !== undefined)
|
|
31
|
+
functionBodies.set(file.path, bodies);
|
|
32
|
+
collectFileProducts(tasks, outcomes, source, cloneSources, results);
|
|
33
|
+
}
|
|
34
|
+
return { cloneSources, functionBodies };
|
|
35
|
+
}
|
|
36
|
+
function matchedInspections({ file }, sources, results) {
|
|
37
|
+
const claimed = sources.perFile.filter(({ matches }) => matches(file.path));
|
|
38
|
+
if (claimed.length && file.bytes.byteLength > maxClaimedFileBytes)
|
|
39
|
+
results.diagnostics.push(oversizedClaim(file.path));
|
|
40
|
+
return isClaimedText(file.bytes) ? claimed.map(({ plugin }) => plugin) : [];
|
|
41
|
+
}
|
|
42
|
+
function findFilePlan(provider, plugins, plans, results) {
|
|
43
|
+
const key = filePlanKey(provider, plugins);
|
|
44
|
+
const cached = plans.get(key);
|
|
45
|
+
if (cached)
|
|
46
|
+
return cached;
|
|
47
|
+
const tasks = filePlan(provider, plugins);
|
|
48
|
+
plans.set(key, tasks);
|
|
49
|
+
for (const task of tasks) {
|
|
50
|
+
const consumesBatch = provider?.batch && [...task.inputs.values()].some(input => 'external' in input && input.external === 'syntax');
|
|
51
|
+
results.remember(task, consumesBatch ? provider.key : undefined);
|
|
52
|
+
}
|
|
53
|
+
return tasks;
|
|
54
|
+
}
|
|
55
|
+
function filePlan(provider, plugins) {
|
|
56
|
+
const inspections = plugins.flatMap(inspectionKeys);
|
|
57
|
+
if (!provider)
|
|
58
|
+
return plan({ plugins, select: inspections, inputs: fileInput });
|
|
59
|
+
const needsProvider = !provider.batch && plugins.every(plugin => plugin.id !== provider.plugin.id);
|
|
60
|
+
const syntax = provider.batch ? { external: 'syntax' } : { operation: provider.key };
|
|
61
|
+
const providers = needsProvider ? [pluginForScope(provider.plugin, 'file')] : [];
|
|
62
|
+
return plan({
|
|
63
|
+
plugins: [...providers, ...structuralInspections, ...plugins],
|
|
64
|
+
select: [...standardInspections, ...inspections],
|
|
65
|
+
inputs: provider.batch ? batchFileInput : fileInput,
|
|
66
|
+
bindings: new Map(standardInspections.map(operation => [operation, { syntax }])),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function filePlanKey(provider, plugins) {
|
|
70
|
+
return JSON.stringify([provider?.key ?? null, ...plugins.map(plugin => plugin.id)]);
|
|
71
|
+
}
|
|
72
|
+
function recordFileSyntax({ file, provider }, outcome, batch, results, withCoverage) {
|
|
73
|
+
const value = outcome?.state === 'completed' ? outcome.product.value : undefined;
|
|
74
|
+
const builtinParsed = provider === defaultProvider && value !== undefined;
|
|
75
|
+
const facts = batch ?? ((!builtinParsed || withCoverage) && codeStructure.accepts(value) ? value : undefined);
|
|
76
|
+
if (facts || builtinParsed)
|
|
77
|
+
results.parsed.add(file.path);
|
|
78
|
+
return withCoverage ? facts?.functionBodies : undefined;
|
|
79
|
+
}
|
|
80
|
+
function collectFileProducts(tasks, outcomes, { file, provider }, clones, results) {
|
|
81
|
+
for (const task of tasks) {
|
|
82
|
+
const outcome = outcomes.get(task.key);
|
|
83
|
+
results.record(task, outcome, file.path);
|
|
84
|
+
const source = cloneSource(outcome, provider);
|
|
85
|
+
if (source)
|
|
86
|
+
clones.push(source);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function cloneSource(outcome, provider) {
|
|
90
|
+
if (outcome.state !== 'completed' || outcome.product.contract !== fileQuality.id || !fileQuality.accepts(outcome.product.value))
|
|
91
|
+
return;
|
|
92
|
+
const source = outcome.product.value.cloneSource;
|
|
93
|
+
return provider && provider !== defaultProvider && source.scheme === undefined ? { ...source, scheme: provider.plugin.id } : source;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=analysis-files.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OperationCacheOptions } from '../core/engine/operation-cache.js';
|
|
2
|
+
import type { AnalysisInput } from '../core/usecases/inspect.js';
|
|
3
|
+
import type { FileAnalysis } from './analysis-files.js';
|
|
4
|
+
import type { AnalysisResults } from './analysis-results.js';
|
|
5
|
+
import type { AnalysisSources } from './analysis-sources.js';
|
|
6
|
+
export declare function inspectDuplication(files: FileAnalysis, results: AnalysisResults, cache?: OperationCacheOptions): Promise<void>;
|
|
7
|
+
export declare function importAnalysisCoverage({ coverage: input, excludedPaths, snapshot }: AnalysisInput, sources: AnalysisSources, files: FileAnalysis, results: AnalysisResults, cache?: OperationCacheOptions): Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { execute } from '../core/engine/execute.js';
|
|
2
|
+
import { plan } from '../core/engine/plan.js';
|
|
3
|
+
import { sourceLineCounts } from '../core/model/snapshot.js';
|
|
4
|
+
import { sourceExclusionMatcher } from '../core/profile/exclusions.js';
|
|
5
|
+
import { coverage, coverageResult, lcovInput } from '../plugins/coverage/coverage.js';
|
|
6
|
+
import { duplication, duplicationInput } from '../plugins/duplication/duplication.js';
|
|
7
|
+
const duplicationPlan = plan({ plugins: [duplication], select: ['duplication/detect'], inputs: new Map([['sources', duplicationInput.id]]) });
|
|
8
|
+
const coveragePlan = plan({ plugins: [coverage], select: ['lcov/import', 'lcov/lines'], inputs: new Map([['lcov', lcovInput.id]]) });
|
|
9
|
+
export async function inspectDuplication(files, results, cache) {
|
|
10
|
+
const inputs = new Map([['sources', { contract: duplicationInput.id, value: files.cloneSources }]]);
|
|
11
|
+
const outcomes = await execute(duplicationPlan, inputs, cache);
|
|
12
|
+
const [task] = duplicationPlan;
|
|
13
|
+
results.remember(task);
|
|
14
|
+
results.record(task, outcomes.get(task.key));
|
|
15
|
+
}
|
|
16
|
+
export async function importAnalysisCoverage({ coverage: input, excludedPaths = [], snapshot }, sources, files, results, cache) {
|
|
17
|
+
if (input === undefined)
|
|
18
|
+
return;
|
|
19
|
+
const value = { text: input.text, root: input.sourceRoot, sourceLines: sourceLineCounts(sources.sourceFiles),
|
|
20
|
+
codeLines: new Map(files.cloneSources.map(({ path, codeLines }) => [path, new Set(codeLines)])), functionBodies: files.functionBodies,
|
|
21
|
+
excludes: sourceExclusionMatcher(excludedPaths, snapshot.generatedExcluded) };
|
|
22
|
+
const outcomes = await execute(coveragePlan, new Map([['lcov', { contract: lcovInput.id, value }]]), cache);
|
|
23
|
+
for (const task of coveragePlan) {
|
|
24
|
+
results.remember(task);
|
|
25
|
+
results.record(task, outcomes.get(task.key));
|
|
26
|
+
}
|
|
27
|
+
const outcome = outcomes.get('lcov/import');
|
|
28
|
+
if (outcome?.state !== 'completed' || !coverageResult.accepts(outcome.product.value))
|
|
29
|
+
return;
|
|
30
|
+
for (const { path, reason } of outcome.product.value.gaps) {
|
|
31
|
+
results.diagnostics.push({ operation: 'lcov/import', state: 'partial', path, message: reason });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=analysis-imports.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Report } from '../core/model/report.js';
|
|
2
|
+
import type { AnalysisInput } from '../core/usecases/inspect.js';
|
|
3
|
+
import type { AnalysisResults } from './analysis-results.js';
|
|
4
|
+
import type { AnalysisSources } from './analysis-sources.js';
|
|
5
|
+
export declare function assembleAnalysisReport(input: AnalysisInput, sources: AnalysisSources, results: AnalysisResults): Report;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { definitions } from '../core/model/measurement.js';
|
|
2
|
+
import { debtModel } from '../core/model/quality-summary.js';
|
|
3
|
+
import { reportSchema } from '../core/model/report.js';
|
|
4
|
+
import { comparePaths, digest, sourceDirectoriesExcluded, textLineCount } from '../core/model/snapshot.js';
|
|
5
|
+
import { defaultSourceExclusions, generatedSourcePolicy } from '../core/profile/exclusions.js';
|
|
6
|
+
import { duplicationSettings, structuralRules } from '../core/profile/maintainability.js';
|
|
7
|
+
import { parserDefaults } from '../plugins/language-js/babel-provider.js';
|
|
8
|
+
import { languageId } from './languages.js';
|
|
9
|
+
const measurementDefinitions = {
|
|
10
|
+
[definitions.lines]: 'Physical lines including blank lines and comments. A final line terminator does not add a line.',
|
|
11
|
+
[definitions.functions]: 'Babel function nodes with bodies, including nested functions and methods.',
|
|
12
|
+
[definitions.complexity]: 'One plus branches in the function body: if, ternary, loops, catch, non-default switch cases and logical operators. Nested functions are measured separately. Line and column are 1-based and columns count UTF-16 units.',
|
|
13
|
+
[definitions.coverage]: 'Distinct covered code lines divided by the distinct code lines listed in LCOV DA records. Hit counts are summed across records. A zero denominator has no ratio.',
|
|
14
|
+
[definitions.codeLines]: 'Nonblank physical lines after removing Babel comment spans and the interpreter directive. A line containing both code and a comment counts as code.',
|
|
15
|
+
[definitions.comments]: 'Physical lines containing only a Babel comment or interpreter directive.',
|
|
16
|
+
[definitions.classes]: 'Babel class declaration and expression nodes.',
|
|
17
|
+
[definitions.cognitiveComplexity]: 'Flow breaks plus nesting weight and logical operator sequences. Nested functions are measured separately. File complexity sums functions and module-level flow breaks.',
|
|
18
|
+
[definitions.duplicatedLines]: 'Distinct code lines inside repeated Babel syntax subtrees, including original and repeated occurrences. Identifier and literal spellings are ignored for similar-code matches.',
|
|
19
|
+
};
|
|
20
|
+
export function assembleAnalysisReport(input, sources, results) {
|
|
21
|
+
const pluginData = results.pluginData();
|
|
22
|
+
const { snapshot } = input;
|
|
23
|
+
const fileCount = sources.sourceFiles.length;
|
|
24
|
+
return {
|
|
25
|
+
schema: reportSchema,
|
|
26
|
+
subject: snapshot.subject,
|
|
27
|
+
generatedAt: new Date().toISOString(),
|
|
28
|
+
appliedConfig: appliedConfiguration(input, sources, results),
|
|
29
|
+
definitions: { ...Object.fromEntries((pluginData?.metrics ?? []).map(metric => [metric.id, metric.description ?? metric.label])),
|
|
30
|
+
...measurementDefinitions },
|
|
31
|
+
scope: { files: fileCount, parsed: results.parsed.size },
|
|
32
|
+
status: inspectionStatus(fileCount, results),
|
|
33
|
+
measurements: results.measurements,
|
|
34
|
+
diagnostics: results.diagnostics,
|
|
35
|
+
findings: results.findings,
|
|
36
|
+
...(pluginData === undefined ? {} : { pluginData: { ...pluginData, languages: sources.languages.catalog,
|
|
37
|
+
inventory: reportInventory(snapshot, sources, results) } }),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function appliedConfiguration({ snapshot, excludedOutput, excludedPaths = [], coverage }, { languages, claimedPlugins, plugins }, results) {
|
|
41
|
+
const securityScanners = results.securityScanners(claimedPlugins);
|
|
42
|
+
return {
|
|
43
|
+
profile: 'js-ts/v2', mode: snapshot.subject.kind,
|
|
44
|
+
source: { extensions: languages.extensions, ...(languages.globs.length ? { globs: languages.globs } : {}),
|
|
45
|
+
excludedDirectories: sourceDirectoriesExcluded, excludedOutput, excludedPaths,
|
|
46
|
+
defaultExclusions: defaultSourceExclusions, generatedSourcePolicy, generatedExcluded: snapshot.generatedExcluded ?? [] },
|
|
47
|
+
parser: parserDefaults,
|
|
48
|
+
maintainability: { structuralRules, duplication: duplicationSettings, debtModel, remediation: 'nonoverlapping-complexity/v1' },
|
|
49
|
+
coverage: coverage === undefined ? null : { inputDigest: digest(coverage.text), pathBase: coverage.sourceRoot,
|
|
50
|
+
merge: 'any-hit', hitCounts: 'sum', lines: 'code-only' },
|
|
51
|
+
...(securityScanners.length ? { securityScanners } : {}),
|
|
52
|
+
plugins: plugins.map(pluginProvenance),
|
|
53
|
+
operations: results.operationRecords(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function pluginProvenance({ id, version, api, tools, kinds, claims, settings, providesLanguages }) {
|
|
57
|
+
return { id, version, api, tools: tools ?? {}, kinds,
|
|
58
|
+
...(claims === undefined ? {} : { claims }), ...(settings === undefined ? {} : { settings }),
|
|
59
|
+
...(providesLanguages === undefined ? {} : { providesLanguages }) };
|
|
60
|
+
}
|
|
61
|
+
function inspectionStatus(fileCount, results) {
|
|
62
|
+
if (results.diagnostics.length > 0)
|
|
63
|
+
return 'partial';
|
|
64
|
+
return fileCount === 0 && !results.completedInspection ? 'not-applicable' : 'complete';
|
|
65
|
+
}
|
|
66
|
+
function reportInventory(snapshot, sources, results) {
|
|
67
|
+
const inventory = new Map((snapshot.inventory ?? []).map(({ path, lines, bytes }) => [path, { lines, bytes }]));
|
|
68
|
+
for (const { path, bytes } of snapshot.files) {
|
|
69
|
+
if (!inventory.has(path))
|
|
70
|
+
inventory.set(path, { lines: textLineCount(bytes), bytes: bytes.length });
|
|
71
|
+
}
|
|
72
|
+
return [...inventory].sort(([left], [right]) => comparePaths(left, right)).map(([path, { lines, bytes }]) => {
|
|
73
|
+
const provider = sources.providersByPath.get(path);
|
|
74
|
+
return { path, lines, ...(bytes === undefined ? {} : { bytes }), language: provider?.language(path) ?? languageId(path),
|
|
75
|
+
analysed: results.parsed.has(path) || results.inspected.has(path), ...(provider === undefined ? {} : { provider: provider.key }) };
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=analysis-report.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OperationCacheOptions } from '../core/engine/operation-cache.js';
|
|
2
|
+
import type { CodeStructure } from '../core/model/code-structure.js';
|
|
3
|
+
import type { AnalysisResults } from './analysis-results.js';
|
|
4
|
+
import type { AnalysisSources } from './analysis-sources.js';
|
|
5
|
+
export declare function collectRepositorySyntax(sources: AnalysisSources, results: AnalysisResults, cache?: OperationCacheOptions): Promise<Map<string, CodeStructure>>;
|
|
6
|
+
export declare function inspectRepositories(sources: AnalysisSources, results: AnalysisResults, cache?: OperationCacheOptions): Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { execute } from '../core/engine/execute.js';
|
|
2
|
+
import { plan } from '../core/engine/plan.js';
|
|
3
|
+
import { codeStructures } from '../core/model/code-structure.js';
|
|
4
|
+
import { sourceFiles } from '../core/model/snapshot.js';
|
|
5
|
+
import { isClaimedText } from '../core/model/source.js';
|
|
6
|
+
import { inspectionKeys } from './analysis-sources.js';
|
|
7
|
+
const repositoryInput = new Map([['files', sourceFiles.id]]);
|
|
8
|
+
export async function collectRepositorySyntax(sources, results, cache) {
|
|
9
|
+
const providers = new Map(sources.languages.providers.filter(provider => provider.batch).map(provider => [provider.plugin.id, provider]));
|
|
10
|
+
const facts = new Map();
|
|
11
|
+
for (const { plugin } of sources.repository) {
|
|
12
|
+
const provider = providers.get(plugin.id);
|
|
13
|
+
if (!provider)
|
|
14
|
+
continue;
|
|
15
|
+
const files = sources.sources.filter(source => source.provider === provider).map(({ file }) => file);
|
|
16
|
+
if (!files.length)
|
|
17
|
+
continue;
|
|
18
|
+
const outcomes = await runRepository(plugin, files, [provider.key, ...inspectionKeys(plugin)], results, cache);
|
|
19
|
+
const syntax = outcomes.get(provider.key);
|
|
20
|
+
if (syntax?.state === 'completed' && codeStructures.accepts(syntax.product.value)) {
|
|
21
|
+
collectFacts(facts, syntax.product.value, files, provider.key, results);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return facts;
|
|
25
|
+
}
|
|
26
|
+
export async function inspectRepositories(sources, results, cache) {
|
|
27
|
+
for (const { plugin, matches } of sources.repository) {
|
|
28
|
+
if (sources.languages.providers.some(provider => provider.batch && provider.plugin.id === plugin.id))
|
|
29
|
+
continue;
|
|
30
|
+
const select = inspectionKeys(plugin);
|
|
31
|
+
if (!select.length)
|
|
32
|
+
continue;
|
|
33
|
+
const files = sources.sources.map(({ file }) => file).filter(file => matches(file.path) && isClaimedText(file.bytes));
|
|
34
|
+
if (files.length)
|
|
35
|
+
await runRepository(plugin, files, select, results, cache);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function runRepository(plugin, files, select, results, cache) {
|
|
39
|
+
const tasks = plan({ plugins: [plugin], select, inputs: repositoryInput });
|
|
40
|
+
const outcomes = await execute(tasks, new Map([['files', { contract: sourceFiles.id, value: files }]]), cache);
|
|
41
|
+
const paths = files.map(({ path }) => path);
|
|
42
|
+
for (const task of tasks) {
|
|
43
|
+
results.remember(task);
|
|
44
|
+
results.record(task, outcomes.get(task.key), undefined, paths);
|
|
45
|
+
}
|
|
46
|
+
return outcomes;
|
|
47
|
+
}
|
|
48
|
+
function collectFacts(target, values, files, operation, results) {
|
|
49
|
+
const planned = new Set(files.map(({ path }) => path));
|
|
50
|
+
if (values.some(({ path }) => !planned.has(path))) {
|
|
51
|
+
results.diagnostics.push({ operation, state: 'failed', message: 'Language provider returned a path outside its inputs' });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
for (const facts of values)
|
|
55
|
+
target.set(facts.path, facts);
|
|
56
|
+
for (const path of planned) {
|
|
57
|
+
if (!target.has(path))
|
|
58
|
+
results.diagnostics.push({ operation, state: 'failed', path, message: 'Language provider returned no structure for this file' });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=analysis-repository.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Outcome } from '../core/engine/execute.js';
|
|
2
|
+
import type { PlannedOperation } from '../core/engine/plan.js';
|
|
3
|
+
import type { Plugin } from '../core/engine/plugin.js';
|
|
4
|
+
import type { Finding } from '../core/model/finding.js';
|
|
5
|
+
import type { Measurement } from '../core/model/measurement.js';
|
|
6
|
+
import type { Diagnostic } from '../core/model/report.js';
|
|
7
|
+
export declare class AnalysisResults {
|
|
8
|
+
readonly measurements: Measurement[];
|
|
9
|
+
readonly findings: Finding[];
|
|
10
|
+
readonly diagnostics: Diagnostic[];
|
|
11
|
+
readonly parsed: Set<string>;
|
|
12
|
+
readonly inspected: Set<string>;
|
|
13
|
+
completedInspection: boolean;
|
|
14
|
+
private readonly products;
|
|
15
|
+
private readonly scanned;
|
|
16
|
+
private readonly scanOnly;
|
|
17
|
+
private readonly securityOperations;
|
|
18
|
+
private readonly usedPlans;
|
|
19
|
+
constructor(plugins: readonly Plugin[], claimed: readonly Plugin[], oversized: readonly string[]);
|
|
20
|
+
remember(task: PlannedOperation, syntaxProvider?: string): void;
|
|
21
|
+
operationRecords(): readonly ReturnType<typeof operationProvenance>[];
|
|
22
|
+
pluginData(): import("../core/model/plugin-data.js").PluginData | undefined;
|
|
23
|
+
securityScanners(plugins: readonly Plugin[]): {
|
|
24
|
+
name: string;
|
|
25
|
+
version: string;
|
|
26
|
+
}[];
|
|
27
|
+
record(task: PlannedOperation, outcome: Outcome, path?: string, paths?: readonly string[]): void;
|
|
28
|
+
private recordInspection;
|
|
29
|
+
}
|
|
30
|
+
export declare function operationProvenance(task: PlannedOperation, syntaxProvider?: string): {
|
|
31
|
+
key: string;
|
|
32
|
+
inputs: {
|
|
33
|
+
[k: string]: import("../core/engine/plan.js").InputBinding;
|
|
34
|
+
};
|
|
35
|
+
scope?: "repository" | undefined;
|
|
36
|
+
syntaxProvider?: string | undefined;
|
|
37
|
+
};
|
|
38
|
+
export declare function oversizedClaim(path: string): Diagnostic;
|