@repometry/cli 0.2.0 → 0.4.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 +5 -2
- package/package.json +2 -2
- package/target/main/resources/language-catalog.json +54 -0
- package/target/main/resources/licenses/spdx.json +746 -0
- package/target/main/resources/report/json/config-v2.schema.json +2 -1
- package/target/main/resources/report/json/file-metrics-v1.schema.json +2 -0
- package/target/main/resources/report/json/report-v2.schema.json +6 -3
- package/target/main/resources/report/json/repository-summary-v1.schema.json +14 -0
- package/target/main/resources/viewer/index.html +4 -0
- package/target/main/resources/viewer/styles.css +7 -2
- package/target/main/ts/api/git/git.d.ts +2 -1
- package/target/main/ts/api/git/git.js +4 -4
- package/target/main/ts/api/git/inspection-source.js +2 -2
- package/target/main/ts/api/git/local.d.ts +1 -1
- package/target/main/ts/api/git/local.js +5 -4
- package/target/main/ts/api/import/finding-import.js +2 -9
- package/target/main/ts/api/import/license-import.d.ts +2 -0
- package/target/main/ts/api/import/license-import.js +36 -0
- package/target/main/ts/api/import/repository-path.d.ts +1 -0
- package/target/main/ts/api/import/repository-path.js +10 -0
- package/target/main/ts/cli/imports.d.ts +2 -0
- package/target/main/ts/cli/imports.js +6 -2
- package/target/main/ts/cli/run.js +10 -4
- package/target/main/ts/compose/analysis-report.js +5 -2
- package/target/main/ts/compose/analysis-results.d.ts +3 -2
- package/target/main/ts/compose/analysis-results.js +15 -6
- package/target/main/ts/compose/analysis-steps.js +3 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +1 -1
- package/target/main/ts/compose/analyze-snapshot.js +7 -4
- package/target/main/ts/compose/built-ins.d.ts +2 -2
- package/target/main/ts/compose/built-ins.js +2 -2
- package/target/main/ts/compose/inspect.d.ts +2 -0
- package/target/main/ts/compose/inspect.js +7 -4
- package/target/main/ts/compose/language-discovery.js +3 -1
- package/target/main/ts/compose/load-plugins.js +4 -2
- package/target/main/ts/compose/phases.d.ts +7 -3
- package/target/main/ts/compose/phases.js +26 -10
- package/target/main/ts/plugins/built-in.d.ts +2 -0
- package/target/main/ts/plugins/built-in.js +4 -1
- package/target/main/ts/plugins/duplication/duplication.d.ts +1 -2
- package/target/main/ts/plugins/duplication/duplication.js +18 -17
- package/target/main/ts/plugins/json-spans.d.ts +11 -0
- package/target/main/ts/plugins/json-spans.js +86 -0
- package/target/main/ts/plugins/language-js/babel-provider.d.ts +34 -2
- package/target/main/ts/plugins/language-js/babel-provider.js +39 -35
- package/target/main/ts/plugins/language-js/js-security.d.ts +17 -2
- package/target/main/ts/plugins/language-js/js-security.js +24 -23
- package/target/main/ts/plugins/language-js/structural-observations.d.ts +2 -1
- package/target/main/ts/plugins/language-js/structural-observations.js +2 -2
- package/target/main/ts/plugins/legal/composer-lock.d.ts +2 -0
- package/target/main/ts/plugins/legal/composer-lock.js +24 -0
- package/target/main/ts/plugins/legal/dependencies.d.ts +73 -0
- package/target/main/ts/plugins/legal/dependencies.js +27 -0
- package/target/main/ts/plugins/legal/licenses.d.ts +19 -0
- package/target/main/ts/plugins/legal/licenses.js +112 -0
- package/target/main/ts/plugins/legal/npm-lock.d.ts +3 -0
- package/target/main/ts/plugins/legal/npm-lock.js +30 -0
- package/target/main/ts/plugins/legal/policy.d.ts +72 -0
- package/target/main/ts/plugins/legal/policy.js +149 -0
- package/target/main/ts/plugins/legal/sbom.d.ts +3 -0
- package/target/main/ts/plugins/legal/sbom.js +131 -0
- package/target/main/ts/plugins/legal/unverified-lock.d.ts +1 -0
- package/target/main/ts/plugins/legal/unverified-lock.js +21 -0
- package/target/main/ts/plugins/maintainability/maintainability.d.ts +1 -2
- package/target/main/ts/plugins/maintainability/maintainability.js +34 -33
- package/target/main/ts/plugins/maintainability/structural-smells.d.ts +1 -2
- package/target/main/ts/plugins/maintainability/structural-smells.js +5 -5
- package/target/main/ts/plugins/security/actions-security.d.ts +17 -2
- package/target/main/ts/plugins/security/actions-security.js +21 -16
- package/target/main/ts/plugins/security/dockerfile.d.ts +17 -2
- package/target/main/ts/plugins/security/dockerfile.js +23 -18
- package/target/main/ts/plugins/security/npm-supply-chain.d.ts +17 -2
- package/target/main/ts/plugins/security/npm-supply-chain.js +32 -110
- package/target/main/ts/plugins/security/secrets.d.ts +18 -6
- package/target/main/ts/plugins/security/secrets.js +27 -23
- package/target/main/ts/plugins/source/forges.js +25 -32
- package/target/main/ts/report/html/app/viewer-issue-group.js +1 -1
- package/target/main/ts/report/html/app/viewer-metric-registry.js +1 -1
- package/target/main/ts/report/html/app/viewer-metrics.d.ts +2 -1
- package/target/main/ts/report/html/app/viewer-metrics.js +7 -2
- package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +1 -0
- package/target/main/ts/report/html/app/viewer-overview-cards.js +20 -1
- package/target/main/ts/report/html/app/viewer-overview-lead.js +4 -1
- package/target/main/ts/report/html/app/viewer-shell.js +3 -1
- package/target/main/ts/report/html/app/viewer-tokenizer.js +37 -9
- package/target/main/ts/report/html/app/viewer-trend-data.js +1 -0
- package/target/main/ts/report/html/app/viewer.js +5 -2
- package/target/main/ts/report/json/validation/report.js +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import { readLicenseImports } from '../api/import/license-import.js';
|
|
4
5
|
import { importFindings } from '../api/import/finding-import.js';
|
|
5
6
|
import { hasCoverageInputs } from '../api/import/lcov-files.js';
|
|
6
7
|
import { readInspectionCoverage } from './inspection-coverage.js';
|
|
@@ -8,19 +9,21 @@ import { reportSchema } from '@repometry/core/internal/model/report.js';
|
|
|
8
9
|
import { isExcludedDirectory } from '@repometry/core/internal/model/snapshot.js';
|
|
9
10
|
import { executeInspection } from '@repometry/core/internal/usecases/inspect.js';
|
|
10
11
|
import { LocalReportStore } from '../report/json/store/local-store.js';
|
|
11
|
-
import { analyzeSnapshot, inspectionFileMatcher } from './analyze-snapshot.js';
|
|
12
|
+
import { analyzeSnapshot, inspectionFileLimit, inspectionFileMatcher } from './analyze-snapshot.js';
|
|
12
13
|
import { attachChurn } from './attach-churn.js';
|
|
13
14
|
import { languageRegistry } from './languages.js';
|
|
14
15
|
export function inspect(request) {
|
|
15
16
|
return inspectWithOptions(request);
|
|
16
17
|
}
|
|
17
18
|
export async function inspectWithOptions(request, { history, deferSummary = false, recordChurn = true, inventory } = {}) {
|
|
18
|
-
const { findingInputs = [], plugins = [], operationCache } = request;
|
|
19
|
+
const { findingInputs = [], licenseInputs = [], plugins = [], operationCache } = request;
|
|
19
20
|
const languages = languageRegistry(plugins, request.parsers);
|
|
20
|
-
const
|
|
21
|
+
const fromLockfiles = licenseInputs.length === 0;
|
|
22
|
+
const claims = inspectionFileMatcher(languages, fromLockfiles);
|
|
21
23
|
const { isSource } = languages;
|
|
22
24
|
const ports = {
|
|
23
|
-
readSource: excludes => readSource(request, { excludes, isSource, claims, history: history?.blobs }, deferSummary, inventory),
|
|
25
|
+
readSource: excludes => readSource(request, { excludes, isSource, claims, claimLimit: inspectionFileLimit(languages, fromLockfiles), history: history?.blobs }, deferSummary, inventory),
|
|
26
|
+
...(!fromLockfiles ? { readLicenseImports: source => readLicenseImports(licenseInputs, source.root) } : {}),
|
|
24
27
|
analyze: input => analyzeSnapshot(input, languages, operationCache, history),
|
|
25
28
|
...(hasCoverageInputs(request) ? { readCoverage: source => readInspectionCoverage(request, source) } : {}),
|
|
26
29
|
...(findingInputs.length === 0 ? {} : { importFindings: (report, root, excludes) => attachFindings(report, findingInputs, root, request.findingRoot === undefined ? root : resolve(request.findingRoot), excludes) }),
|
|
@@ -13,7 +13,9 @@ for (const entry of catalog) {
|
|
|
13
13
|
packages.add(entry.package);
|
|
14
14
|
packagesByLanguage.set(entry.language, packages);
|
|
15
15
|
for (const extension of entry.extensions) {
|
|
16
|
-
|
|
16
|
+
// Uninspected shell files keep their report language ID.
|
|
17
|
+
const fileType = entry.language === 'bash' ? 'shell' : entry.language;
|
|
18
|
+
if (fileTypesByExtension.get(extension) === fileType)
|
|
17
19
|
officialByExtension.set(extension, entry.language);
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, resolve } from 'node:path';
|
|
2
|
-
import { builtInPlugins } from './built-ins.js';
|
|
2
|
+
import { builtInConfigurations, builtInPlugins } from './built-ins.js';
|
|
3
3
|
import { installedModule, javaScriptManifest, localModule } from './js-plugin.js';
|
|
4
4
|
import { validatePluginOptions } from './plugin-options.js';
|
|
5
5
|
import { dockerPluginFile, dockerPluginImage } from './process-plugins.js';
|
|
@@ -61,7 +61,9 @@ async function resolvePlugin(input, entry, folder, context, builtIns) {
|
|
|
61
61
|
const builtIn = builtIns.get(use) ?? alias;
|
|
62
62
|
if (builtIn !== undefined) {
|
|
63
63
|
validatePluginOptions(builtIn.config, entry.options, base);
|
|
64
|
-
|
|
64
|
+
const configure = builtInConfigurations.get(builtIn.id);
|
|
65
|
+
const plugin = configure && entry.options !== undefined ? configure(entry.options) : builtIn;
|
|
66
|
+
return { plugin, versionSource: 'built-in', builtIn: true, include: undefined, exclude: undefined, requires: undefined };
|
|
65
67
|
}
|
|
66
68
|
const installed = await installedModule(pkg, entry, context);
|
|
67
69
|
const plugin = pkg.startsWith('@repometry/language-') && pkg === '@repometry/' + installed.plugin.id
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DataContract, Operation, Plugin } from '@repometry/core/internal/engine/plugin.js';
|
|
2
|
+
import type { ImportedLicenseEvidence } from '@repometry/core/internal/model/license-evidence.js';
|
|
2
3
|
import type { SourceFile, SourceSnapshot } from '@repometry/core/internal/model/source.js';
|
|
3
4
|
import type { LanguageProvider, LanguageRegistry } from './languages.js';
|
|
4
5
|
/**
|
|
@@ -10,7 +11,7 @@ export type Phase = Readonly<{
|
|
|
10
11
|
task: 'file' | 'repository' | 'run';
|
|
11
12
|
}>;
|
|
12
13
|
/** The phases of an analysis in run order. The coverage input is offered only when coverage is given. */
|
|
13
|
-
export declare function analysisPhases(withCoverage: boolean): {
|
|
14
|
+
export declare function analysisPhases(withCoverage: boolean, withLicenseFiles?: boolean): {
|
|
14
15
|
readonly files: {
|
|
15
16
|
readonly task: 'file';
|
|
16
17
|
readonly offers: {
|
|
@@ -29,6 +30,7 @@ export declare function analysisPhases(withCoverage: boolean): {
|
|
|
29
30
|
readonly offers: {
|
|
30
31
|
readonly sources: DataContract<readonly import("@repometry/core/internal/model/clone-source.js").CloneSource[]>;
|
|
31
32
|
readonly lcov?: DataContract<import("@repometry/core/internal/model/coverage-input.js").CoverageInput> | undefined;
|
|
33
|
+
readonly licenseFiles?: DataContract<readonly import("@repometry/core/internal/model/license-evidence.js").LicenseEvidenceFile[]> | undefined;
|
|
32
34
|
};
|
|
33
35
|
};
|
|
34
36
|
};
|
|
@@ -78,9 +80,11 @@ export type SelectedSource = Readonly<{
|
|
|
78
80
|
provider: LanguageProvider | undefined;
|
|
79
81
|
}>;
|
|
80
82
|
/** Whether a file is claimed by an inspection that runs on claimed files rather than on every parsed one. */
|
|
81
|
-
export declare function inspectionFileMatcher(languages: LanguageRegistry): (path: string) => boolean;
|
|
83
|
+
export declare function inspectionFileMatcher(languages: LanguageRegistry, fromLockfiles?: boolean): (path: string) => boolean;
|
|
84
|
+
export declare function inspectionFileLimit(languages: LanguageRegistry, fromLockfiles?: boolean): (path: string) => number;
|
|
82
85
|
/** The files of a snapshot with their language providers, and the steps that analyse them. */
|
|
83
|
-
export declare function selectAnalysisSources(snapshot: SourceSnapshot, withCoverage: boolean, languages: LanguageRegistry): {
|
|
86
|
+
export declare function selectAnalysisSources(snapshot: SourceSnapshot, withCoverage: boolean, languages: LanguageRegistry, imported?: ImportedLicenseEvidence): {
|
|
87
|
+
licenseInputs: SourceFile[] | readonly import("@repometry/core/internal/model/license-evidence.js").LicenseImportFile[];
|
|
84
88
|
languages: {
|
|
85
89
|
select: (path: string) => LanguageProvider | undefined;
|
|
86
90
|
isSource: (path: string) => boolean;
|
|
@@ -2,23 +2,26 @@ import { changesInput } from '@repometry/core/internal/model/changes.js';
|
|
|
2
2
|
import { cloneSources } from '@repometry/core/internal/model/clone-source.js';
|
|
3
3
|
import { codeStructure, codeStructures } from '@repometry/core/internal/model/code-structure.js';
|
|
4
4
|
import { lcovInput } from '@repometry/core/internal/model/coverage-input.js';
|
|
5
|
+
import { isLicenseLockfile, licenseFiles, maxLicenseFileBytes } from '@repometry/core/internal/model/license-evidence.js';
|
|
6
|
+
import { isClaimedText, maxClaimedFileBytes } from '@repometry/core/internal/model/source.js';
|
|
5
7
|
import { sourceFile, sourceFiles } from '@repometry/core/internal/model/snapshot.js';
|
|
6
8
|
import { builtInPluginIds } from './built-ins.js';
|
|
7
9
|
import { claimMatcher } from './languages.js';
|
|
8
10
|
import { inspectionClaims } from './parser-order.js';
|
|
9
11
|
import { scopedMatcher, scopeOperation } from './plugin-scope.js';
|
|
10
12
|
/** The phases of an analysis in run order. The coverage input is offered only when coverage is given. */
|
|
11
|
-
export function analysisPhases(withCoverage) {
|
|
13
|
+
export function analysisPhases(withCoverage, withLicenseFiles = false) {
|
|
12
14
|
return {
|
|
13
15
|
files: { task: 'file', offers: { file: sourceFile, syntax: codeStructure } },
|
|
14
16
|
repository: { task: 'repository', offers: { files: sourceFiles } },
|
|
15
|
-
afterFiles: { task: 'run', offers: { sources: cloneSources, ...(withCoverage ? { lcov: lcovInput } : {})
|
|
17
|
+
afterFiles: { task: 'run', offers: { sources: cloneSources, ...(withCoverage ? { lcov: lcovInput } : {}),
|
|
18
|
+
...(withLicenseFiles ? { licenseFiles } : {}) } },
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
/** The one phase of a diff coverage run. */
|
|
19
22
|
export const diffCoveragePhases = { changedLines: { task: 'run', offers: { changes: changesInput, lcov: lcovInput } } };
|
|
20
23
|
/** The phases of each kind of run, with all their optional host inputs. Every plugin takes part in an analysis; only built-ins in diff coverage. */
|
|
21
|
-
const analysisRun = Object.values(analysisPhases(true));
|
|
24
|
+
const analysisRun = Object.values(analysisPhases(true, true));
|
|
22
25
|
const diffCoverageRun = Object.values(diffCoveragePhases);
|
|
23
26
|
/** The closed list of host contracts: every contract some host run offers. */
|
|
24
27
|
const hostContracts = new Set([...analysisRun, ...diffCoverageRun].flatMap(({ offers }) => Object.values(offers).map(({ id }) => id)));
|
|
@@ -82,8 +85,8 @@ function rejectUnsatisfiable(all) {
|
|
|
82
85
|
throw new Error(`${dependent.key} reads ${unread(dependent, reachable).join(', ')}, which only operations that never run output`);
|
|
83
86
|
}
|
|
84
87
|
/** What runs where in an analysis: the active plugins and the four steps. */
|
|
85
|
-
function analysisSteps(plugins, languages, withCoverage) {
|
|
86
|
-
const { files, repository, afterFiles } = selectOperations(plugins, analysisPhases(withCoverage), new Set(languages.providers.map(({ key }) => key)));
|
|
88
|
+
function analysisSteps(plugins, languages, withCoverage, withLicenseFiles = false) {
|
|
89
|
+
const { files, repository, afterFiles } = selectOperations(plugins, analysisPhases(withCoverage, withLicenseFiles), new Set(languages.providers.map(({ key }) => key)));
|
|
87
90
|
// Those that read the code structure, directly or through the products of others, run on the parsed files their plugin claims.
|
|
88
91
|
const readers = new Set(reached(files, [codeStructure.id], 'some'));
|
|
89
92
|
const claims = new Map(plugins.map(plugin => [plugin.id, claimsOf(plugin, languages)]));
|
|
@@ -129,19 +132,32 @@ export function phaseInputs({ offers }, omit) {
|
|
|
129
132
|
return new Map(Object.entries(offers).filter(([, contract]) => contract !== omit).map(([port, { id }]) => [port, id]));
|
|
130
133
|
}
|
|
131
134
|
/** Whether a file is claimed by an inspection that runs on claimed files rather than on every parsed one. */
|
|
132
|
-
export function inspectionFileMatcher(languages) {
|
|
135
|
+
export function inspectionFileMatcher(languages, fromLockfiles = true) {
|
|
133
136
|
const { files, repository } = analysisSteps(languages.plugins, languages, false);
|
|
134
137
|
const claimed = [...files.inspections, ...repository.inspections].filter(({ parsed }) => !parsed);
|
|
135
|
-
|
|
138
|
+
const lockfile = licenseFileMatcher(languages);
|
|
139
|
+
return path => (fromLockfiles && lockfile(path)) || claimed.some(({ matches }) => matches(path, false));
|
|
140
|
+
}
|
|
141
|
+
function licenseFileMatcher(languages) {
|
|
142
|
+
const checks = languages.plugins.filter(plugin => plugin.kinds.includes('legal')
|
|
143
|
+
&& plugin.operations.some(operation => Object.values(operation.inputs).some(contract => contract.id === licenseFiles.id)))
|
|
144
|
+
.map(plugin => claimsOf(plugin, languages));
|
|
145
|
+
return path => isLicenseLockfile(path) && checks.some(matches => matches(path));
|
|
146
|
+
}
|
|
147
|
+
export function inspectionFileLimit(languages, fromLockfiles = true) {
|
|
148
|
+
const license = licenseFileMatcher(languages);
|
|
149
|
+
return path => fromLockfiles && license(path) ? maxLicenseFileBytes : maxClaimedFileBytes;
|
|
136
150
|
}
|
|
137
151
|
/** The files of a snapshot with their language providers, and the steps that analyse them. */
|
|
138
|
-
export function selectAnalysisSources(snapshot, withCoverage, languages) {
|
|
152
|
+
export function selectAnalysisSources(snapshot, withCoverage, languages, imported) {
|
|
139
153
|
const sources = snapshot.files.map(file => ({ file, provider: languages.select(file.path) }));
|
|
140
154
|
const providersByPath = new Map(sources.flatMap(({ file, provider }) => provider ? [[file.path, provider]] : []));
|
|
141
155
|
const unavailableFiles = new Set(sources.filter(({ file, provider }) => !provider && languages.skipped(file.path))
|
|
142
156
|
.map(({ file }) => file.path));
|
|
143
157
|
const sourceFiles = sources.flatMap(({ file, provider }) => provider ? [file] : []);
|
|
144
|
-
const
|
|
145
|
-
|
|
158
|
+
const matchesLicense = licenseFileMatcher(languages);
|
|
159
|
+
const licenseInputs = imported?.files ?? snapshot.files.filter(file => matchesLicense(file.path) && isClaimedText(file.bytes, maxLicenseFileBytes));
|
|
160
|
+
const steps = analysisSteps(languages.plugins, languages, withCoverage, licenseInputs.length > 0);
|
|
161
|
+
return { licenseInputs, languages, sources, sourceFiles, unavailableFiles, providersByPath, steps, plugins: steps.plugins };
|
|
146
162
|
}
|
|
147
163
|
//# sourceMappingURL=phases.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { JsonValue } from '@repometry/core/internal/model/plugin-data.js';
|
|
1
2
|
import type { Plugin } from '@repometry/core/internal/engine/plugin.js';
|
|
3
|
+
export declare const builtInConfigurations: Map<string, (options: JsonValue) => Plugin>;
|
|
2
4
|
/** The built-in plugins in run order. The first language plugin is the default provider. */
|
|
3
5
|
export declare const builtInPlugins: readonly Plugin[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { licenses } from './legal/licenses.js';
|
|
1
2
|
import { bundledPlugin } from '@repometry/core/internal/engine/plugin-manifest.js';
|
|
2
3
|
import { coverage } from './coverage/coverage.js';
|
|
3
4
|
import { diffCoverage } from './coverage/diff-coverage.js';
|
|
@@ -12,8 +13,10 @@ import { secrets } from './security/secrets.js';
|
|
|
12
13
|
import { githubSource, gitlabSource, localSource } from './source/forges.js';
|
|
13
14
|
import { structure } from './structure/structure.js';
|
|
14
15
|
// The review path uses the importer kind, which is also part of existing inspection profiles.
|
|
16
|
+
const licensePlugin = licenses();
|
|
17
|
+
export const builtInConfigurations = new Map([[licensePlugin.id, licenses]]);
|
|
15
18
|
const lcov = { ...bundledPlugin(coverage), kinds: ['coverage', 'import'] };
|
|
16
19
|
/** The built-in plugins in run order. The first language plugin is the default provider. */
|
|
17
20
|
export const builtInPlugins = [babelProvider, bundledPlugin(structure), maintainability, duplication, lcov, bundledPlugin(diffCoverage),
|
|
18
|
-
secrets, jsSecurity, actionsSecurity, npmSupplyChain, dockerfile, githubSource, gitlabSource, localSource];
|
|
21
|
+
secrets, jsSecurity, actionsSecurity, npmSupplyChain, dockerfile, licensePlugin, githubSource, gitlabSource, localSource];
|
|
19
22
|
//# sourceMappingURL=built-in.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const duplication: Plugin;
|
|
1
|
+
export declare const duplication: import("@repometry/core/internal/engine/plugin.js").Plugin;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findingResult } from '@repometry/core/internal/engine/author-contracts.js';
|
|
2
|
+
import { bundledPlugin, pluginManifestSchema } from '@repometry/core/internal/engine/plugin-manifest.js';
|
|
2
3
|
import { comparePaths } from '@repometry/core/internal/model/snapshot.js';
|
|
3
|
-
import { findingResult } from '@repometry/core/internal/model/finding.js';
|
|
4
4
|
import { definitions } from '@repometry/core/internal/model/measurement.js';
|
|
5
5
|
import { cloneSources } from '@repometry/core/internal/model/clone-source.js';
|
|
6
6
|
import { duplicationSettings } from '@repometry/core/internal/profile/maintainability.js';
|
|
7
|
-
export const duplication = {
|
|
8
|
-
id: 'duplication', version: '1.0.0',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
7
|
+
export const duplication = bundledPlugin({
|
|
8
|
+
schema: pluginManifestSchema, id: 'duplication', version: '1.0.0', category: 'maintainability',
|
|
9
|
+
checks: [{ id: 'identical-code' }, { id: 'similar-code' }],
|
|
10
|
+
create: () => ({
|
|
11
|
+
produces: [{ contract: findingResult.id, persistence: 'report', metrics: [
|
|
12
|
+
{ id: definitions.duplicatedLines, label: 'Duplicated lines', unit: 'count', scope: 'file', aggregate: 'sum', better: 'lower',
|
|
13
|
+
group: 'Maintainability' },
|
|
14
|
+
] }],
|
|
15
|
+
operations: [{
|
|
16
|
+
id: 'detect', role: 'inspection', inputs: { sources: cloneSources }, output: findingResult,
|
|
17
|
+
execute(inputs) { return detectClones(inputs.read('sources', cloneSources)); },
|
|
18
|
+
}],
|
|
19
|
+
}),
|
|
20
|
+
}, { tool: 'repometry', category: 'duplication' });
|
|
20
21
|
function detectClones(sources) {
|
|
21
22
|
const schemes = new Map();
|
|
22
23
|
for (const { path, candidates, scheme } of sources) {
|
|
@@ -53,9 +54,9 @@ function detectClones(sources) {
|
|
|
53
54
|
const selected = matched.get(occurrence.path);
|
|
54
55
|
selected.splice(insertionIndex(selected, occurrence.start), 0, occurrence);
|
|
55
56
|
}
|
|
56
|
-
const
|
|
57
|
+
const check = identical ? 'identical-code' : 'similar-code';
|
|
57
58
|
const effortMinutes = fresh.slice(1).reduce((total, occurrence) => total + occurrence.codeLines, 0) * duplicationSettings.minutesPerRepeatedLine;
|
|
58
|
-
findings.push({
|
|
59
|
+
findings.push({ check, level: 'medium',
|
|
59
60
|
message: `${identical ? 'Identical' : 'Similar'} code in ${fresh.length} locations`, ...location(first),
|
|
60
61
|
related: fresh.slice(1).map(location), effortMinutes, value: fresh.length, anchor: first.similar });
|
|
61
62
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function pointer(path: readonly (string | number)[]): string;
|
|
2
|
+
interface Span {
|
|
3
|
+
readonly line: number;
|
|
4
|
+
readonly endLine: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Find the lines of the wanted values in JSON text that JSON.parse has already accepted. A member starts on the line
|
|
8
|
+
* of its key and ends on the line where its value ends. Only paths up to `depth` keys deep are tracked.
|
|
9
|
+
*/
|
|
10
|
+
export declare function locateJsonSpans(text: string, wanted: ReadonlySet<string>, depth: number): ReadonlyMap<string, Span>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export function pointer(path) {
|
|
2
|
+
return path.map(segment => typeof segment === 'number' ? '#' + segment : JSON.stringify(segment)).join('');
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Find the lines of the wanted values in JSON text that JSON.parse has already accepted. A member starts on the line
|
|
6
|
+
* of its key and ends on the line where its value ends. Only paths up to `depth` keys deep are tracked.
|
|
7
|
+
*/
|
|
8
|
+
export function locateJsonSpans(text, wanted, depth) {
|
|
9
|
+
const spans = new Map();
|
|
10
|
+
const stack = [];
|
|
11
|
+
let line = 1;
|
|
12
|
+
const child = () => {
|
|
13
|
+
const parent = stack.at(-1);
|
|
14
|
+
if (!parent)
|
|
15
|
+
return { path: '', line };
|
|
16
|
+
const path = parent.path === undefined || stack.length > depth ? undefined
|
|
17
|
+
: parent.path + (parent.array ? `#${parent.index}` : JSON.stringify(parent.key));
|
|
18
|
+
return { path, line: parent.array ? line : parent.keyLine };
|
|
19
|
+
};
|
|
20
|
+
const scalar = () => {
|
|
21
|
+
const { path, line: start } = child();
|
|
22
|
+
if (path !== undefined && wanted.has(path))
|
|
23
|
+
spans.set(path, { line: start, endLine: line });
|
|
24
|
+
};
|
|
25
|
+
for (let index = 0; index < text.length;) {
|
|
26
|
+
const char = text[index];
|
|
27
|
+
if (char === '\n')
|
|
28
|
+
line++;
|
|
29
|
+
if (char === '\n' || char === ' ' || char === '\t' || char === '\r' || char === ':') {
|
|
30
|
+
index++;
|
|
31
|
+
}
|
|
32
|
+
else if (char === ',') {
|
|
33
|
+
const parent = stack.at(-1);
|
|
34
|
+
if (parent?.array)
|
|
35
|
+
parent.index++;
|
|
36
|
+
else if (parent)
|
|
37
|
+
parent.expectKey = true;
|
|
38
|
+
index++;
|
|
39
|
+
}
|
|
40
|
+
else if (char === '"') {
|
|
41
|
+
const end = stringEnd(text, index);
|
|
42
|
+
const parent = stack.at(-1);
|
|
43
|
+
if (parent && !parent.array && parent.expectKey) {
|
|
44
|
+
const raw = text.slice(index + 1, end);
|
|
45
|
+
parent.key = raw.includes('\\') ? JSON.parse(text.slice(index, end + 1)) : raw;
|
|
46
|
+
parent.keyLine = line;
|
|
47
|
+
parent.expectKey = false;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
scalar();
|
|
51
|
+
}
|
|
52
|
+
index = end + 1;
|
|
53
|
+
}
|
|
54
|
+
else if (char === '{' || char === '[') {
|
|
55
|
+
const { path, line: start } = child();
|
|
56
|
+
stack.push({ path, line: start, array: char === '[', index: 0, key: '', keyLine: line, expectKey: char === '{' });
|
|
57
|
+
index++;
|
|
58
|
+
}
|
|
59
|
+
else if (char === '}' || char === ']') {
|
|
60
|
+
const frame = stack.pop();
|
|
61
|
+
if (frame?.path !== undefined && wanted.has(frame.path))
|
|
62
|
+
spans.set(frame.path, { line: frame.line, endLine: line });
|
|
63
|
+
index++;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
scalar();
|
|
67
|
+
while (index < text.length && !/[\s,\]}]/.test(text[index]))
|
|
68
|
+
index++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return spans;
|
|
72
|
+
}
|
|
73
|
+
function stringEnd(text, start) {
|
|
74
|
+
for (let from = start + 1;;) {
|
|
75
|
+
const quote = text.indexOf('"', from);
|
|
76
|
+
if (quote < 0)
|
|
77
|
+
return text.length;
|
|
78
|
+
let slashes = 0;
|
|
79
|
+
while (text[quote - 1 - slashes] === '\\')
|
|
80
|
+
slashes++;
|
|
81
|
+
if (slashes % 2 === 0)
|
|
82
|
+
return quote;
|
|
83
|
+
from = quote + 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=json-spans.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Plugin } from '@repometry/core/internal/engine/plugin.js';
|
|
2
1
|
export declare const parserDefaults: {
|
|
3
2
|
readonly sourceType: 'unambiguous';
|
|
4
3
|
readonly errorRecovery: false;
|
|
@@ -7,4 +6,37 @@ export declare const parserDefaults: {
|
|
|
7
6
|
export declare const babelTypes: {
|
|
8
7
|
'@babel/types': string;
|
|
9
8
|
};
|
|
10
|
-
export declare const babelProvider:
|
|
9
|
+
export declare const babelProvider: {
|
|
10
|
+
id: string;
|
|
11
|
+
version: string;
|
|
12
|
+
api: string;
|
|
13
|
+
tools?: Readonly<Record<string, string>>;
|
|
14
|
+
operations: readonly import("@repometry/core").Operation[];
|
|
15
|
+
rules?: readonly import("@repometry/core/internal/engine/plugin.js").RuleDescriptor[];
|
|
16
|
+
config?: import("@repometry/core/internal/engine/plugin.js").PluginConfigSchema;
|
|
17
|
+
kinds: readonly import("@repometry/core/internal/engine/plugin.js").PluginKind[];
|
|
18
|
+
languageProvenanceRequiresSource?: true;
|
|
19
|
+
produces: readonly import("@repometry/core/internal/engine/plugin.js").ProductDeclaration[];
|
|
20
|
+
claims: {
|
|
21
|
+
extensions: readonly [".js", ".mjs", ".cjs", ".jsx", ".ts", ".mts", ".cts", ".tsx"];
|
|
22
|
+
languages: ("javascript" | "typescript")[];
|
|
23
|
+
};
|
|
24
|
+
providesLanguages: ({
|
|
25
|
+
id: 'javascript';
|
|
26
|
+
label: 'JavaScript';
|
|
27
|
+
color: '#f1e05a';
|
|
28
|
+
extensions: readonly ['.js', '.mjs', '.cjs', '.jsx'];
|
|
29
|
+
syntax: import("@repometry/core").LanguageSyntax;
|
|
30
|
+
} | {
|
|
31
|
+
id: 'typescript';
|
|
32
|
+
label: 'TypeScript';
|
|
33
|
+
color: '#3178c6';
|
|
34
|
+
extensions: readonly ['.ts', '.mts', '.cts', '.tsx'];
|
|
35
|
+
syntax: import("@repometry/core").LanguageSyntax;
|
|
36
|
+
})[];
|
|
37
|
+
settings: {
|
|
38
|
+
readonly sourceType: 'unambiguous';
|
|
39
|
+
readonly errorRecovery: false;
|
|
40
|
+
readonly attachComment: false;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { extname } from 'node:path';
|
|
3
3
|
import { parse } from '@babel/parser';
|
|
4
|
-
import {
|
|
4
|
+
import { codeStructure } from '@repometry/core/internal/engine/author-contracts.js';
|
|
5
|
+
import { bundledPlugin, pluginManifestSchema } from '@repometry/core/internal/engine/plugin-manifest.js';
|
|
5
6
|
import { javascriptType, typescriptType } from '@repometry/core/internal/model/file-types.js';
|
|
6
|
-
import { codeStructure } from '@repometry/core/internal/model/code-structure.js';
|
|
7
7
|
import { physicalLines, sourceFile, utf8 } from '@repometry/core/internal/model/snapshot.js';
|
|
8
8
|
import { cloneCandidates } from './clone-candidates.js';
|
|
9
9
|
import { classifyLines } from './code-lines.js';
|
|
@@ -15,40 +15,44 @@ import { jsSyntax } from './syntax.js';
|
|
|
15
15
|
const require = createRequire(import.meta.url);
|
|
16
16
|
export const parserDefaults = { sourceType: 'unambiguous', errorRecovery: false, attachComment: false };
|
|
17
17
|
export const babelTypes = { '@babel/types': require('@babel/types/package.json').version };
|
|
18
|
+
const languages = [{ ...javascriptType, syntax: jsSyntax }, { ...typescriptType, syntax: jsSyntax }];
|
|
18
19
|
export const babelProvider = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
...bundledPlugin({
|
|
21
|
+
schema: pluginManifestSchema, id: 'babel-syntax', version: '1.1.0', category: 'language',
|
|
22
|
+
languages: languages.map(({ extensions, ...language }) => ({ ...language, include: extensions.map(extension => '**/*' + extension) })),
|
|
23
|
+
tools: { '@babel/parser': require('@babel/parser/package.json').version, ...babelTypes },
|
|
24
|
+
create: () => ({
|
|
25
|
+
produces: [{ contract: codeStructure.id, persistence: 'transient' }],
|
|
26
|
+
operations: [{
|
|
27
|
+
id: 'parse',
|
|
28
|
+
role: 'provider',
|
|
29
|
+
inputs: { source: sourceFile },
|
|
30
|
+
output: codeStructure,
|
|
31
|
+
execute(inputs) {
|
|
32
|
+
const file = inputs.read('source', sourceFile);
|
|
33
|
+
const source = utf8(file.bytes);
|
|
34
|
+
const ext = extname(file.path);
|
|
35
|
+
const plugins = [];
|
|
36
|
+
if (typescriptType.extensions.includes(ext)) {
|
|
37
|
+
plugins.push(['typescript', { dts: /\.d\.[cm]?ts$/.test(file.path), disallowAmbiguousJSXLike: ext === '.mts' || ext === '.cts' }]);
|
|
38
|
+
}
|
|
39
|
+
if (ext === '.jsx' || ext === '.tsx')
|
|
40
|
+
plugins.push('jsx');
|
|
41
|
+
const sourceType = ext === '.mjs' || ext === '.mts' ? 'module'
|
|
42
|
+
: ext === '.cjs' || ext === '.cts' ? 'commonjs' : parserDefaults.sourceType;
|
|
43
|
+
const ast = parse(source, { ...parserDefaults, sourceType, plugins });
|
|
44
|
+
const lines = physicalLines(source);
|
|
45
|
+
const { code, comments } = classifyLines(source, ast, lines);
|
|
46
|
+
const names = qualifiedNames(ast);
|
|
47
|
+
return { path: file.path, lines, commentLines: comments, ...functionFacts(ast, names),
|
|
48
|
+
...structuralObservations(ast, names), clones: cloneCandidates(file.path, ast, code) };
|
|
49
|
+
},
|
|
50
|
+
}],
|
|
51
|
+
}),
|
|
52
|
+
}),
|
|
53
|
+
claims: { extensions: jsTsExtensions, languages: languages.map(({ id }) => id) },
|
|
54
|
+
// Existing reports record suffix selectors and the effective Babel settings.
|
|
55
|
+
providesLanguages: languages,
|
|
25
56
|
settings: parserDefaults,
|
|
26
|
-
produces: [{ contract: codeStructure.id, persistence: 'transient' }],
|
|
27
|
-
tools: { '@babel/parser': require('@babel/parser/package.json').version, ...babelTypes },
|
|
28
|
-
operations: [{
|
|
29
|
-
id: 'parse',
|
|
30
|
-
role: 'provider',
|
|
31
|
-
inputs: { source: sourceFile },
|
|
32
|
-
output: codeStructure,
|
|
33
|
-
execute(inputs) {
|
|
34
|
-
const file = inputs.read('source', sourceFile);
|
|
35
|
-
const source = utf8(file.bytes);
|
|
36
|
-
const ext = extname(file.path);
|
|
37
|
-
const plugins = [];
|
|
38
|
-
if (typescriptType.extensions.includes(ext)) {
|
|
39
|
-
plugins.push(['typescript', { dts: /\.d\.[cm]?ts$/.test(file.path), disallowAmbiguousJSXLike: ext === '.mts' || ext === '.cts' }]);
|
|
40
|
-
}
|
|
41
|
-
if (ext === '.jsx' || ext === '.tsx')
|
|
42
|
-
plugins.push('jsx');
|
|
43
|
-
const sourceType = ext === '.mjs' || ext === '.mts' ? 'module'
|
|
44
|
-
: ext === '.cjs' || ext === '.cts' ? 'commonjs' : parserDefaults.sourceType;
|
|
45
|
-
const ast = parse(source, { ...parserDefaults, sourceType, plugins });
|
|
46
|
-
const lines = physicalLines(source);
|
|
47
|
-
const { code, comments } = classifyLines(source, ast, lines);
|
|
48
|
-
const names = qualifiedNames(ast);
|
|
49
|
-
return { path: file.path, lines, commentLines: comments, ...functionFacts(ast, names),
|
|
50
|
-
...structuralObservations(ast, names), clones: cloneCandidates(file.path, ast, code) };
|
|
51
|
-
},
|
|
52
|
-
}],
|
|
53
57
|
};
|
|
54
58
|
//# sourceMappingURL=babel-provider.js.map
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const jsSecurity: {
|
|
2
|
+
id: string;
|
|
3
|
+
version: string;
|
|
4
|
+
api: string;
|
|
5
|
+
tools?: Readonly<Record<string, string>>;
|
|
6
|
+
operations: readonly import("@repometry/core").Operation[];
|
|
7
|
+
rules?: readonly import("@repometry/core/internal/engine/plugin.js").RuleDescriptor[];
|
|
8
|
+
config?: import("@repometry/core/internal/engine/plugin.js").PluginConfigSchema;
|
|
9
|
+
settings?: import("@repometry/core/internal/model/plugin-data.js").JsonValue;
|
|
10
|
+
kinds: readonly import("@repometry/core/internal/engine/plugin.js").PluginKind[];
|
|
11
|
+
providesLanguages?: readonly import("@repometry/core/internal/model/language.js").ProvidedLanguage[];
|
|
12
|
+
languageProvenanceRequiresSource?: true;
|
|
13
|
+
produces: readonly import("@repometry/core/internal/engine/plugin.js").ProductDeclaration[];
|
|
14
|
+
claims: {
|
|
15
|
+
extensions: readonly [".js", ".mjs", ".cjs", ".jsx", ".ts", ".mts", ".cts", ".tsx"];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
3
18
|
/** Splits camelCase, PascalCase and snake_case names into words and looks for secret-bearing ones. */
|
|
4
19
|
export declare function isSecretName(name: string): boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { extname } from 'node:path';
|
|
3
3
|
import { parse } from '@babel/parser';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { findingResult } from '@repometry/core/internal/engine/author-contracts.js';
|
|
5
|
+
import { bundledPlugin, pluginManifestSchema } from '@repometry/core/internal/engine/plugin-manifest.js';
|
|
6
6
|
import { sourceFile, utf8 } from '@repometry/core/internal/model/snapshot.js';
|
|
7
7
|
import { jsTsExtensions } from './extensions.js';
|
|
8
8
|
import { babelTypes, parserDefaults } from './babel-provider.js';
|
|
@@ -36,28 +36,29 @@ const wrappers = new Set(['TSAsExpression', 'TSSatisfiesExpression', 'TSNonNullE
|
|
|
36
36
|
'ParenthesizedExpression', 'TypeCastExpression']);
|
|
37
37
|
const functionTypes = new Set(['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression', 'ObjectMethod',
|
|
38
38
|
'ClassMethod', 'ClassPrivateMethod']);
|
|
39
|
-
const jsSecurityRules = Object.entries(catalog)
|
|
40
|
-
.map(([id, { description }]) => ({ id, category: 'security', description }));
|
|
39
|
+
const jsSecurityRules = Object.entries(catalog).map(([id, { description }]) => ({ id, description }));
|
|
41
40
|
export const jsSecurity = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
...bundledPlugin({
|
|
42
|
+
schema: pluginManifestSchema, id: 'js-security', version: '1.0.0', category: 'security',
|
|
43
|
+
include: jsTsExtensions.map(extension => '**/*' + extension),
|
|
44
|
+
tools: { '@babel/parser': require('@babel/parser/package.json').version, ...babelTypes },
|
|
45
|
+
checks: jsSecurityRules,
|
|
46
|
+
create: () => ({
|
|
47
|
+
produces: [{ contract: findingResult.id, persistence: 'report' }],
|
|
48
|
+
operations: [{
|
|
49
|
+
id: 'scan',
|
|
50
|
+
role: 'inspection',
|
|
51
|
+
inputs: { source: sourceFile },
|
|
52
|
+
output: findingResult,
|
|
53
|
+
execute(inputs) {
|
|
54
|
+
const file = inputs.read('source', sourceFile);
|
|
55
|
+
const ast = parseSource(file.path, file.bytes);
|
|
56
|
+
return { measurements: [], findings: ast === undefined ? [] : scan(file.path, ast) };
|
|
57
|
+
},
|
|
58
|
+
}],
|
|
59
|
+
}),
|
|
60
|
+
}, { tool: 'js-security', category: 'security' }),
|
|
46
61
|
claims: { extensions: jsTsExtensions },
|
|
47
|
-
produces: [{ contract: findingResult.id, persistence: 'report' }],
|
|
48
|
-
tools: { '@babel/parser': require('@babel/parser/package.json').version, ...babelTypes },
|
|
49
|
-
rules: jsSecurityRules,
|
|
50
|
-
operations: [{
|
|
51
|
-
id: 'scan',
|
|
52
|
-
role: 'inspection',
|
|
53
|
-
inputs: { source: sourceFile },
|
|
54
|
-
output: findingResult,
|
|
55
|
-
execute(inputs) {
|
|
56
|
-
const file = inputs.read('source', sourceFile);
|
|
57
|
-
const ast = parseSource(file.path, file.bytes);
|
|
58
|
-
return { measurements: [], findings: ast === undefined ? [] : scan(file.path, ast) };
|
|
59
|
-
},
|
|
60
|
-
}],
|
|
61
62
|
};
|
|
62
63
|
/** Parses like the babel-syntax provider; a file it rejects is that plugin's diagnostic, not a security finding. */
|
|
63
64
|
function parseSource(path, bytes) {
|
|
@@ -218,7 +219,7 @@ function scan(path, ast) {
|
|
|
218
219
|
}
|
|
219
220
|
function report(rule, node, message) {
|
|
220
221
|
const line = node.loc?.start.line ?? 1;
|
|
221
|
-
findings.push({
|
|
222
|
+
findings.push({ check: rule, level: catalog[rule].level, message, path,
|
|
222
223
|
line, endLine: Math.max(line, node.loc?.end.line ?? line) });
|
|
223
224
|
}
|
|
224
225
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Node } from '@babel/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { StructuralObservation } from '@repometry/core/internal/engine/author-contracts.js';
|
|
3
|
+
import type { FunctionComplexity } from '@repometry/core/internal/model/code-structure.js';
|
|
3
4
|
import type { FunctionNaming } from './qualified-names.js';
|
|
4
5
|
export declare function structuralObservations(ast: Node, names: ReadonlyMap<Node, FunctionNaming>): {
|
|
5
6
|
observations: StructuralObservation[];
|
|
@@ -72,8 +72,8 @@ export function structuralObservations(ast, names) {
|
|
|
72
72
|
visit(child, frame, depth + Number(block), node);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function observe(
|
|
76
|
-
observations.push({
|
|
75
|
+
function observe(check, value, label, location, anchor) {
|
|
76
|
+
observations.push({ check, value, label, line: location?.loc?.start.line, endLine: location?.loc?.end.line,
|
|
77
77
|
...(anchor === undefined ? {} : { anchor }) });
|
|
78
78
|
}
|
|
79
79
|
}
|