repometry 0.10.0 → 0.11.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 -3
- package/package.json +1 -1
- package/target/main/resources/config/process-plugins-v1.schema.json +22 -0
- package/target/main/resources/report/json/config-v1.schema.json +125 -2
- package/target/main/resources/report/json/file-metrics-v1.schema.json +23 -1
- package/target/main/resources/report/json/pull-review-v2.schema.json +100 -0
- package/target/main/ts/api/cache/root.d.ts +3 -0
- package/target/main/ts/api/cache/root.js +21 -0
- package/target/main/ts/api/gh/github.d.ts +0 -4
- package/target/main/ts/api/gh/github.js +3 -33
- package/target/main/ts/api/git/blob-batch.js +2 -1
- package/target/main/ts/api/git/blob-history.d.ts +20 -0
- package/target/main/ts/api/git/blob-history.js +54 -0
- package/target/main/ts/api/git/commit-metadata.d.ts +0 -1
- package/target/main/ts/api/git/commit-metadata.js +1 -10
- package/target/main/ts/api/git/git-executable.d.ts +1 -0
- package/target/main/ts/api/git/git-executable.js +31 -0
- package/target/main/ts/api/git/git.d.ts +8 -1
- package/target/main/ts/api/git/git.js +58 -61
- package/target/main/ts/api/git/inspection-source.d.ts +2 -1
- package/target/main/ts/api/git/inspection-source.js +3 -2
- package/target/main/ts/api/git/local-sources.js +3 -2
- package/target/main/ts/api/git/source-cache.d.ts +0 -2
- package/target/main/ts/api/git/source-cache.js +1 -16
- package/target/main/ts/api/import/cobertura.d.ts +2 -0
- package/target/main/ts/api/import/cobertura.js +160 -0
- package/target/main/ts/api/import/coverage-xml.d.ts +7 -0
- package/target/main/ts/api/import/coverage-xml.js +135 -0
- package/target/main/ts/api/import/lcov-files.d.ts +3 -1
- package/target/main/ts/api/import/lcov-files.js +23 -4
- package/target/main/ts/api/process/go-parser-cache.d.ts +1 -0
- package/target/main/ts/api/process/go-parser-cache.js +71 -0
- package/target/main/ts/api/process/go-parser-files.d.ts +5 -0
- package/target/main/ts/api/process/go-parser-files.js +65 -0
- package/target/main/ts/api/process/host-language-runner.d.ts +3 -5
- package/target/main/ts/api/process/host-language-runner.js +21 -66
- package/target/main/ts/api/process/host-tool.d.ts +22 -0
- package/target/main/ts/api/process/host-tool.js +87 -0
- package/target/main/ts/cli/arguments.js +2 -4
- package/target/main/ts/cli/config.d.ts +20 -3
- package/target/main/ts/cli/config.js +43 -10
- package/target/main/ts/cli/imports.d.ts +1 -0
- package/target/main/ts/cli/imports.js +6 -2
- package/target/main/ts/cli/main.js +66 -215
- package/target/main/ts/cli/range-inspection.d.ts +25 -0
- package/target/main/ts/cli/range-inspection.js +29 -0
- package/target/main/ts/cli/range-jobs.d.ts +22 -0
- package/target/main/ts/cli/range-jobs.js +150 -0
- package/target/main/ts/cli/range-worker.d.ts +1 -0
- package/target/main/ts/cli/range-worker.js +36 -0
- package/target/main/ts/cli/reporting.d.ts +2 -7
- package/target/main/ts/cli/reporting.js +23 -37
- package/target/main/ts/compose/analysis-report.d.ts +1 -1
- package/target/main/ts/compose/analysis-report.js +8 -8
- package/target/main/ts/compose/analysis-results.d.ts +1 -1
- package/target/main/ts/compose/analysis-results.js +4 -6
- package/target/main/ts/compose/analysis-steps.d.ts +23 -0
- package/target/main/ts/compose/analysis-steps.js +215 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +1 -1
- package/target/main/ts/compose/analyze-snapshot.js +8 -12
- package/target/main/ts/compose/built-ins.d.ts +3 -0
- package/target/main/ts/compose/built-ins.js +5 -0
- package/target/main/ts/compose/diff-coverage.d.ts +2 -4
- package/target/main/ts/compose/diff-coverage.js +16 -13
- package/target/main/ts/compose/history-cache.d.ts +3 -1
- package/target/main/ts/compose/history-cache.js +2 -0
- package/target/main/ts/compose/inspect.d.ts +6 -9
- package/target/main/ts/compose/inspect.js +11 -12
- package/target/main/ts/compose/languages.d.ts +4 -1
- package/target/main/ts/compose/languages.js +9 -6
- package/target/main/ts/compose/native-language-plugins.d.ts +0 -1
- package/target/main/ts/compose/native-language-plugins.js +11 -17
- package/target/main/ts/compose/phases.d.ts +126 -0
- package/target/main/ts/compose/phases.js +154 -0
- package/target/main/ts/compose/plugin-list.d.ts +8 -2
- package/target/main/ts/compose/plugin-list.js +4 -13
- package/target/main/ts/compose/process-plugins.js +1 -1
- package/target/main/ts/compose/review.d.ts +2 -4
- package/target/main/ts/compose/review.js +10 -9
- package/target/main/ts/compose/sources.d.ts +1 -2
- package/target/main/ts/compose/sources.js +7 -7
- package/target/main/ts/core/engine/execute.d.ts +4 -1
- package/target/main/ts/core/engine/execute.js +1 -1
- package/target/main/ts/core/engine/manifest.d.ts +0 -1
- package/target/main/ts/core/engine/manifest.js +9 -13
- package/target/main/ts/core/engine/plugin.d.ts +1 -1
- package/target/main/ts/core/engine/report-products.js +3 -2
- package/target/main/ts/core/model/changes.d.ts +2 -0
- package/target/main/ts/core/model/changes.js +5 -1
- package/target/main/ts/core/model/clone-source.d.ts +2 -0
- package/target/main/ts/core/model/clone-source.js +4 -0
- package/target/main/ts/core/model/code-structure.d.ts +4 -1
- package/target/main/ts/core/model/code-structure.js +3 -1
- package/target/main/ts/core/model/coverage-input.d.ts +12 -0
- package/target/main/ts/core/model/coverage-input.js +11 -0
- package/target/main/ts/core/model/diff-coverage.d.ts +2 -0
- package/target/main/ts/core/model/diff-coverage.js +9 -1
- package/target/main/ts/core/model/language.d.ts +28 -0
- package/target/main/ts/core/model/language.js +25 -1
- package/target/main/ts/core/model/quality-summary.js +1 -1
- package/target/main/ts/core/model/report.d.ts +0 -2
- package/target/main/ts/core/model/report.js +0 -20
- package/target/main/ts/core/ports/tool-runner.d.ts +13 -0
- package/target/main/ts/core/usecases/inspect.d.ts +1 -2
- package/target/main/ts/core/usecases/review.js +11 -3
- package/target/main/ts/index.d.ts +6 -33
- package/target/main/ts/index.js +3 -18
- package/target/main/ts/plugin.d.ts +7 -3
- package/target/main/ts/plugin.js +3 -0
- package/target/main/ts/plugins/built-in.d.ts +6 -0
- package/target/main/ts/plugins/built-in.js +39 -0
- package/target/main/ts/plugins/coverage/coverage.d.ts +3 -24
- package/target/main/ts/plugins/coverage/coverage.js +8 -11
- package/target/main/ts/plugins/coverage/diff-coverage.d.ts +1 -5
- package/target/main/ts/plugins/coverage/diff-coverage.js +5 -14
- package/target/main/ts/plugins/duplication/duplication.d.ts +1 -3
- package/target/main/ts/plugins/duplication/duplication.js +2 -6
- package/target/main/ts/plugins/language-js/babel-provider.js +3 -2
- package/target/main/ts/plugins/language-js/structural-observations.js +1 -1
- package/target/main/ts/plugins/language-js/syntax.d.ts +2 -0
- package/target/main/ts/plugins/language-js/syntax.js +11 -0
- package/target/main/ts/plugins/maintainability/maintainability.d.ts +1 -8
- package/target/main/ts/plugins/maintainability/maintainability.js +4 -10
- package/target/main/ts/plugins/source/forges.js +1 -1
- package/target/main/ts/report/html/app/viewer-languages.d.ts +3 -1
- package/target/main/ts/report/html/app/viewer-languages.js +11 -1
- package/target/main/ts/report/html/app/viewer-metrics-view.js +1 -1
- package/target/main/ts/report/html/app/viewer-source-view.js +2 -2
- package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +7 -6
- package/target/main/ts/report/html/app/viewer-tokenizer.js +72 -71
- package/target/main/ts/report/html/site/export-site.d.ts +1 -5
- package/target/main/ts/report/html/site/export-site.js +2 -6
- package/target/main/ts/report/html/site/projects.d.ts +1 -3
- package/target/main/ts/report/html/site/projects.js +2 -4
- package/target/main/ts/report/json/projections/commit-summary.js +5 -7
- package/target/main/ts/report/json/projections/file-metrics.js +1 -1
- package/target/main/ts/report/json/projections/inspection-context.d.ts +1 -0
- package/target/main/ts/report/json/projections/inspection-context.js +19 -1
- package/target/main/ts/report/json/projections/inspection-details.js +7 -2
- package/target/main/ts/report/json/projections/metric-values.d.ts +5 -0
- package/target/main/ts/report/json/projections/metric-values.js +9 -6
- package/target/main/ts/report/json/store/local-store.js +2 -0
- package/target/main/ts/report/json/store/replace-file.d.ts +1 -1
- package/target/main/ts/report/json/store/replace-file.js +24 -3
- package/target/main/ts/report/json/store/store-check.js +10 -1
- package/target/main/ts/report/json/validation/metabranch.d.ts +1 -1
- package/target/main/ts/report/json/validation/metabranch.js +6 -3
- package/target/main/ts/report/json/wire/file-metrics-model.d.ts +3 -1
- package/target/main/ts/report.d.ts +13 -1
- package/target/main/ts/report.js +7 -1
- package/target/main/ts/api/git/metabranch-worktree.d.ts +0 -1
- package/target/main/ts/api/git/metabranch-worktree.js +0 -35
- package/target/main/ts/api/worker/remote-executor.d.ts +0 -2
- package/target/main/ts/api/worker/remote-executor.js +0 -46
- package/target/main/ts/api/worker/worker-protocol.d.ts +0 -7
- package/target/main/ts/api/worker/worker-protocol.js +0 -127
- package/target/main/ts/api/worker/worker.d.ts +0 -5
- package/target/main/ts/api/worker/worker.js +0 -86
- package/target/main/ts/compose/analysis-files.d.ts +0 -15
- package/target/main/ts/compose/analysis-files.js +0 -129
- package/target/main/ts/compose/analysis-imports.d.ts +0 -7
- package/target/main/ts/compose/analysis-imports.js +0 -36
- package/target/main/ts/compose/analysis-repository.d.ts +0 -7
- package/target/main/ts/compose/analysis-repository.js +0 -99
- package/target/main/ts/compose/analysis-sources.d.ts +0 -48
- package/target/main/ts/compose/analysis-sources.js +0 -54
- package/target/main/ts/compose/prepare-metabranch.d.ts +0 -9
- package/target/main/ts/compose/prepare-metabranch.js +0 -17
- package/target/main/ts/compose/security-plugins.d.ts +0 -1
- package/target/main/ts/compose/security-plugins.js +0 -7
- package/target/main/ts/core/usecases/compare.d.ts +0 -6
- package/target/main/ts/core/usecases/compare.js +0 -189
- package/target/main/ts/report/json/store/components.d.ts +0 -2
- package/target/main/ts/report/json/store/components.js +0 -32
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isCloneSource } from '../../core/model/clone-source.js';
|
|
1
|
+
import { pluginApi } from '../../core/engine/plugin.js';
|
|
3
2
|
import { codeStructure, structureCodeLines } from '../../core/model/code-structure.js';
|
|
4
3
|
import { findingResult } from '../../core/model/finding.js';
|
|
5
4
|
import { definitions } from '../../core/model/measurement.js';
|
|
6
5
|
import { sourceFile } from '../../core/model/snapshot.js';
|
|
7
6
|
import { structuralRules } from '../../core/profile/maintainability.js';
|
|
8
7
|
import { structuralSmells } from './structural-smells.js';
|
|
9
|
-
export const fileQuality = {
|
|
10
|
-
id: 'repometry.maintainability-file/v1',
|
|
11
|
-
accepts: (value) => isRecord(value) && (value.cloneSource === undefined || isCloneSource(value.cloneSource)) && findingResult.accepts(value),
|
|
12
|
-
};
|
|
13
8
|
export const maintainability = {
|
|
14
9
|
id: 'maintainability', version: '1.0.0', api: pluginApi,
|
|
15
10
|
kinds: ['analysis'],
|
|
16
|
-
produces: [{ contract:
|
|
11
|
+
produces: [{ contract: findingResult.id, persistence: 'report', metrics: [
|
|
17
12
|
{ id: definitions.cognitiveComplexity, label: 'Cognitive complexity', unit: 'count', scope: 'file', aggregate: 'sum',
|
|
18
13
|
better: 'lower', group: 'Maintainability' },
|
|
19
14
|
{ id: definitions.classes, label: 'Classes', unit: 'count', scope: 'file', aggregate: 'sum', better: 'none', group: 'Size' },
|
|
@@ -23,10 +18,10 @@ export const maintainability = {
|
|
|
23
18
|
] }],
|
|
24
19
|
rules: Object.entries(structuralRules).map(([id, { limit, minutesPerExcess }]) => ({ id, category: 'structure', defaults: { limit, cost: minutesPerExcess } })),
|
|
25
20
|
operations: [{
|
|
26
|
-
id: 'file', role: 'inspection', inputs: { syntax: codeStructure, source: sourceFile }, output:
|
|
21
|
+
id: 'file', role: 'inspection', inputs: { syntax: codeStructure, source: sourceFile }, output: findingResult,
|
|
27
22
|
execute(inputs) {
|
|
28
23
|
const facts = inputs.read('syntax', codeStructure);
|
|
29
|
-
const { path, observations = [], cognitiveFunctions = [], cognitiveComplexity, classes, commentLines
|
|
24
|
+
const { path, observations = [], cognitiveFunctions = [], cognitiveComplexity, classes, commentLines } = facts;
|
|
30
25
|
const codeLines = structureCodeLines(facts);
|
|
31
26
|
const counts = [[definitions.cognitiveComplexity, cognitiveComplexity], [definitions.classes, classes],
|
|
32
27
|
[definitions.codeLines, codeLines?.length], [definitions.comments, commentLines]];
|
|
@@ -36,7 +31,6 @@ export const maintainability = {
|
|
|
36
31
|
...cognitiveFunctions.map(({ line, column, name, value }) => ({ definition: definitions.cognitiveComplexity, target: 'function', path, line, column, name, value })),
|
|
37
32
|
...counts.flatMap(([definition, value]) => value === undefined ? [] : [{ definition, target: 'file', path, value }]),
|
|
38
33
|
],
|
|
39
|
-
...(clones === undefined ? {} : { cloneSource: clones }),
|
|
40
34
|
};
|
|
41
35
|
},
|
|
42
36
|
}],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pluginApi } from '../../core/engine/plugin.js';
|
|
2
2
|
const manifest = {
|
|
3
3
|
api: pluginApi, version: '1.0.0', kinds: ['source'],
|
|
4
|
-
operations: [], produces: [{ contract: 'repometry.source-locator/v1', persistence: '
|
|
4
|
+
operations: [], produces: [{ contract: 'repometry.source-locator/v1', persistence: 'transient' }],
|
|
5
5
|
};
|
|
6
6
|
export const localSource = {
|
|
7
7
|
...manifest, id: 'local',
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { FileMetricsReport } from '../../json/wire/file-metrics-model.js';
|
|
1
|
+
import type { FileMetricsReport, LanguageSyntax } from '../../json/wire/file-metrics-model.js';
|
|
2
2
|
type FileEntry = FileMetricsReport['files'][number];
|
|
3
3
|
/** Takes the languages of the inspection on screen: their names, and the colours the plugins and the catalog give them. */
|
|
4
4
|
export declare function useLanguages(metrics: Pick<FileMetricsReport, 'languages' | 'files'>): void;
|
|
5
5
|
/** The id of a file's language, as the inspection gives it: what decides how its source is read. */
|
|
6
6
|
export declare function languageIdOf(path: string): string | undefined;
|
|
7
|
+
/** How a file's language is coloured, as its plugin declares it; none for a language that declares no syntax. */
|
|
8
|
+
export declare function syntaxOf(path: string): LanguageSyntax | undefined;
|
|
7
9
|
/**
|
|
8
10
|
* Dependency lockfiles, by exact file name. They are generated, often the largest files in a repository, and no
|
|
9
11
|
* plugin reads them: the language bar and the Metrics list give them a category of their own beside the ignored files.
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* The inspection's languages, which its files point to by index, the colour of each by its name, each file's id, and
|
|
3
|
+
* the syntax each language declares by its id.
|
|
4
|
+
*/
|
|
2
5
|
let languages = [];
|
|
3
6
|
let colors = new Map();
|
|
4
7
|
let ids = new Map();
|
|
8
|
+
let syntaxes = new Map();
|
|
5
9
|
function nameOf(language) {
|
|
6
10
|
return language.label ?? language.id;
|
|
7
11
|
}
|
|
@@ -11,11 +15,17 @@ export function useLanguages(metrics) {
|
|
|
11
15
|
colors = new Map(languages.flatMap(language => language.color ? [[nameOf(language), language.color]] : []));
|
|
12
16
|
ids = new Map(metrics.files.flatMap(file => file.language === undefined || !languages[file.language] ? []
|
|
13
17
|
: [[file.path, languages[file.language].id]]));
|
|
18
|
+
syntaxes = new Map(languages.flatMap(language => language.syntax ? [[language.id, language.syntax]] : []));
|
|
14
19
|
}
|
|
15
20
|
/** The id of a file's language, as the inspection gives it: what decides how its source is read. */
|
|
16
21
|
export function languageIdOf(path) {
|
|
17
22
|
return ids.get(path);
|
|
18
23
|
}
|
|
24
|
+
/** How a file's language is coloured, as its plugin declares it; none for a language that declares no syntax. */
|
|
25
|
+
export function syntaxOf(path) {
|
|
26
|
+
const id = ids.get(path);
|
|
27
|
+
return id === undefined ? undefined : syntaxes.get(id);
|
|
28
|
+
}
|
|
19
29
|
/**
|
|
20
30
|
* Dependency lockfiles, by exact file name. They are generated, often the largest files in a repository, and no
|
|
21
31
|
* plugin reads them: the language bar and the Metrics list give them a category of their own beside the ignored files.
|
|
@@ -21,7 +21,7 @@ function tableNote(columns) {
|
|
|
21
21
|
}
|
|
22
22
|
function componentHint(hint) {
|
|
23
23
|
hint.hidden = false;
|
|
24
|
-
hint.replaceChildren('No components are defined for this repository.
|
|
24
|
+
hint.replaceChildren('No components are defined for this repository. Set the components key in ', element('code', '', 'repometry.config.json'), ' to compare groups of paths here.');
|
|
25
25
|
}
|
|
26
26
|
/** The Metrics page: a query, a grouping and columns over the folder's files, their languages, and the totals beside. */
|
|
27
27
|
export function metricsView(details, navigation, settings, directory, selectedFile) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// on the lines they describe, or the tests' coverage in the gutter; and the short excerpt a finding shows.
|
|
3
3
|
import { element } from './viewer-dom.js';
|
|
4
4
|
import { bridgeStates, hitLabel } from './viewer-line-coverage.js';
|
|
5
|
-
import {
|
|
5
|
+
import { syntaxOf } from './viewer-languages.js';
|
|
6
6
|
import { highlighter, runNodes, tokenizer } from './viewer-tokenizer.js';
|
|
7
7
|
function sourceLines(text) {
|
|
8
8
|
return text.replace(/\r\n?/g, '\n').replace(/\n$/, '').split('\n');
|
|
@@ -43,7 +43,7 @@ function noteBox(note) {
|
|
|
43
43
|
export function renderSource(container, text, options) {
|
|
44
44
|
const lines = sourceLines(text);
|
|
45
45
|
// Tokenized up front, in order, since a comment's state carries from line to line.
|
|
46
|
-
const tokenize = tokenizer(
|
|
46
|
+
const tokenize = tokenizer(syntaxOf(options.path));
|
|
47
47
|
const tokens = lines.map(line => tokenize(line));
|
|
48
48
|
const states = new Map([...options.coverage ?? []].map(([line, reading]) => [line, reading.state]));
|
|
49
49
|
const bridged = bridgeStates(states);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import type { LanguageSyntax } from '../../json/wire/file-metrics-model.js';
|
|
1
2
|
export type TokenKind = '' | 'c' | 's' | 'n' | 'k';
|
|
2
3
|
export type Run = [TokenKind, string];
|
|
3
4
|
/**
|
|
4
|
-
* Splits lines
|
|
5
|
-
* keywords. It honours escapes and character classes, and
|
|
6
|
-
* before the slash. State carries across lines, so a block comment or a
|
|
7
|
-
*
|
|
5
|
+
* Splits lines into coloured runs by a language's syntax data: comments, strings, regular expressions, numbers and
|
|
6
|
+
* keywords. It honours escapes and character classes, and where the data asks for regular expressions it tells one from
|
|
7
|
+
* a division by what comes before the slash. State carries across lines, so a block comment or a multi-line string
|
|
8
|
+
* stays coloured to its end. Without syntax a line comes back as plain text.
|
|
8
9
|
*/
|
|
9
|
-
export declare function tokenizer(
|
|
10
|
+
export declare function tokenizer(syntax: LanguageSyntax | undefined): (line: string) => Run[];
|
|
10
11
|
/** A line's runs as nodes: coloured spans and plain text. */
|
|
11
12
|
export declare function runNodes(lineRuns: readonly Run[]): Node[];
|
|
12
|
-
/** Highlights a file's lines, or a snippet of them, by the file's language. */
|
|
13
|
+
/** Highlights a file's lines, or a snippet of them, by the syntax of the file's language. */
|
|
13
14
|
export declare function highlighter(path: string): (line: string) => Node[];
|
|
@@ -1,40 +1,55 @@
|
|
|
1
|
-
// Light highlighting for JavaScript and TypeScript: a scanner, not a parser, that colours comments, strings, regular
|
|
2
|
-
// expressions, numbers and keywords. A file is read by its language as the inspection names it; any other language comes
|
|
3
|
-
// back as plain text, never in another language's colours.
|
|
4
1
|
import { element } from './viewer-dom.js';
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { syntaxOf } from './viewer-languages.js';
|
|
3
|
+
const form = (kind, start, end, multiline = false, raw = false) => ({ kind, start, end, multiline, raw });
|
|
4
|
+
/** The syntax data in the shape the scanner reads: forms longest marker first, words as sets. */
|
|
5
|
+
function grammarOf({ lineComments = [], blockComments = [], strings = [], stringPrefixes = [], keywords, regexAfter }) {
|
|
6
|
+
const forms = [
|
|
7
|
+
...lineComments.map(start => form('c', start, '', false, true)),
|
|
8
|
+
...blockComments.map(([start, end]) => form('c', start, end, true, true)),
|
|
9
|
+
...strings.map(({ quote, multiline, raw }) => form('s', quote, quote, multiline, raw)),
|
|
10
|
+
];
|
|
11
|
+
return {
|
|
12
|
+
// Longest marker first; the sort is stable, so on equal length a comment, listed first, wins.
|
|
13
|
+
forms: forms.sort((a, b) => b.start.length - a.start.length),
|
|
14
|
+
keywords: new Set(keywords),
|
|
15
|
+
prefixes: new Set(stringPrefixes.map(prefix => prefix.toLowerCase())),
|
|
16
|
+
regexAfter: regexAfter && new Set(regexAfter),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Where a form ends from `from` on: the index after its end marker, or the line's end when it stays open. */
|
|
20
|
+
function closeAt(line, from, open) {
|
|
21
|
+
if (!open.end)
|
|
22
|
+
return [line.length, true];
|
|
15
23
|
let at = from;
|
|
16
|
-
while (at < line.length && line
|
|
17
|
-
at += line[at] === '\\' ? 2 : 1;
|
|
18
|
-
return at < line.length ? [at +
|
|
24
|
+
while (at < line.length && !line.startsWith(open.end, at))
|
|
25
|
+
at += !open.raw && line[at] === '\\' ? 2 : 1;
|
|
26
|
+
return at < line.length ? [at + open.end.length, true] : [line.length, false];
|
|
19
27
|
}
|
|
20
28
|
/** Takes the run up to `stop` as one token. */
|
|
21
29
|
function take(cursor, kind, stop) {
|
|
22
30
|
cursor.push(kind, cursor.line.slice(cursor.at, stop));
|
|
23
31
|
cursor.at = stop;
|
|
24
32
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
function close(state, closed) {
|
|
34
|
+
state.open = undefined;
|
|
35
|
+
if (closed.kind === 's')
|
|
36
|
+
state.regexAllowed = false;
|
|
37
|
+
}
|
|
38
|
+
/** Inside a form that an earlier line or run left open: up to its end, or the whole line. */
|
|
39
|
+
function inside(cursor, open) {
|
|
40
|
+
const [stop, closed] = closeAt(cursor.line, cursor.at, open);
|
|
41
|
+
take(cursor, open.kind, stop);
|
|
42
|
+
if (closed)
|
|
43
|
+
close(cursor.state, open);
|
|
30
44
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
/** Opens a form after `prefix` characters: a multi-line one as its start marker, left open; another to its end. */
|
|
46
|
+
function begin(cursor, opened, prefix) {
|
|
47
|
+
const body = cursor.at + prefix + opened.start.length;
|
|
48
|
+
take(cursor, opened.kind, opened.multiline ? body : closeAt(cursor.line, body, opened)[0]);
|
|
49
|
+
if (opened.multiline)
|
|
50
|
+
cursor.state.open = opened;
|
|
51
|
+
else
|
|
52
|
+
close(cursor.state, opened);
|
|
38
53
|
}
|
|
39
54
|
/**
|
|
40
55
|
* The end of a regular expression literal that starts at `at`, its flags included, honouring escapes and character
|
|
@@ -67,36 +82,15 @@ function regexEnd(line, at) {
|
|
|
67
82
|
const char = (cursor, offset = 0) => cursor.line[cursor.at + offset];
|
|
68
83
|
/** Where a token can start, tried in order; each takes what it recognises and says whether it did. */
|
|
69
84
|
const starts = [
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
take(cursor, 'c', cursor.line.length);
|
|
74
|
-
return true;
|
|
75
|
-
},
|
|
76
|
-
function blockComment(cursor) {
|
|
77
|
-
if (char(cursor) !== '/' || char(cursor, 1) !== '*')
|
|
78
|
-
return false;
|
|
79
|
-
take(cursor, 'c', cursor.at + 2);
|
|
80
|
-
cursor.state.open = 'comment';
|
|
81
|
-
return true;
|
|
82
|
-
},
|
|
83
|
-
function template(cursor) {
|
|
84
|
-
if (char(cursor) !== '`')
|
|
85
|
-
return false;
|
|
86
|
-
take(cursor, 's', cursor.at + 1);
|
|
87
|
-
cursor.state.open = 'template';
|
|
88
|
-
return true;
|
|
89
|
-
},
|
|
90
|
-
function quoted(cursor) {
|
|
91
|
-
const quote = char(cursor);
|
|
92
|
-
if (quote !== '"' && quote !== "'")
|
|
85
|
+
function marked(cursor) {
|
|
86
|
+
const found = cursor.grammar.forms.find(candidate => cursor.line.startsWith(candidate.start, cursor.at));
|
|
87
|
+
if (!found)
|
|
93
88
|
return false;
|
|
94
|
-
|
|
95
|
-
cursor.state.regexAllowed = false;
|
|
89
|
+
begin(cursor, found, 0);
|
|
96
90
|
return true;
|
|
97
91
|
},
|
|
98
92
|
function regex(cursor) {
|
|
99
|
-
if (char(cursor) !== '/' || !cursor.state.regexAllowed)
|
|
93
|
+
if (char(cursor) !== '/' || !cursor.grammar.regexAfter || !cursor.state.regexAllowed)
|
|
100
94
|
return false;
|
|
101
95
|
const end = regexEnd(cursor.line, cursor.at);
|
|
102
96
|
if (end < 0)
|
|
@@ -109,12 +103,20 @@ const starts = [
|
|
|
109
103
|
const found = /^[A-Za-z_$][\w$]*/.exec(cursor.line.slice(cursor.at))?.[0];
|
|
110
104
|
if (!found)
|
|
111
105
|
return false;
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
const { grammar } = cursor;
|
|
107
|
+
// A declared string prefix right before a quote belongs to the string.
|
|
108
|
+
const quoted = grammar.prefixes.has(found.toLowerCase())
|
|
109
|
+
&& grammar.forms.find(candidate => candidate.kind === 's' && cursor.line.startsWith(candidate.start, cursor.at + found.length));
|
|
110
|
+
if (quoted) {
|
|
111
|
+
begin(cursor, quoted, found.length);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
take(cursor, grammar.keywords.has(found) ? 'k' : '', cursor.at + found.length);
|
|
115
|
+
cursor.state.regexAllowed = !!grammar.regexAfter?.has(found);
|
|
114
116
|
return true;
|
|
115
117
|
},
|
|
116
118
|
function number(cursor) {
|
|
117
|
-
const found =
|
|
119
|
+
const found = /^\.?\d(?:[eEpP][+-]\d|\.\d|\w)*/.exec(cursor.line.slice(cursor.at))?.[0];
|
|
118
120
|
if (!found)
|
|
119
121
|
return false;
|
|
120
122
|
take(cursor, 'n', cursor.at + found.length);
|
|
@@ -155,23 +157,22 @@ function runs() {
|
|
|
155
157
|
};
|
|
156
158
|
}
|
|
157
159
|
/**
|
|
158
|
-
* Splits lines
|
|
159
|
-
* keywords. It honours escapes and character classes, and
|
|
160
|
-
* before the slash. State carries across lines, so a block comment or a
|
|
161
|
-
*
|
|
160
|
+
* Splits lines into coloured runs by a language's syntax data: comments, strings, regular expressions, numbers and
|
|
161
|
+
* keywords. It honours escapes and character classes, and where the data asks for regular expressions it tells one from
|
|
162
|
+
* a division by what comes before the slash. State carries across lines, so a block comment or a multi-line string
|
|
163
|
+
* stays coloured to its end. Without syntax a line comes back as plain text.
|
|
162
164
|
*/
|
|
163
|
-
export function tokenizer(
|
|
164
|
-
if (!
|
|
165
|
+
export function tokenizer(syntax) {
|
|
166
|
+
if (!syntax)
|
|
165
167
|
return line => [['', line]];
|
|
166
|
-
const
|
|
168
|
+
const grammar = grammarOf(syntax);
|
|
169
|
+
const state = { open: undefined, regexAllowed: true };
|
|
167
170
|
return line => {
|
|
168
171
|
const collected = runs();
|
|
169
|
-
const cursor = { line, at: 0, state, push: collected.push };
|
|
172
|
+
const cursor = { line, grammar, at: 0, state, push: collected.push };
|
|
170
173
|
while (cursor.at < line.length) {
|
|
171
|
-
if (state.open
|
|
172
|
-
|
|
173
|
-
else if (state.open === 'template')
|
|
174
|
-
insideTemplate(cursor);
|
|
174
|
+
if (state.open)
|
|
175
|
+
inside(cursor, state.open);
|
|
175
176
|
else
|
|
176
177
|
starts.find(start => start(cursor));
|
|
177
178
|
}
|
|
@@ -182,8 +183,8 @@ export function tokenizer(language) {
|
|
|
182
183
|
export function runNodes(lineRuns) {
|
|
183
184
|
return lineRuns.map(([kind, value]) => kind ? element('span', `tok-${kind}`, value) : document.createTextNode(value));
|
|
184
185
|
}
|
|
185
|
-
/** Highlights a file's lines, or a snippet of them, by the file's language. */
|
|
186
|
+
/** Highlights a file's lines, or a snippet of them, by the syntax of the file's language. */
|
|
186
187
|
export function highlighter(path) {
|
|
187
|
-
const tokenize = tokenizer(
|
|
188
|
+
const tokenize = tokenizer(syntaxOf(path));
|
|
188
189
|
return line => runNodes(tokenize(line));
|
|
189
190
|
}
|
|
@@ -9,12 +9,8 @@ export interface SiteOptions extends InspectionOptions {
|
|
|
9
9
|
readonly sources?: SourceLocator;
|
|
10
10
|
readonly branch?: string;
|
|
11
11
|
readonly readCommitMetadata?: ReadCommitMetadata;
|
|
12
|
-
/** The page footer with the project link and license; --no-footer leaves it out. */
|
|
13
|
-
readonly footer?: boolean;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
export declare function withoutFooter(html: string): string;
|
|
17
|
-
export declare function viewerAssets(rows: readonly CommitSummary[], { title, pulls, footer }: SiteOptions): Promise<Map<string, Buffer<ArrayBufferLike>>>;
|
|
13
|
+
export declare function viewerAssets(rows: readonly CommitSummary[], { title, pulls }: SiteOptions): Promise<Map<string, Buffer<ArrayBufferLike>>>;
|
|
18
14
|
export declare function siteFiles(reports: readonly Report[], options?: SiteOptions): Promise<Map<string, Buffer>>;
|
|
19
15
|
export declare function siteSummary(rows: readonly CommitSummary[], { components, pulls, sources, branch }: SiteOptions, inspectionPath?: (row: CommitSummary) => string | undefined): Buffer;
|
|
20
16
|
export declare function exportSite(reader: ReportReader, destination: string, options?: SiteOptions): Promise<void>;
|
|
@@ -28,11 +28,7 @@ async function listAssets(directory, include) {
|
|
|
28
28
|
return entries.filter(entry => entry.isFile() && include(entry.name))
|
|
29
29
|
.map(({ name }) => [name, new URL(encodeURIComponent(name), directory)]);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
export function withoutFooter(html) {
|
|
33
|
-
return html.replace(/\n[ \t]*<footer class="site-footer">[\s\S]*?<\/footer>/, '');
|
|
34
|
-
}
|
|
35
|
-
export async function viewerAssets(rows, { title = '', pulls = [], footer = true }) {
|
|
31
|
+
export async function viewerAssets(rows, { title = '', pulls = [] }) {
|
|
36
32
|
const files = new Map(await Promise.all((await listViewerAssets()).map(async ([name, source]) => {
|
|
37
33
|
const bytes = await readFile(source);
|
|
38
34
|
// The published viewer keeps its existing flat URLs for static hosts and open tabs.
|
|
@@ -43,7 +39,7 @@ export async function viewerAssets(rows, { title = '', pulls = [], footer = true
|
|
|
43
39
|
})));
|
|
44
40
|
const index = files.get('index.html').toString('utf8')
|
|
45
41
|
.replace('name="repometry-project" content=""', () => `name="repometry-project" content="${escapeAttribute(title)}"`);
|
|
46
|
-
files.set('index.html', Buffer.from(
|
|
42
|
+
files.set('index.html', Buffer.from(index));
|
|
47
43
|
const latest = rows[0];
|
|
48
44
|
for (const [name, data] of badges(latest, latest?.quality, latest?.counts?.security))
|
|
49
45
|
files.set(name, data);
|
|
@@ -2,10 +2,9 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { lstat, mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { readExportedSummary } from './exported-server.js';
|
|
5
|
-
import { withoutFooter } from './export-site.js';
|
|
6
5
|
const indexMarker = '<meta name="repometry-projects" content="1">';
|
|
7
6
|
const resources = '../../../../resources/viewer/';
|
|
8
|
-
export async function exportProjects(directory
|
|
7
|
+
export async function exportProjects(directory) {
|
|
9
8
|
const folders = await readdir(directory, { withFileTypes: true });
|
|
10
9
|
const candidates = folders.filter(entry => (entry.isDirectory() || entry.isSymbolicLink()) && !entry.name.startsWith('.'));
|
|
11
10
|
const entries = (await Promise.all(candidates.map(({ name }) => readProject(directory, name))))
|
|
@@ -16,8 +15,7 @@ export async function exportProjects(directory, { footer = true } = {}) {
|
|
|
16
15
|
['styles.css', await readFile(new URL(resources + 'styles.css', import.meta.url))],
|
|
17
16
|
['projects.js', await readFile(new URL('../app/viewer-projects.js', import.meta.url))],
|
|
18
17
|
['projects.json', JSON.stringify({ schema: 'urn:repometry:schema:projects:1', projects: entries }) + '\n'],
|
|
19
|
-
['index.html', await readFile(new URL(resources + 'projects.html', import.meta.url))
|
|
20
|
-
.then(page => footer ? page : Buffer.from(withoutFooter(page.toString('utf8'))))],
|
|
18
|
+
['index.html', await readFile(new URL(resources + 'projects.html', import.meta.url))],
|
|
21
19
|
]);
|
|
22
20
|
if (marker !== null && !marker.includes(indexMarker))
|
|
23
21
|
throw new Error('Directory already contains another site index');
|
|
@@ -5,7 +5,7 @@ import { securityCounts } from './security-summary.js';
|
|
|
5
5
|
import { compareHistoryEntries } from '../wire/public-history-model.js';
|
|
6
6
|
import { inspectionProfileDigest } from './inspection-context.js';
|
|
7
7
|
import { reportRevision } from '../validation/report.js';
|
|
8
|
-
import { canonicalMetricDescriptor, metricProjection } from './metric-values.js';
|
|
8
|
+
import { canonicalMetricDescriptor, metricProjection, unavailableStructureMetrics } from './metric-values.js';
|
|
9
9
|
import { summarySchema } from '../wire/summary-model.js';
|
|
10
10
|
export function commitSummary(report) {
|
|
11
11
|
const history = historyEntry(report);
|
|
@@ -111,17 +111,15 @@ export function historyEntry(report) {
|
|
|
111
111
|
lineCoverage = { covered: item.covered, total: item.total };
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
const unmeasured = new Set(report.pluginData?.inventory?.flatMap(
|
|
115
|
-
|
|
116
|
-
functions = null;
|
|
117
|
-
if (unmeasured.has('cyclomaticComplexity'))
|
|
118
|
-
maxComplexity = null;
|
|
114
|
+
const unmeasured = new Set(report.pluginData?.inventory?.flatMap(unavailableStructureMetrics));
|
|
115
|
+
const measured = (id, value) => unmeasured.has(id) ? null : value;
|
|
119
116
|
const window = report.appliedConfig.churnWindow;
|
|
120
117
|
const endingAt = isRecord(window) && typeof window.endingAt === 'string' ? window.endingAt : '';
|
|
121
118
|
const committedAt = Date.parse(report.committedAt ?? endingAt);
|
|
122
119
|
const generatedAt = Date.parse(report.generatedAt);
|
|
123
120
|
return { sha: report.subject.id, generatedAt: Number.isFinite(generatedAt) ? new Date(generatedAt).toISOString() : '',
|
|
124
121
|
...(Number.isFinite(committedAt) ? { committedAt: new Date(committedAt).toISOString() } : {}), status: report.status,
|
|
125
|
-
files: report.scope.files, parsed: report.scope.parsed, lines
|
|
122
|
+
files: report.scope.files, parsed: report.scope.parsed, lines: measured(definitions.lines, lines),
|
|
123
|
+
functions: measured(definitions.functions, functions), maxComplexity: measured(definitions.complexity, maxComplexity), lineCoverage };
|
|
126
124
|
}
|
|
127
125
|
//# sourceMappingURL=commit-summary.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileTypeId, fileTypes } from '../../../core/model/file-types.js';
|
|
2
2
|
import { isRecord } from '../../../core/engine/plugin.js';
|
|
3
3
|
import { canonicalMetricId, definitions } from '../../../core/model/measurement.js';
|
|
4
|
-
import { legacySyntaxPlugin } from '
|
|
4
|
+
import { legacySyntaxPlugin } from './inspection-context.js';
|
|
5
5
|
import { comparePaths } from '../../../core/model/snapshot.js';
|
|
6
6
|
import { metricProjection } from './metric-values.js';
|
|
7
7
|
import { fileMetricsSchema } from '../wire/file-metrics-model.js';
|
|
@@ -2,3 +2,4 @@ import type { Report } from '../validation/report.js';
|
|
|
2
2
|
import type { InspectionContext } from '../wire/inspection-context-model.js';
|
|
3
3
|
export declare function inspectionProfileDigest(report: Report): string | undefined;
|
|
4
4
|
export declare function inspectionContext(report: Report): InspectionContext | undefined;
|
|
5
|
+
export declare const legacySyntaxPlugin = "babel-syntax";
|
|
@@ -3,7 +3,6 @@ import { isRecord } from '../../../core/engine/plugin.js';
|
|
|
3
3
|
import { findingImportMethods } from '../../../core/model/scanner-import.js';
|
|
4
4
|
import { nativeScanners, securityCounts } from './security-summary.js';
|
|
5
5
|
import { normalizeFindingIgnore } from '../../../core/model/finding-ignore.js';
|
|
6
|
-
import { historicalPluginTools, legacySyntaxPlugin } from '../../../core/model/report.js';
|
|
7
6
|
import { comparePaths, digest } from '../../../core/model/snapshot.js';
|
|
8
7
|
export function inspectionProfileDigest(report) {
|
|
9
8
|
const profile = readProfile(report.appliedConfig);
|
|
@@ -79,4 +78,23 @@ function stringList(value) {
|
|
|
79
78
|
function ordered(values) {
|
|
80
79
|
return [...new Set(values)].sort(comparePaths);
|
|
81
80
|
}
|
|
81
|
+
export const legacySyntaxPlugin = 'babel-syntax';
|
|
82
|
+
// Keep history comparable when the parser starts recording its own tool versions.
|
|
83
|
+
function historicalPluginTools(plugins) {
|
|
84
|
+
if (!Array.isArray(plugins))
|
|
85
|
+
return plugins;
|
|
86
|
+
const syntax = plugins.find(entry => isRecord(entry) && entry.id === legacySyntaxPlugin);
|
|
87
|
+
if (!isRecord(syntax?.tools))
|
|
88
|
+
return plugins;
|
|
89
|
+
const { '@babel/types': types, ...native } = syntax.tools;
|
|
90
|
+
if (typeof types !== 'string')
|
|
91
|
+
return plugins;
|
|
92
|
+
return plugins.map(entry => {
|
|
93
|
+
if (entry === syntax)
|
|
94
|
+
return { ...syntax, tools: native };
|
|
95
|
+
if (!isRecord(entry) || (entry.id !== 'structure' && entry.id !== 'maintainability') || !isRecord(entry.tools))
|
|
96
|
+
return entry;
|
|
97
|
+
return { ...entry, tools: { '@babel/types': types, ...entry.tools } };
|
|
98
|
+
});
|
|
99
|
+
}
|
|
82
100
|
//# sourceMappingURL=inspection-context.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { javascriptType, typescriptType } from '../../../core/model/file-types.js';
|
|
2
2
|
import { isRecord } from '../../../core/model/plugin-data.js';
|
|
3
|
-
import { legacySyntaxPlugin } from '
|
|
3
|
+
import { legacySyntaxPlugin } from './inspection-context.js';
|
|
4
4
|
import { canonicalMetricId, definitions } from '../../../core/model/measurement.js';
|
|
5
5
|
import { lcovLines } from '../../../core/model/line-coverage.js';
|
|
6
6
|
import { comparePaths } from '../../../core/model/snapshot.js';
|
|
@@ -13,7 +13,12 @@ export function inspectionAsset(report, options) {
|
|
|
13
13
|
context: inspectionContext(report), inspection: inspectionDetails(report, options) };
|
|
14
14
|
}
|
|
15
15
|
export function inspectionDetails(report, { components = [], languages } = {}) {
|
|
16
|
-
const
|
|
16
|
+
const files = fileMetrics(report, languages);
|
|
17
|
+
const display = files.languages?.map(item => {
|
|
18
|
+
const syntax = languages?.syntax?.(item.id);
|
|
19
|
+
return syntax === undefined ? item : { ...item, syntax };
|
|
20
|
+
});
|
|
21
|
+
const metrics = display === undefined ? files : { ...files, languages: display };
|
|
17
22
|
const lineCoverage = report.pluginData?.products[lcovLines.id]?.[0]?.value;
|
|
18
23
|
const profile = profileSettings(report.appliedConfig);
|
|
19
24
|
const ruleCatalog = report.pluginData?.rules.flatMap(({ plugin, rules }) => rules.map(rule => ({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MetricDescriptor, MetricValues } from '../wire/summary-model.js';
|
|
2
|
+
import type { StructureMeasure } from '../../../core/model/code-structure.js';
|
|
2
3
|
import type { Report } from '../../../core/model/report.js';
|
|
3
4
|
export declare function metricProjection(report: Report): {
|
|
4
5
|
catalog: MetricDescriptor[];
|
|
@@ -6,4 +7,8 @@ export declare function metricProjection(report: Report): {
|
|
|
6
7
|
values: (path?: string, directory?: boolean) => MetricValues;
|
|
7
8
|
isAvailable: (id: string, path?: string, directory?: boolean) => boolean;
|
|
8
9
|
} | undefined;
|
|
10
|
+
export declare function unavailableStructureMetrics({ analysed, unmeasured }: {
|
|
11
|
+
readonly analysed: boolean;
|
|
12
|
+
readonly unmeasured?: readonly StructureMeasure[];
|
|
13
|
+
}): string[];
|
|
9
14
|
export declare function canonicalMetricDescriptor(metric: MetricDescriptor): MetricDescriptor;
|
|
@@ -22,15 +22,12 @@ export function metricProjection(report) {
|
|
|
22
22
|
rows.set(id, [row]);
|
|
23
23
|
}
|
|
24
24
|
const unavailable = new Map();
|
|
25
|
-
for (const
|
|
26
|
-
for (const
|
|
27
|
-
const id = structureMetricIds[measure];
|
|
28
|
-
if (id === undefined)
|
|
29
|
-
continue;
|
|
25
|
+
for (const file of metadata.inventory ?? []) {
|
|
26
|
+
for (const id of unavailableStructureMetrics(file)) {
|
|
30
27
|
let files = unavailable.get(id);
|
|
31
28
|
if (!files)
|
|
32
29
|
unavailable.set(id, files = new Set());
|
|
33
|
-
files.add(path);
|
|
30
|
+
files.add(file.path);
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
function isAvailable(id, path, directory = false) {
|
|
@@ -72,6 +69,12 @@ export function metricProjection(report) {
|
|
|
72
69
|
const privateMetrics = metadata.privateMetrics?.map(canonicalMetricId).filter(id => measured.has(id));
|
|
73
70
|
return { catalog: metrics, privateMetrics: privateMetrics?.length ? privateMetrics : undefined, values, isAvailable };
|
|
74
71
|
}
|
|
72
|
+
export function unavailableStructureMetrics({ analysed, unmeasured = [] }) {
|
|
73
|
+
const metrics = unmeasured.flatMap(measure => structureMetricIds[measure] ?? []);
|
|
74
|
+
if (!analysed && unmeasured.length)
|
|
75
|
+
metrics.push(definitions.lines);
|
|
76
|
+
return metrics;
|
|
77
|
+
}
|
|
75
78
|
export function canonicalMetricDescriptor(metric) {
|
|
76
79
|
const id = canonicalMetricId(metric.id);
|
|
77
80
|
if (!metric.ratio)
|
|
@@ -6,6 +6,7 @@ import { commitSummary, needsMaintainabilityRefresh, orderSummaries, repositoryS
|
|
|
6
6
|
import { summarySchema } from '../wire/summary-model.js';
|
|
7
7
|
import { compactJsonSchema } from '../wire/compact-json.js';
|
|
8
8
|
import { compareReports, readReport, readStoredReport, validSubjectId } from '../validation/report.js';
|
|
9
|
+
import { metaManifest } from '../validation/metabranch.js';
|
|
9
10
|
import { validateSummaryRow } from '../validation/summary-validation.js';
|
|
10
11
|
import { checkDirectory, ensureDirectory, hasCode } from './directory.js';
|
|
11
12
|
import { LocalObjectStore } from './object-store.js';
|
|
@@ -38,6 +39,7 @@ export class LocalReportStore {
|
|
|
38
39
|
const row = report.subject.kind === 'commit' ? commitSummary(report) : undefined;
|
|
39
40
|
if (row && !validateSummaryRow(row))
|
|
40
41
|
throw new Error(`Invalid report summary: ${report.subject.id}`);
|
|
42
|
+
await replaceFile(this.directory, 'manifest.json', `${JSON.stringify(metaManifest, null, 2)}\n`, true);
|
|
41
43
|
// Objects go first, so a published commit file never names a missing object.
|
|
42
44
|
await this.objects.write(objects);
|
|
43
45
|
// Keep the small index row on the first line of the same atomic file as the report.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function replaceFile(directory: string, name: string, contents: string | Uint8Array): Promise<void>;
|
|
1
|
+
export declare function replaceFile(directory: string, name: string, contents: string | Uint8Array, onlyIfMissing?: boolean): Promise<void>;
|