repometry 0.1.0 → 0.2.1
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 +3 -2
- package/package.json +5 -4
- package/target/main/resources/report/json/config-v1.schema.json +0 -1
- package/target/main/resources/report/json/report-v2.schema.json +14 -0
- package/target/main/resources/viewer/index.html +10 -20
- package/target/main/resources/viewer/styles.css +3 -29
- package/target/main/ts/api/gh/github.js +1 -0
- package/target/main/ts/api/git/blob-batch.js +1 -0
- package/target/main/ts/api/git/changes.js +1 -0
- package/target/main/ts/api/git/commit-metadata.js +5 -6
- package/target/main/ts/api/git/git-churn.js +1 -0
- package/target/main/ts/api/git/git-reader.js +1 -0
- package/target/main/ts/api/git/git.js +1 -0
- package/target/main/ts/api/git/inspection-source.js +1 -0
- package/target/main/ts/api/git/local-sources.js +1 -0
- package/target/main/ts/api/git/local.js +1 -0
- package/target/main/ts/api/git/metabranch-worktree.js +1 -0
- package/target/main/ts/api/git/source-cache.js +1 -0
- package/target/main/ts/api/import/finding-import.js +1 -0
- package/target/main/ts/api/import/lcov-files.js +1 -0
- package/target/main/ts/api/import/profile-file.js +1 -0
- package/target/main/ts/api/worker/remote-executor.js +1 -0
- package/target/main/ts/api/worker/worker-protocol.js +1 -0
- package/target/main/ts/api/worker/worker.js +1 -0
- package/target/main/ts/cli/arguments.js +1 -0
- package/target/main/ts/cli/config.d.ts +0 -1
- package/target/main/ts/cli/config.js +3 -5
- package/target/main/ts/cli/imports.js +1 -0
- package/target/main/ts/cli/main.js +3 -2
- package/target/main/ts/cli/reporting.js +9 -13
- package/target/main/ts/cli/revisions.js +1 -0
- package/target/main/ts/cli/store.js +1 -0
- package/target/main/ts/compose/analyze-snapshot.js +1 -0
- package/target/main/ts/compose/attach-churn.js +13 -0
- package/target/main/ts/compose/diff-coverage.js +1 -0
- package/target/main/ts/compose/inspect.js +1 -0
- package/target/main/ts/compose/plugin-list.js +1 -0
- package/target/main/ts/compose/prepare-metabranch.js +1 -0
- package/target/main/ts/compose/review.js +1 -0
- package/target/main/ts/compose/sources.js +1 -0
- package/target/main/ts/core/engine/execute.js +1 -0
- package/target/main/ts/core/engine/manifest.js +1 -0
- package/target/main/ts/core/engine/plan.js +1 -0
- package/target/main/ts/core/engine/report-products.js +1 -0
- package/target/main/ts/core/model/changes.js +1 -0
- package/target/main/ts/core/model/clone-source.js +1 -0
- package/target/main/ts/core/model/code-structure.js +1 -0
- package/target/main/ts/core/model/finding-ignore.js +1 -0
- package/target/main/ts/core/model/measurement.d.ts +6 -0
- package/target/main/ts/core/model/measurement.js +6 -0
- package/target/main/ts/core/model/report.d.ts +8 -0
- package/target/main/ts/core/model/scanner-import.js +1 -0
- package/target/main/ts/core/model/snapshot.js +1 -0
- package/target/main/ts/core/ports/report.js +1 -0
- package/target/main/ts/core/ports/source-provider.js +1 -0
- package/target/main/ts/core/profile/exclusions.js +1 -0
- package/target/main/ts/core/profile/maintainability.js +1 -0
- package/target/main/ts/core/profile/profile.js +1 -0
- package/target/main/ts/core/usecases/compare.js +1 -0
- package/target/main/ts/core/usecases/diff-coverage-policy.js +1 -0
- package/target/main/ts/core/usecases/diff-coverage.js +1 -0
- package/target/main/ts/core/usecases/inspect.js +1 -0
- package/target/main/ts/core/usecases/review.js +1 -0
- package/target/main/ts/index.js +1 -0
- package/target/main/ts/plugin.js +1 -0
- package/target/main/ts/plugins/coverage/coverage.d.ts +2 -0
- package/target/main/ts/plugins/coverage/coverage.js +83 -4
- package/target/main/ts/plugins/coverage/diff-coverage.js +1 -0
- package/target/main/ts/plugins/duplication/duplication.js +1 -0
- package/target/main/ts/plugins/language-js/babel-provider.js +1 -0
- package/target/main/ts/plugins/language-js/clone-candidates.js +1 -0
- package/target/main/ts/plugins/language-js/code-lines.js +1 -0
- package/target/main/ts/plugins/language-js/function-facts.js +1 -0
- package/target/main/ts/plugins/language-js/structural-observations.js +1 -0
- package/target/main/ts/plugins/maintainability/maintainability.js +1 -0
- package/target/main/ts/plugins/maintainability/structural-smells.js +1 -0
- package/target/main/ts/plugins/source/forges.js +1 -0
- package/target/main/ts/plugins/structure/structure.js +1 -0
- package/target/main/ts/report/html/app/viewer-chart.js +5 -5
- package/target/main/ts/report/html/app/viewer-commits.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-commits.js +1 -1
- package/target/main/ts/report/html/app/viewer-data.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-data.js +4 -4
- package/target/main/ts/report/html/app/viewer-files.js +25 -8
- package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +3 -1
- package/target/main/ts/report/html/app/viewer-metric-registry.js +24 -6
- package/target/main/ts/report/html/app/viewer-profile.js +3 -3
- package/target/main/ts/report/html/app/viewer-trends.d.ts +0 -1
- package/target/main/ts/report/html/app/viewer-trends.js +16 -6
- package/target/main/ts/report/html/app/viewer.js +48 -107
- package/target/main/ts/report/html/site/badges.js +1 -0
- package/target/main/ts/report/html/site/export-site.d.ts +2 -1
- package/target/main/ts/report/html/site/export-site.js +17 -24
- package/target/main/ts/report/html/site/exported-server.js +1 -0
- package/target/main/ts/report/html/site/local-server.js +1 -0
- package/target/main/ts/report/html/site/projects.js +1 -0
- package/target/main/ts/report/html/site/server.js +1 -0
- package/target/main/ts/report/html/site/source-route.js +1 -0
- package/target/main/ts/report/json/projections/commit-summary.d.ts +1 -0
- package/target/main/ts/report/json/projections/commit-summary.js +7 -1
- package/target/main/ts/report/json/projections/components.js +1 -0
- package/target/main/ts/report/json/projections/file-metrics.js +1 -0
- package/target/main/ts/report/json/projections/inspection-context.js +1 -0
- package/target/main/ts/report/json/projections/inspection-details.js +1 -0
- package/target/main/ts/report/json/projections/metric-values.js +1 -0
- package/target/main/ts/report/json/projections/public-history.js +1 -0
- package/target/main/ts/report/json/store/components.js +1 -0
- package/target/main/ts/report/json/store/local-store.js +1 -0
- package/target/main/ts/report/json/store/pull-review-store.js +1 -0
- package/target/main/ts/report/json/validation/metabranch.js +1 -0
- package/target/main/ts/report/json/validation/report.js +1 -0
- package/target/main/ts/report/json/validation/summary-validation.js +1 -0
- package/target/main/ts/report.js +1 -0
- package/target/main/ts/api/gh/github-pr-comment.d.ts +0 -4
- package/target/main/ts/api/gh/github-pr-comment.js +0 -107
- package/target/main/ts/cli/github-pr-comment.d.ts +0 -1
- package/target/main/ts/cli/github-pr-comment.js +0 -12
- package/target/main/ts/report/html/app/viewer-access.d.ts +0 -19
- package/target/main/ts/report/html/app/viewer-access.js +0 -25
|
@@ -6,6 +6,12 @@ export declare const definitions: {
|
|
|
6
6
|
readonly coverage: 'repometry.lcov-line-coverage/v1';
|
|
7
7
|
readonly coveredLines: 'repometry.lcov-covered-lines/v1';
|
|
8
8
|
readonly coverableLines: 'repometry.lcov-coverable-lines/v1';
|
|
9
|
+
readonly branchCoverage: 'repometry.lcov-branch-coverage/v1';
|
|
10
|
+
readonly coveredBranches: 'repometry.lcov-covered-branches/v1';
|
|
11
|
+
readonly coverableBranches: 'repometry.lcov-coverable-branches/v1';
|
|
12
|
+
readonly functionCoverage: 'repometry.lcov-function-coverage/v1';
|
|
13
|
+
readonly coveredFunctions: 'repometry.lcov-covered-functions/v1';
|
|
14
|
+
readonly coverableFunctions: 'repometry.lcov-coverable-functions/v1';
|
|
9
15
|
readonly codeLines: 'repometry.code-lines-babel/v1';
|
|
10
16
|
readonly comments: 'repometry.comment-lines-babel/v1';
|
|
11
17
|
readonly classes: 'repometry.classes-babel/v1';
|
|
@@ -6,6 +6,12 @@ export const definitions = {
|
|
|
6
6
|
coverage: 'repometry.lcov-line-coverage/v1',
|
|
7
7
|
coveredLines: 'repometry.lcov-covered-lines/v1',
|
|
8
8
|
coverableLines: 'repometry.lcov-coverable-lines/v1',
|
|
9
|
+
branchCoverage: 'repometry.lcov-branch-coverage/v1',
|
|
10
|
+
coveredBranches: 'repometry.lcov-covered-branches/v1',
|
|
11
|
+
coverableBranches: 'repometry.lcov-coverable-branches/v1',
|
|
12
|
+
functionCoverage: 'repometry.lcov-function-coverage/v1',
|
|
13
|
+
coveredFunctions: 'repometry.lcov-covered-functions/v1',
|
|
14
|
+
coverableFunctions: 'repometry.lcov-coverable-functions/v1',
|
|
9
15
|
codeLines: 'repometry.code-lines-babel/v1',
|
|
10
16
|
comments: 'repometry.comment-lines-babel/v1',
|
|
11
17
|
classes: 'repometry.classes-babel/v1',
|
|
@@ -16,6 +16,14 @@ export interface Report {
|
|
|
16
16
|
readonly subject: Subject;
|
|
17
17
|
readonly generatedAt: string;
|
|
18
18
|
readonly committedAt?: string;
|
|
19
|
+
/** The inspected commit's message title and author, recorded at analysis so the store alone can describe it. */
|
|
20
|
+
readonly commit?: {
|
|
21
|
+
readonly subject: string;
|
|
22
|
+
readonly author: {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly email: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
19
27
|
readonly appliedConfig: Readonly<Record<string, unknown>>;
|
|
20
28
|
readonly definitions: Readonly<Record<string, string>>;
|
|
21
29
|
readonly scope: {
|
|
@@ -126,3 +126,4 @@ function findingMethod(report, qualityOnly) {
|
|
|
126
126
|
const imported = findingImportMethods(findingImports).filter(({ category }) => !qualityOnly || !isSensitiveFinding(category));
|
|
127
127
|
return { ...settings, imported, plugins: exclude(plugins, 'id', 'lcov'), operations: exclude(operations, 'key', 'lcov/import') };
|
|
128
128
|
}
|
|
129
|
+
//# sourceMappingURL=review.js.map
|
package/target/main/ts/index.js
CHANGED
|
@@ -15,3 +15,4 @@ export { readReport, reportSchema } from './report/json/validation/report.js';
|
|
|
15
15
|
export { coverageGrade, qualitySummary } from './core/model/quality-summary.js';
|
|
16
16
|
export { pullReviewSchema } from './core/model/pull-review.js';
|
|
17
17
|
export { pullReviewsSchema } from './report/json/wire/pull-review-model.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/target/main/ts/plugin.js
CHANGED
|
@@ -3,3 +3,4 @@ export { codeStructure } from './core/model/code-structure.js';
|
|
|
3
3
|
export { sourceFile } from './core/model/snapshot.js';
|
|
4
4
|
export { measurements } from './core/model/measurement.js';
|
|
5
5
|
export { findingResult } from './core/model/finding.js';
|
|
6
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -18,6 +18,8 @@ export declare const coverageResult: DataContract<CoverageResult>;
|
|
|
18
18
|
export declare const coverage: Plugin;
|
|
19
19
|
export declare function mapCoverage({ text, root, sourceLines, excludes }: CoverageInput): {
|
|
20
20
|
files: Map<string, Map<number, boolean>>;
|
|
21
|
+
branches: Map<string, Map<string, boolean>>;
|
|
22
|
+
functions: Map<string, Map<string, boolean>>;
|
|
21
23
|
gaps: Map<string, string>;
|
|
22
24
|
};
|
|
23
25
|
export {};
|
|
@@ -15,7 +15,7 @@ export const coverageResult = {
|
|
|
15
15
|
};
|
|
16
16
|
export const coverage = {
|
|
17
17
|
id: 'lcov',
|
|
18
|
-
version: '1.
|
|
18
|
+
version: '1.2.0',
|
|
19
19
|
api: pluginApi,
|
|
20
20
|
kinds: ['coverage', 'import'],
|
|
21
21
|
produces: [{ contract: coverageResult.id, persistence: 'report', metrics: [
|
|
@@ -23,6 +23,14 @@ export const coverage = {
|
|
|
23
23
|
ratio: { of: definitions.coveredLines, over: definitions.coverableLines }, bands: [0.6, 0.7, 0.8, 0.9], group: 'Coverage' },
|
|
24
24
|
{ id: definitions.coveredLines, label: 'Covered lines', unit: 'count', scope: 'file', aggregate: 'sum', better: 'higher', group: 'Coverage' },
|
|
25
25
|
{ id: definitions.coverableLines, label: 'Measured lines', unit: 'count', scope: 'file', aggregate: 'sum', better: 'none', group: 'Coverage' },
|
|
26
|
+
{ id: definitions.branchCoverage, label: 'Branch coverage', unit: 'ratio', scope: 'file', aggregate: 'sum', better: 'higher',
|
|
27
|
+
ratio: { of: definitions.coveredBranches, over: definitions.coverableBranches }, bands: [0.6, 0.7, 0.8, 0.9], group: 'Coverage' },
|
|
28
|
+
{ id: definitions.coveredBranches, label: 'Covered branches', unit: 'count', scope: 'file', aggregate: 'sum', better: 'higher', group: 'Coverage' },
|
|
29
|
+
{ id: definitions.coverableBranches, label: 'Measured branches', unit: 'count', scope: 'file', aggregate: 'sum', better: 'none', group: 'Coverage' },
|
|
30
|
+
{ id: definitions.functionCoverage, label: 'Function coverage', unit: 'ratio', scope: 'file', aggregate: 'sum', better: 'higher',
|
|
31
|
+
ratio: { of: definitions.coveredFunctions, over: definitions.coverableFunctions }, bands: [0.6, 0.7, 0.8, 0.9], group: 'Coverage' },
|
|
32
|
+
{ id: definitions.coveredFunctions, label: 'Covered functions', unit: 'count', scope: 'file', aggregate: 'sum', better: 'higher', group: 'Coverage' },
|
|
33
|
+
{ id: definitions.coverableFunctions, label: 'Measured functions', unit: 'count', scope: 'file', aggregate: 'sum', better: 'none', group: 'Coverage' },
|
|
26
34
|
] }],
|
|
27
35
|
operations: [{
|
|
28
36
|
id: 'import',
|
|
@@ -34,6 +42,17 @@ export const coverage = {
|
|
|
34
42
|
};
|
|
35
43
|
export function mapCoverage({ text, root, sourceLines, excludes }) {
|
|
36
44
|
const files = new Map();
|
|
45
|
+
// Branches by line, block and branch. Functions by name and its occurrence in the record: tools such as c8 repeat a
|
|
46
|
+
// name for different functions and list FNDA in FN order. Several reports merge by any hit.
|
|
47
|
+
const branches = new Map();
|
|
48
|
+
const declared = new Map();
|
|
49
|
+
const called = new Map();
|
|
50
|
+
const occurrences = { declared: new Map(), called: new Map() };
|
|
51
|
+
const occurrence = (seen, name) => {
|
|
52
|
+
const count = (seen.get(name) ?? 0) + 1;
|
|
53
|
+
seen.set(name, count);
|
|
54
|
+
return `${name}#${count}`;
|
|
55
|
+
};
|
|
37
56
|
const gaps = new Map();
|
|
38
57
|
let active;
|
|
39
58
|
let ignored = false;
|
|
@@ -44,6 +63,8 @@ export function mapCoverage({ text, root, sourceLines, excludes }) {
|
|
|
44
63
|
if (active !== undefined || line.length === 3)
|
|
45
64
|
throw new Error(`Unexpected LCOV source at line ${index + 1}`);
|
|
46
65
|
active = normalizeLcovPath(root, line.slice(3));
|
|
66
|
+
occurrences.declared.clear();
|
|
67
|
+
occurrences.called.clear();
|
|
47
68
|
sawSource = true;
|
|
48
69
|
ignored = excludes?.(active) ?? false;
|
|
49
70
|
if (ignored)
|
|
@@ -70,6 +91,34 @@ export function mapCoverage({ text, root, sourceLines, excludes }) {
|
|
|
70
91
|
else if (file)
|
|
71
92
|
file.set(number, (file.get(number) ?? false) || hits > 0);
|
|
72
93
|
}
|
|
94
|
+
else if (line.startsWith('BRDA:') || line.startsWith('FN:') || line.startsWith('FNDA:')) {
|
|
95
|
+
if (active === undefined)
|
|
96
|
+
throw new Error(`LCOV data outside a source record at line ${index + 1}`);
|
|
97
|
+
if (ignored || !files.has(active))
|
|
98
|
+
continue;
|
|
99
|
+
const branch = /^BRDA:([1-9]\d*),([^,]+),([^,]+),(\d+|-)$/.exec(line);
|
|
100
|
+
const declaration = /^FN:[1-9]\d*(?:,[1-9]\d*)?,(.+)$/.exec(line);
|
|
101
|
+
const call = /^FNDA:(\d+),(.+)$/.exec(line);
|
|
102
|
+
if (branch) {
|
|
103
|
+
const taken = branch[4] !== '-' && Number(branch[4]) > 0;
|
|
104
|
+
const key = `${branch[1]},${branch[2]},${branch[3]}`;
|
|
105
|
+
const file = branches.get(active) ?? new Map();
|
|
106
|
+
file.set(key, (file.get(key) ?? false) || taken);
|
|
107
|
+
branches.set(active, file);
|
|
108
|
+
}
|
|
109
|
+
else if (declaration) {
|
|
110
|
+
declared.set(active, (declared.get(active) ?? new Set()).add(occurrence(occurrences.declared, declaration[1])));
|
|
111
|
+
}
|
|
112
|
+
else if (call) {
|
|
113
|
+
const key = occurrence(occurrences.called, call[2]);
|
|
114
|
+
const file = called.get(active) ?? new Map();
|
|
115
|
+
file.set(key, (file.get(key) ?? false) || Number(call[1]) > 0);
|
|
116
|
+
called.set(active, file);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new Error(`Invalid LCOV data at line ${index + 1}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
73
122
|
else if (line === 'end_of_record') {
|
|
74
123
|
if (active === undefined)
|
|
75
124
|
throw new Error(`Unexpected LCOV record end at line ${index + 1}`);
|
|
@@ -80,10 +129,11 @@ export function mapCoverage({ text, root, sourceLines, excludes }) {
|
|
|
80
129
|
throw new Error('Unterminated LCOV source record');
|
|
81
130
|
if (!sawSource && text.trim() !== '')
|
|
82
131
|
throw new Error('LCOV contains no source records');
|
|
83
|
-
|
|
132
|
+
const functions = new Map([...declared].map(([path, names]) => [path, new Map([...names].map(name => [name, called.get(path)?.get(name) ?? false]))]));
|
|
133
|
+
return { files, branches, functions, gaps };
|
|
84
134
|
}
|
|
85
135
|
function importCoverage(input) {
|
|
86
|
-
const { files, gaps } = mapCoverage(input);
|
|
136
|
+
const { files, branches, functions, gaps } = mapCoverage(input);
|
|
87
137
|
const rows = [];
|
|
88
138
|
let totalCovered = 0;
|
|
89
139
|
let totalLines = 0;
|
|
@@ -103,9 +153,37 @@ function importCoverage(input) {
|
|
|
103
153
|
{ definition: definitions.coveredLines, target, path, value: covered ?? null },
|
|
104
154
|
{ definition: definitions.coverableLines, target, path, value: total ?? null },
|
|
105
155
|
]);
|
|
106
|
-
|
|
156
|
+
const extra = [
|
|
157
|
+
...hitRows(branches, gaps, definitions.branchCoverage, definitions.coveredBranches, definitions.coverableBranches),
|
|
158
|
+
...hitRows(functions, gaps, definitions.functionCoverage, definitions.coveredFunctions, definitions.coverableFunctions),
|
|
159
|
+
];
|
|
160
|
+
return { measurements: [...rows, ...counts, ...extra],
|
|
107
161
|
gaps: [...gaps].sort(([left], [right]) => comparePaths(left, right)).map(([path, reason]) => ({ path, reason })) };
|
|
108
162
|
}
|
|
163
|
+
/** Per-file and repository ratios with their counts, for a kind the LCOV reports; nothing when it reports none. */
|
|
164
|
+
function hitRows(files, gaps, ratioId, coveredId, totalId) {
|
|
165
|
+
const rows = [];
|
|
166
|
+
let totalCovered = 0;
|
|
167
|
+
let totalCount = 0;
|
|
168
|
+
for (const [path, hits] of [...files].sort(([left], [right]) => comparePaths(left, right))) {
|
|
169
|
+
if (gaps.has(path) || hits.size === 0)
|
|
170
|
+
continue;
|
|
171
|
+
let covered = 0;
|
|
172
|
+
for (const hit of hits.values())
|
|
173
|
+
if (hit)
|
|
174
|
+
covered++;
|
|
175
|
+
totalCovered += covered;
|
|
176
|
+
totalCount += hits.size;
|
|
177
|
+
rows.push({ definition: ratioId, target: 'file', path, covered, total: hits.size, value: ratio(covered, hits.size) });
|
|
178
|
+
}
|
|
179
|
+
if (totalCount === 0)
|
|
180
|
+
return [];
|
|
181
|
+
rows.push({ definition: ratioId, target: 'repository', covered: totalCovered, total: totalCount, value: ratio(totalCovered, totalCount) });
|
|
182
|
+
return [...rows, ...rows.flatMap(({ target, path, covered, total }) => [
|
|
183
|
+
{ definition: coveredId, target, path, value: covered ?? null },
|
|
184
|
+
{ definition: totalId, target, path, value: total ?? null },
|
|
185
|
+
])];
|
|
186
|
+
}
|
|
109
187
|
function ratio(covered, total) {
|
|
110
188
|
return total === 0 ? null : covered / total;
|
|
111
189
|
}
|
|
@@ -118,3 +196,4 @@ function normalizeLcovPath(root, path) {
|
|
|
118
196
|
return posix.normalize(candidate.replaceAll('\\', '/'));
|
|
119
197
|
return posix.normalize(candidate);
|
|
120
198
|
}
|
|
199
|
+
//# sourceMappingURL=coverage.js.map
|
|
@@ -280,7 +280,7 @@ function lineChart(svg, layout, points, { format, ratio, compact, tickUnit = 1,
|
|
|
280
280
|
markBoundaries(svg, layout, points);
|
|
281
281
|
if (secondary && secondHigh > 0) {
|
|
282
282
|
const y2 = (value) => layout.top + layout.plotHeight - value / secondHigh * layout.plotHeight;
|
|
283
|
-
for (const segment of segments(secondary.values
|
|
283
|
+
for (const segment of segments(secondary.values)) {
|
|
284
284
|
const path = svgElement('path', 'tc-line tc-line-secondary');
|
|
285
285
|
path.setAttribute('d', segment.map((index, order) => {
|
|
286
286
|
const value = secondary.values[index];
|
|
@@ -292,7 +292,7 @@ function lineChart(svg, layout, points, { format, ratio, compact, tickUnit = 1,
|
|
|
292
292
|
svg.append(path);
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
for (const segment of segments(points.map(point => point.value)
|
|
295
|
+
for (const segment of segments(points.map(point => point.value))) {
|
|
296
296
|
const path = svgElement('path', 'tc-line');
|
|
297
297
|
// Code keeps its state until the next commit, so the line holds each value and steps at the commit that changed it;
|
|
298
298
|
// a slope would invent values for the days between commits.
|
|
@@ -622,12 +622,12 @@ function interact(svg, tip, layout, points) {
|
|
|
622
622
|
}
|
|
623
623
|
});
|
|
624
624
|
}
|
|
625
|
-
/** Runs of consecutive measured points, broken where a measurement is missing. */
|
|
626
|
-
function segments(values
|
|
625
|
+
/** Runs of consecutive measured points, broken only where a measurement is missing; a profile change is marked, not cut. */
|
|
626
|
+
function segments(values) {
|
|
627
627
|
const result = [];
|
|
628
628
|
let run = [];
|
|
629
629
|
for (const [index, value] of values.entries()) {
|
|
630
|
-
if (value === null
|
|
630
|
+
if (value === null) {
|
|
631
631
|
if (run.length)
|
|
632
632
|
result.push(run);
|
|
633
633
|
run = [];
|
|
@@ -30,7 +30,7 @@ export interface CommitPicker {
|
|
|
30
30
|
export declare function createCommitPicker(slot: HTMLElement, entries: readonly PublicHistoryEntry[], pick: (sha: string) => void, branch?: string): CommitPicker;
|
|
31
31
|
/**
|
|
32
32
|
* How a commit's author reads in the list: the name, with the email only when the search found the email and not the
|
|
33
|
-
* name. A
|
|
33
|
+
* name. A history without emails carries the name alone, and then it is the name alone; nothing reads as missing.
|
|
34
34
|
*/
|
|
35
35
|
export declare function authorLabel(author: PublicHistoryEntry['author'], words: readonly string[]): string | null;
|
|
36
36
|
export {};
|
|
@@ -226,7 +226,7 @@ export function createCommitPicker(slot, entries, pick, branch) {
|
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
228
228
|
* How a commit's author reads in the list: the name, with the email only when the search found the email and not the
|
|
229
|
-
* name. A
|
|
229
|
+
* name. A history without emails carries the name alone, and then it is the name alone; nothing reads as missing.
|
|
230
230
|
*/
|
|
231
231
|
export function authorLabel(author, words) {
|
|
232
232
|
if (!author?.name)
|
|
@@ -13,7 +13,7 @@ export interface ViewerData {
|
|
|
13
13
|
readonly branch?: string;
|
|
14
14
|
/** The metrics the history's plugins declare; each commit's values are indexed by it. */
|
|
15
15
|
readonly metrics?: readonly MetricDescriptor[];
|
|
16
|
-
/** Where file sources come from,
|
|
16
|
+
/** Where file sources come from, when the export names a place. */
|
|
17
17
|
readonly sources?: SourceLocator;
|
|
18
18
|
loadDetails(sha: string): Promise<InspectionAsset | null>;
|
|
19
19
|
}
|
|
@@ -21,17 +21,17 @@ export async function loadViewerData(mode) {
|
|
|
21
21
|
context: Object.fromEntries(summary.commits.map(commit => [commit.sha, {
|
|
22
22
|
exclusions: null, boundary: commit.profileBoundary ?? null, security: commit.counts?.security,
|
|
23
23
|
}])),
|
|
24
|
-
counts
|
|
24
|
+
counts,
|
|
25
25
|
pullReviewCount: summary.pullReviewCount,
|
|
26
26
|
...(Array.isArray(summary.metrics) ? { metrics: summary.metrics } : {}),
|
|
27
27
|
...(() => {
|
|
28
|
-
const sources =
|
|
28
|
+
const sources = sourceLocator(summary.sources);
|
|
29
29
|
return sources ? { sources } : {};
|
|
30
30
|
})(),
|
|
31
31
|
...(typeof summary.source?.branch === 'string' && summary.source.branch.trim() ? { branch: summary.source.branch.trim() } : {}),
|
|
32
32
|
async loadDetails(sha) {
|
|
33
33
|
const path = details.get(sha);
|
|
34
|
-
if (path === undefined
|
|
34
|
+
if (path === undefined)
|
|
35
35
|
return null;
|
|
36
36
|
const asset = await readInspection(path, sha, mode);
|
|
37
37
|
if (asset)
|
|
@@ -74,7 +74,7 @@ async function legacyViewerData(mode) {
|
|
|
74
74
|
const [history, quality, saved, localContext] = await Promise.all([
|
|
75
75
|
readOptional('./history.json'),
|
|
76
76
|
readOptional('./quality-history.json'),
|
|
77
|
-
mode === '
|
|
77
|
+
mode === 'local' ? null : readOptional('./details.json'),
|
|
78
78
|
mode === 'local' ? readOptional('./inspection-context.json') : null,
|
|
79
79
|
]);
|
|
80
80
|
if (history?.schema !== historySchema || !Array.isArray(history.reports))
|
|
@@ -36,9 +36,14 @@ function useDetails(details) {
|
|
|
36
36
|
function measured(descriptor) {
|
|
37
37
|
return local.index.has(descriptor.ratio?.over ?? descriptor.id);
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
40
|
-
function
|
|
41
|
-
return pluginMetrics().filter(spec => spec.
|
|
39
|
+
/** Coverage kinds beside line coverage (branches, functions), where the coverage report has them. */
|
|
40
|
+
function coverageKinds() {
|
|
41
|
+
return pluginMetrics().filter(spec => spec.plugin === 'repometry' && spec.group === 'Coverage' && spec.descriptor.unit === 'ratio'
|
|
42
|
+
&& spec.descriptor.scope === 'file');
|
|
43
|
+
}
|
|
44
|
+
/** Registry metrics as Metrics columns, in the order the history lists them. */
|
|
45
|
+
function pluginColumns(specs) {
|
|
46
|
+
return specs.map(spec => ({
|
|
42
47
|
label: spec.short,
|
|
43
48
|
value: entry => entryValue(local.index, entry, spec),
|
|
44
49
|
display: entry => format(spec, entryValue(local.index, entry, spec)),
|
|
@@ -87,7 +92,7 @@ const builtinColumns = [
|
|
|
87
92
|
{ label: labelOf('complexity'), value: entry => entry.complexity?.maximum ?? null, display: entry => count(entry.complexity?.maximum) },
|
|
88
93
|
{ label: labelOf('cognitive'), value: entry => entry.quality?.cognitiveComplexity ?? null, display: entry => count(entry.quality?.cognitiveComplexity),
|
|
89
94
|
available: directory => directory?.quality?.cognitiveComplexity !== undefined },
|
|
90
|
-
{ label: '
|
|
95
|
+
{ label: labelOf('coverage'), value: coverageRatio, display: coverageText, available: directory => directory ? coverageRatio(directory) !== null : true },
|
|
91
96
|
{ label: 'Duplication', value: duplicationRatio, display: duplicationText,
|
|
92
97
|
available: directory => directory?.quality?.duplication !== undefined },
|
|
93
98
|
{ label: labelOf('effort'), value: entry => entry.quality?.maintainability?.effortMinutes ?? null,
|
|
@@ -104,7 +109,13 @@ function isGroup(value) {
|
|
|
104
109
|
function metricsView(details, navigation, settings, directory, selectedFile) {
|
|
105
110
|
const view = element('div', 'fx-view');
|
|
106
111
|
const { metrics } = details;
|
|
107
|
-
|
|
112
|
+
// The other coverage kinds sit beside line coverage; every other registry metric follows Repometry's own columns,
|
|
113
|
+
// except the counts a ratio is made of, which read through the ratio as line coverage's do.
|
|
114
|
+
const kinds = coverageKinds();
|
|
115
|
+
const afterCoverage = builtinColumns.findIndex(column => column.label === labelOf('coverage')) + 1;
|
|
116
|
+
const columns = [...builtinColumns.slice(0, afterCoverage),
|
|
117
|
+
...pluginColumns(kinds), ...builtinColumns.slice(afterCoverage),
|
|
118
|
+
...pluginColumns(pluginMetrics().filter(spec => spec.descriptor.scope === 'file' && !spec.ratioPart && !kinds.includes(spec)))];
|
|
108
119
|
const scopeFiles = metrics.files.filter(entry => inside(entry.path, directory));
|
|
109
120
|
const scopeTotals = aggregate(directory, scopeFiles);
|
|
110
121
|
const scopeIgnored = scopeFiles.some(entry => entry.analysed === false);
|
|
@@ -555,9 +566,10 @@ function directorySummary(entry, analysed, lockfiles, selection) {
|
|
|
555
566
|
quality?.duplication === undefined ? null : fact(labelOf('duplication'), duplicationText(entry)),
|
|
556
567
|
quality?.maintainability === undefined ? null : fact(labelOf('effort'), duration(quality.maintainability.effortMinutes)),
|
|
557
568
|
coverageRatio(entry) === null ? null : fact(labelOf('coverage'), coverageText(entry)),
|
|
558
|
-
// Other plugins' totals follow Repometry's own, where this inspection ran them and they roll up
|
|
559
|
-
|
|
560
|
-
|
|
569
|
+
// Other plugins' totals follow Repometry's own, where this inspection ran them and they roll up; the counts behind
|
|
570
|
+
// a ratio read through it.
|
|
571
|
+
...pluginMetrics().filter(spec => spec.descriptor.scope === 'file' && spec.descriptor.aggregate !== 'none' && !spec.ratioPart
|
|
572
|
+
&& measured(spec.descriptor)).map(spec => fact(spec.short, format(spec, entryValue(local.index, entry, spec)))),
|
|
561
573
|
].filter(item => item !== null));
|
|
562
574
|
panel.append(heading, facts);
|
|
563
575
|
return panel;
|
|
@@ -589,6 +601,11 @@ function fileDetails(details, entry, navigation, hooks = {}) {
|
|
|
589
601
|
if (quality?.cognitiveComplexity !== undefined)
|
|
590
602
|
facts.append(fact(labelOf('cognitive'), count(quality.cognitiveComplexity)));
|
|
591
603
|
facts.append(fact(labelOf('coverage'), coverageText(entry), coverageContext(entry)));
|
|
604
|
+
for (const spec of coverageKinds()) {
|
|
605
|
+
const value = measured(spec.descriptor) ? entryValue(local.index, entry, spec) : null;
|
|
606
|
+
if (value !== null)
|
|
607
|
+
facts.append(fact(spec.short, format(spec, value)));
|
|
608
|
+
}
|
|
592
609
|
if (quality?.duplication)
|
|
593
610
|
facts.append(fact(labelOf('duplication'), duplicationText(entry), duplicationContext(entry)));
|
|
594
611
|
if (quality?.maintainability)
|
|
@@ -16,6 +16,8 @@ export interface MetricSpec {
|
|
|
16
16
|
readonly hotspot: boolean;
|
|
17
17
|
/** Has one value per commit, so a trend chart. */
|
|
18
18
|
readonly trend: boolean;
|
|
19
|
+
/** A count another metric's ratio is made of, as covered branches are of branch coverage. */
|
|
20
|
+
readonly ratioPart: boolean;
|
|
19
21
|
}
|
|
20
22
|
/** A row that may carry values: a commit, a file or a folder. */
|
|
21
23
|
export interface Valued {
|
|
@@ -24,7 +26,7 @@ export interface Valued {
|
|
|
24
26
|
}
|
|
25
27
|
/** Curated groups first, in this order; groups named by plugins follow in catalog order. */
|
|
26
28
|
export declare const curatedGroups: readonly ['Maintainability', 'Coverage', 'Security', 'Size'];
|
|
27
|
-
/**
|
|
29
|
+
/** The metrics the viewer draws from their typed fields; a Repometry metric it has no code for goes by its descriptor. */
|
|
28
30
|
export declare function isBuiltin(descriptor: MetricDescriptor): boolean;
|
|
29
31
|
/** One spec per descriptor, in catalog order; descriptors listed twice by id count once. */
|
|
30
32
|
export declare function metricSpecs(catalog: readonly MetricDescriptor[]): MetricSpec[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Repometry's metrics keep short query words; every other key comes from the descriptor's id. */
|
|
2
2
|
const builtinKeys = {
|
|
3
3
|
'repometry.cyclomatic-babel/v1': 'complexity',
|
|
4
4
|
'repometry.cognitive-babel/v1': 'cognitive',
|
|
@@ -7,7 +7,20 @@ const builtinKeys = {
|
|
|
7
7
|
'repometry.lcov-line-coverage/v1': 'coverage',
|
|
8
8
|
'repometry.duplicated-lines-babel/v1': 'duplication',
|
|
9
9
|
'repometry.git-change-frequency/v1': 'changes',
|
|
10
|
+
'repometry.lcov-branch-coverage/v1': 'branch-coverage',
|
|
11
|
+
'repometry.lcov-covered-branches/v1': 'covered-branches',
|
|
12
|
+
'repometry.lcov-coverable-branches/v1': 'coverable-branches',
|
|
13
|
+
'repometry.lcov-function-coverage/v1': 'function-coverage',
|
|
14
|
+
'repometry.lcov-covered-functions/v1': 'covered-functions',
|
|
15
|
+
'repometry.lcov-coverable-functions/v1': 'coverable-functions',
|
|
10
16
|
};
|
|
17
|
+
/** The Repometry metrics the viewer draws from typed fields, with their own labels, columns and charts. */
|
|
18
|
+
const handDrawn = new Set([
|
|
19
|
+
'repometry.physical-lines/v1', 'repometry.functions/v1', 'repometry.cyclomatic-babel/v1', 'repometry.cognitive-babel/v1',
|
|
20
|
+
'repometry.classes-babel/v1', 'repometry.code-lines-babel/v1', 'repometry.comment-lines-babel/v1',
|
|
21
|
+
'repometry.duplicated-lines-babel/v1', 'repometry.lcov-line-coverage/v1', 'repometry.lcov-covered-lines/v1',
|
|
22
|
+
'repometry.lcov-coverable-lines/v1', 'repometry.git-change-frequency/v1',
|
|
23
|
+
]);
|
|
11
24
|
/** Words that already mean something: query keys, Trends views and the series the viewer draws by hand. */
|
|
12
25
|
const reserved = new Set(['lang', 'language', 'component', 'path', 'in', 'has', 'analysed', 'ignored', 'lockfile', 'lockfiles', 'remediation', 'missedlines', 'churn',
|
|
13
26
|
'debt', 'debt-changes', 'diff-coverage', 'effort', 'smells', 'files', 'classes', 'comments', 'code-lines', 'security',
|
|
@@ -15,9 +28,9 @@ const reserved = new Set(['lang', 'language', 'component', 'path', 'in', 'has',
|
|
|
15
28
|
...Object.values(builtinKeys)]);
|
|
16
29
|
/** Curated groups first, in this order; groups named by plugins follow in catalog order. */
|
|
17
30
|
export const curatedGroups = ['Maintainability', 'Coverage', 'Security', 'Size'];
|
|
18
|
-
/**
|
|
31
|
+
/** The metrics the viewer draws from their typed fields; a Repometry metric it has no code for goes by its descriptor. */
|
|
19
32
|
export function isBuiltin(descriptor) {
|
|
20
|
-
return descriptor.id
|
|
33
|
+
return handDrawn.has(descriptor.id);
|
|
21
34
|
}
|
|
22
35
|
function parts(id) {
|
|
23
36
|
const bare = id.replace(/\/v\d+$/, '');
|
|
@@ -33,19 +46,24 @@ export function metricSpecs(catalog) {
|
|
|
33
46
|
const { plugin, name } = parts(id);
|
|
34
47
|
owners.set(name, (owners.get(name) ?? new Set()).add(plugin));
|
|
35
48
|
}
|
|
49
|
+
// The counts a ratio is made of (covered and measured branches) read through the ratio: no chart, column or rank of their own.
|
|
50
|
+
const ratioParts = new Set(unique.flatMap(({ ratio }) => ratio ? [ratio.of, ratio.over] : []));
|
|
36
51
|
return unique.map(descriptor => {
|
|
37
52
|
const { plugin, name } = parts(descriptor.id);
|
|
38
53
|
const builtin = builtinKeys[descriptor.id];
|
|
39
54
|
const key = builtin ?? (owners.get(name).size > 1 || reserved.has(name.toLowerCase()) ? `${plugin}.${name}` : name);
|
|
40
55
|
const rolls = descriptor.aggregate !== 'none' || descriptor.ratio !== undefined;
|
|
56
|
+
const ranked = descriptor.scope === 'file' && descriptor.better !== 'none' && !ratioParts.has(descriptor.id);
|
|
41
57
|
return {
|
|
42
58
|
descriptor, key, plugin,
|
|
43
59
|
label: descriptor.label,
|
|
44
60
|
short: descriptor.short ?? descriptor.label,
|
|
45
61
|
group: descriptor.group ?? plugin,
|
|
46
|
-
column
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
// Repometry's own columns are curated; its metrics without a hand-made column are there to pick, not shown first.
|
|
63
|
+
column: ranked && plugin !== 'repometry',
|
|
64
|
+
hotspot: ranked && rolls,
|
|
65
|
+
trend: !ratioParts.has(descriptor.id) && (descriptor.scope === 'repository' || rolls),
|
|
66
|
+
ratioPart: ratioParts.has(descriptor.id),
|
|
49
67
|
};
|
|
50
68
|
});
|
|
51
69
|
}
|
|
@@ -220,7 +220,7 @@ function pagedTable(spec) {
|
|
|
220
220
|
render();
|
|
221
221
|
return box;
|
|
222
222
|
}
|
|
223
|
-
/**
|
|
223
|
+
/** Until the details arrive only the exclusions are known; the summary does not carry the profile itself. */
|
|
224
224
|
function fallback(data) {
|
|
225
225
|
const section = block('Files');
|
|
226
226
|
const exclusions = data.context?.exclusions;
|
|
@@ -230,8 +230,8 @@ function fallback(data) {
|
|
|
230
230
|
facts.append(row('Excluded directories', exclusions.directories.length ? chips(exclusions.directories.map(directory => `**/${directory}/`)) : none()));
|
|
231
231
|
section.append(facts);
|
|
232
232
|
}
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
if (data.details)
|
|
234
|
+
section.append(element('p', 'detail', 'This inspection did not record its profile.'));
|
|
235
235
|
return section;
|
|
236
236
|
}
|
|
237
237
|
const formatKey = 'repometry.badge-format';
|