repometry 0.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -14
- package/package.json +1 -1
- package/target/main/resources/report/json/comparison-v1.schema.json +6 -6
- package/target/main/resources/report/json/file-metrics-v1.schema.json +7 -6
- package/target/main/resources/report/json/pull-review-v1.schema.json +5 -5
- package/target/main/resources/report/json/report-v2.schema.json +210 -11
- package/target/main/resources/report/json/repository-summary-v1.schema.json +161 -14
- package/target/main/resources/report/json/viewer-inspection-v1.schema.json +518 -6
- package/target/main/resources/viewer/styles.css +7 -2
- package/target/main/ts/api/git/changes.d.ts +1 -1
- package/target/main/ts/api/git/changes.js +3 -3
- package/target/main/ts/api/git/commit-metadata.js +6 -4
- package/target/main/ts/api/git/git.d.ts +2 -1
- package/target/main/ts/api/git/git.js +16 -4
- package/target/main/ts/api/git/inspection-source.d.ts +1 -1
- package/target/main/ts/api/git/inspection-source.js +4 -10
- package/target/main/ts/api/git/local.d.ts +1 -1
- package/target/main/ts/api/git/local.js +41 -7
- package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
- package/target/main/ts/api/process/docker-tool-runner.js +108 -0
- package/target/main/ts/api/process/failure.d.ts +1 -0
- package/target/main/ts/api/process/failure.js +12 -0
- package/target/main/ts/api/process/plugin.d.ts +10 -0
- package/target/main/ts/api/process/plugin.js +96 -0
- package/target/main/ts/api/worker/remote-executor.d.ts +1 -1
- package/target/main/ts/api/worker/remote-executor.js +2 -2
- package/target/main/ts/api/worker/worker-protocol.d.ts +2 -2
- package/target/main/ts/api/worker/worker-protocol.js +8 -8
- package/target/main/ts/api/worker/worker.d.ts +1 -1
- package/target/main/ts/api/worker/worker.js +4 -4
- package/target/main/ts/cli/main.js +4 -3
- package/target/main/ts/cli/reporting.d.ts +1 -1
- package/target/main/ts/cli/reporting.js +1 -1
- package/target/main/ts/compose/analysis-files.d.ts +13 -0
- package/target/main/ts/compose/analysis-files.js +95 -0
- package/target/main/ts/compose/analysis-imports.d.ts +7 -0
- package/target/main/ts/compose/analysis-imports.js +34 -0
- package/target/main/ts/compose/analysis-report.d.ts +5 -0
- package/target/main/ts/compose/analysis-report.js +78 -0
- package/target/main/ts/compose/analysis-repository.d.ts +6 -0
- package/target/main/ts/compose/analysis-repository.js +61 -0
- package/target/main/ts/compose/analysis-results.d.ts +38 -0
- package/target/main/ts/compose/analysis-results.js +78 -0
- package/target/main/ts/compose/analysis-sources.d.ts +73 -0
- package/target/main/ts/compose/analysis-sources.js +47 -0
- package/target/main/ts/compose/analyze-snapshot.d.ts +3 -2
- package/target/main/ts/compose/analyze-snapshot.js +19 -197
- package/target/main/ts/compose/diff-coverage.d.ts +2 -0
- package/target/main/ts/compose/diff-coverage.js +6 -4
- package/target/main/ts/compose/inspect.d.ts +5 -0
- package/target/main/ts/compose/inspect.js +14 -7
- package/target/main/ts/compose/languages.d.ts +29 -0
- package/target/main/ts/compose/languages.js +87 -0
- package/target/main/ts/compose/sources.js +14 -12
- package/target/main/ts/core/engine/execute.d.ts +3 -1
- package/target/main/ts/core/engine/execute.js +14 -2
- package/target/main/ts/core/engine/manifest.d.ts +2 -2
- package/target/main/ts/core/engine/manifest.js +25 -5
- package/target/main/ts/core/engine/operation-cache.d.ts +14 -0
- package/target/main/ts/core/engine/operation-cache.js +66 -0
- package/target/main/ts/core/engine/plan.d.ts +3 -4
- package/target/main/ts/core/engine/plan.js +28 -11
- package/target/main/ts/core/engine/plugin.d.ts +10 -2
- package/target/main/ts/core/engine/plugin.js +1 -3
- package/target/main/ts/core/engine/report-products.js +2 -13
- package/target/main/ts/core/model/clone-source.d.ts +1 -0
- package/target/main/ts/core/model/clone-source.js +2 -1
- package/target/main/ts/core/model/code-structure.d.ts +5 -0
- package/target/main/ts/core/model/code-structure.js +10 -1
- package/target/main/ts/core/model/finding-ignore.js +1 -1
- package/target/main/ts/core/model/finding.js +1 -1
- package/target/main/ts/core/model/language.d.ts +10 -0
- package/target/main/ts/core/model/language.js +6 -0
- package/target/main/ts/core/model/line-coverage.d.ts +5 -1
- package/target/main/ts/core/model/line-coverage.js +14 -11
- package/target/main/ts/core/model/measurement.d.ts +7 -6
- package/target/main/ts/core/model/measurement.js +18 -7
- package/target/main/ts/core/model/plugin-data.d.ts +5 -0
- package/target/main/ts/core/model/plugin-data.js +15 -1
- package/target/main/ts/core/model/quality-summary.js +6 -5
- package/target/main/ts/core/model/report.d.ts +1 -2
- package/target/main/ts/core/model/report.js +0 -1
- package/target/main/ts/core/model/scanner-import.js +1 -1
- package/target/main/ts/core/model/snapshot.d.ts +1 -2
- package/target/main/ts/core/model/snapshot.js +5 -7
- package/target/main/ts/core/model/source.d.ts +3 -0
- package/target/main/ts/core/model/source.js +15 -0
- package/target/main/ts/core/ports/tool-runner.d.ts +18 -0
- package/target/main/ts/core/ports/tool-runner.js +2 -0
- package/target/main/ts/core/usecases/compare.js +61 -17
- package/target/main/ts/core/usecases/inspect.js +2 -2
- package/target/main/ts/plugin.d.ts +10 -3
- package/target/main/ts/plugin.js +4 -2
- package/target/main/ts/plugins/coverage/coverage.d.ts +5 -2
- package/target/main/ts/plugins/coverage/coverage.js +35 -10
- package/target/main/ts/plugins/duplication/duplication.js +10 -4
- package/target/main/ts/plugins/language-js/babel-provider.js +8 -2
- package/target/main/ts/plugins/language-js/extensions.d.ts +3 -0
- package/target/main/ts/plugins/language-js/extensions.js +4 -0
- package/target/main/ts/plugins/language-js/function-facts.d.ts +1 -0
- package/target/main/ts/plugins/language-js/function-facts.js +30 -4
- package/target/main/ts/plugins/language-js/js-security.js +3 -2
- package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +11 -0
- package/target/main/ts/report/html/app/viewer-chart-bars.js +54 -0
- package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
- package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
- package/target/main/ts/report/html/app/viewer-chart-line.d.ts +24 -0
- package/target/main/ts/report/html/app/viewer-chart-line.js +89 -0
- package/target/main/ts/report/html/app/viewer-chart-points.d.ts +49 -0
- package/target/main/ts/report/html/app/viewer-chart-points.js +74 -0
- package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
- package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
- package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
- package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
- package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
- package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
- package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
- package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
- package/target/main/ts/report/html/app/viewer-chart.d.ts +4 -98
- package/target/main/ts/report/html/app/viewer-chart.js +16 -677
- package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-code-map.js +175 -0
- package/target/main/ts/report/html/app/viewer-columns.d.ts +38 -0
- package/target/main/ts/report/html/app/viewer-columns.js +92 -0
- package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
- package/target/main/ts/report/html/app/viewer-commits.d.ts +5 -9
- package/target/main/ts/report/html/app/viewer-commits.js +17 -216
- package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
- package/target/main/ts/report/html/app/viewer-controls.js +141 -0
- package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
- package/target/main/ts/report/html/app/viewer-copy.js +64 -0
- package/target/main/ts/report/html/app/viewer-data.d.ts +1 -1
- package/target/main/ts/report/html/app/viewer-data.js +2 -29
- package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
- package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-dom.js +99 -0
- package/target/main/ts/report/html/app/viewer-file-aside.d.ts +19 -0
- package/target/main/ts/report/html/app/viewer-file-aside.js +124 -0
- package/target/main/ts/report/html/app/viewer-file-figures.d.ts +15 -0
- package/target/main/ts/report/html/app/viewer-file-figures.js +60 -0
- package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
- package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
- package/target/main/ts/report/html/app/viewer-files.d.ts +2 -118
- package/target/main/ts/report/html/app/viewer-files.js +24 -2184
- package/target/main/ts/report/html/app/viewer-filter.d.ts +3 -51
- package/target/main/ts/report/html/app/viewer-filter.js +111 -450
- package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-hotspots.js +131 -0
- package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
- package/target/main/ts/report/html/app/viewer-inspection.js +36 -0
- package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
- package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-issues.js +173 -0
- package/target/main/ts/report/html/app/viewer-language-bar.d.ts +9 -0
- package/target/main/ts/report/html/app/viewer-language-bar.js +72 -0
- package/target/main/ts/report/html/app/viewer-languages.d.ts +27 -0
- package/target/main/ts/report/html/app/viewer-languages.js +93 -0
- package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
- package/target/main/ts/report/html/app/viewer-layout.js +134 -0
- package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
- package/target/main/ts/report/html/app/viewer-line-coverage.js +121 -0
- package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
- package/target/main/ts/report/html/app/viewer-locations.js +31 -0
- package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
- package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
- package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
- package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
- package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
- package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
- package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +0 -20
- package/target/main/ts/report/html/app/viewer-metric-registry.js +7 -84
- package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-metrics-view.js +162 -0
- package/target/main/ts/report/html/app/viewer-metrics.d.ts +6 -1
- package/target/main/ts/report/html/app/viewer-metrics.js +53 -35
- package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-overview-cards.js +118 -0
- package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
- package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
- package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
- package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
- package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
- package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
- package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
- package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
- package/target/main/ts/report/html/app/viewer-profile.d.ts +2 -6
- package/target/main/ts/report/html/app/viewer-profile.js +6 -248
- package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
- package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
- package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
- package/target/main/ts/report/html/app/viewer-pulls.d.ts +0 -1
- package/target/main/ts/report/html/app/viewer-pulls.js +28 -178
- package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
- package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
- package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
- package/target/main/ts/report/html/app/viewer-route.js +55 -0
- package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
- package/target/main/ts/report/html/app/viewer-shell.js +116 -0
- package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
- package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
- package/target/main/ts/report/html/app/viewer-source.d.ts +0 -84
- package/target/main/ts/report/html/app/viewer-source.js +7 -365
- package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
- package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
- package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
- package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
- package/target/main/ts/report/html/app/viewer-table-cells.js +129 -0
- package/target/main/ts/report/html/app/viewer-table-rows.d.ts +54 -0
- package/target/main/ts/report/html/app/viewer-table-rows.js +95 -0
- package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +16 -0
- package/target/main/ts/report/html/app/viewer-tokenizer.js +192 -0
- package/target/main/ts/report/html/app/viewer-totals.d.ts +14 -0
- package/target/main/ts/report/html/app/viewer-totals.js +89 -0
- package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
- package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
- package/target/main/ts/report/html/app/viewer-trend-data.d.ts +54 -0
- package/target/main/ts/report/html/app/viewer-trend-data.js +109 -0
- package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
- package/target/main/ts/report/html/app/viewer-trend-nav.js +85 -0
- package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
- package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
- package/target/main/ts/report/html/app/viewer-trend-series.d.ts +26 -0
- package/target/main/ts/report/html/app/viewer-trend-series.js +98 -0
- package/target/main/ts/report/html/app/viewer-trends.d.ts +2 -70
- package/target/main/ts/report/html/app/viewer-trends.js +41 -392
- package/target/main/ts/report/html/app/viewer.js +152 -663
- package/target/main/ts/report/html/site/export-site.d.ts +3 -4
- package/target/main/ts/report/html/site/export-site.js +24 -41
- package/target/main/ts/report/html/site/exported-server.js +2 -1
- package/target/main/ts/report/html/site/local-server.d.ts +1 -1
- package/target/main/ts/report/html/site/local-server.js +13 -19
- package/target/main/ts/report/html/site/projects.js +8 -17
- package/target/main/ts/report/json/projections/commit-summary.d.ts +2 -2
- package/target/main/ts/report/json/projections/commit-summary.js +18 -19
- package/target/main/ts/report/json/projections/file-metrics.js +31 -24
- package/target/main/ts/report/json/projections/inspection-context.js +10 -1
- package/target/main/ts/report/json/projections/inspection-details.d.ts +1 -1
- package/target/main/ts/report/json/projections/inspection-details.js +2 -2
- package/target/main/ts/report/json/projections/metric-values.d.ts +1 -0
- package/target/main/ts/report/json/projections/metric-values.js +15 -5
- package/target/main/ts/report/json/store/local-store.js +2 -12
- package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
- package/target/main/ts/report/json/store/operation-cache.js +32 -0
- package/target/main/ts/report/json/store/pull-review-store.js +1 -2
- package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
- package/target/main/ts/report/json/store/replace-file.js +14 -0
- package/target/main/ts/report/json/validation/report.d.ts +1 -1
- package/target/main/ts/report/json/validation/report.js +10 -8
- package/target/main/ts/report/json/validation/summary-validation.js +1 -3
- package/target/main/ts/report/json/wire/file-metrics-model.d.ts +2 -0
- package/target/main/ts/report/json/wire/inspection-details-model.d.ts +0 -5
- package/target/main/ts/report/json/wire/public-history-model.d.ts +0 -6
- package/target/main/ts/report/json/wire/public-history-model.js +0 -1
- package/target/main/ts/report.d.ts +3 -3
- package/target/main/ts/report.js +2 -2
- package/target/main/resources/report/json/inspection-context-v1.schema.json +0 -172
- package/target/main/resources/report/json/public-history-v1.schema.json +0 -50
- package/target/main/resources/report/json/quality-history-v1.schema.json +0 -51
- package/target/main/resources/report/json/report-v1.schema.json +0 -65
- package/target/main/resources/report/json/viewer-details-v1.schema.json +0 -346
- package/target/main/ts/report/json/projections/public-history.d.ts +0 -4
- package/target/main/ts/report/json/projections/public-history.js +0 -17
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { node, reviewFiles, reviewIssues } from './viewer-pull-sections.js';
|
|
2
|
+
import { formatPercent, lineCount } from './viewer-pull-trend.js';
|
|
3
3
|
const points = new Intl.NumberFormat(undefined, { signDisplay: 'exceptZero', maximumFractionDigits: 1 });
|
|
4
|
-
const
|
|
4
|
+
const gateWords = {
|
|
5
|
+
passed: 'Gate passed', failed: 'Gate failed', 'not-applicable': 'Gate skipped', indeterminate: 'Gate pending data',
|
|
6
|
+
};
|
|
7
|
+
const gateStates = { passed: 'complete', indeterminate: 'partial' };
|
|
5
8
|
const coverageReasons = {
|
|
6
9
|
'reports-unavailable': 'Save inspections for the base and head commits to compare total coverage.',
|
|
7
10
|
'observations-unavailable': 'The saved inspections lack complete line coverage data.',
|
|
@@ -11,12 +14,6 @@ const coverageReasons = {
|
|
|
11
14
|
'method-changed': 'The base and head used different coverage methods.',
|
|
12
15
|
'head-coverage-changed': 'The review used a different LCOV input than the saved head inspection.',
|
|
13
16
|
};
|
|
14
|
-
const findingReasons = {
|
|
15
|
-
'reports-unavailable': 'Save inspections for the base and head commits to compare findings.',
|
|
16
|
-
'findings-unavailable': 'One or both revisions lack findings data.',
|
|
17
|
-
'partial-inspection': 'One or both revisions have incomplete analysis.',
|
|
18
|
-
'analysis-changed': 'The base and head used different analysis settings.',
|
|
19
|
-
};
|
|
20
17
|
export function renderPulls(container, records) {
|
|
21
18
|
const heading = node('h2', 'Pull requests');
|
|
22
19
|
// The page title stands outside the card, as on every other page; the review picker shares its row.
|
|
@@ -51,64 +48,33 @@ export function renderPulls(container, records) {
|
|
|
51
48
|
display(review);
|
|
52
49
|
});
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const subject = node('div', '', 'pull-trend-subject');
|
|
72
|
-
const time = node('time', date.format(new Date(review.generatedAt)), 'detail');
|
|
73
|
-
time.dateTime = review.generatedAt;
|
|
74
|
-
subject.append(node('strong', label), time);
|
|
75
|
-
const track = node('div', '', 'pull-trend-track');
|
|
76
|
-
track.setAttribute('aria-hidden', 'true');
|
|
77
|
-
const { percent, status, covered, total } = review.diff;
|
|
78
|
-
if (percent !== null) {
|
|
79
|
-
const bar = node('div', '', 'pull-trend-bar');
|
|
80
|
-
bar.dataset.status = status;
|
|
81
|
-
bar.style.inlineSize = `${percent}%`;
|
|
82
|
-
track.append(bar);
|
|
83
|
-
}
|
|
84
|
-
const value = node('div', '', 'pull-trend-result');
|
|
85
|
-
if (percent === null) {
|
|
86
|
-
value.append(node('span', status === 'partial' ? 'Partial · Unmeasured'
|
|
87
|
-
: status === 'not-applicable' ? 'No measurable changes' : 'Coverage unavailable', 'detail'));
|
|
88
|
-
track.classList.add('pull-trend-empty');
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const result = `${whole.format(covered)} / ${whole.format(total)} lines`;
|
|
92
|
-
value.append(node('strong', formatPercent(percent)), node('span', status === 'partial' ? `Partial · ${result}` : result, 'detail'));
|
|
93
|
-
}
|
|
94
|
-
row.append(subject, track, value);
|
|
95
|
-
list.append(row);
|
|
96
|
-
}
|
|
51
|
+
/** Total coverage and how it moved from the base. */
|
|
52
|
+
function totalCoverage(coverage) {
|
|
53
|
+
const total = coverage.head?.value == null ? 'Unavailable' : formatPercent(coverage.head.value);
|
|
54
|
+
return [total, coverage.delta === null ? 'No comparable base coverage' : `${points.format(coverage.delta)} pp from base`];
|
|
55
|
+
}
|
|
56
|
+
/** Changed-line coverage, with the measured lines behind it or why there are none. */
|
|
57
|
+
function changedCoverage(diff) {
|
|
58
|
+
if (diff.percent === null)
|
|
59
|
+
return diff.status === 'not-applicable' ? 'No measured changed lines' : 'Coverage unavailable';
|
|
60
|
+
return `${lineCount(diff.covered)} of ${lineCount(diff.total)} measured lines${diff.status === 'partial' ? ' · Partial' : ''}`;
|
|
61
|
+
}
|
|
62
|
+
/** New issues; where the gate counted a different number of quality issues, the line under the figure says so. */
|
|
63
|
+
function newIssues({ added, gate, qualityCount }) {
|
|
64
|
+
const value = added === null ? 'Unavailable' : lineCount(added.length);
|
|
65
|
+
if (gate && qualityCount !== null && qualityCount !== added?.length)
|
|
66
|
+
return [value, `Gate counted ${lineCount(qualityCount)} quality issues`];
|
|
67
|
+
return [value, added === null ? '' : 'Compared with base'];
|
|
97
68
|
}
|
|
98
69
|
function reviewSummary({ base, head, coverage, diff, findings }) {
|
|
99
70
|
const header = node('div', '', 'pull-revisions');
|
|
100
71
|
header.append(node('p', 'Base ', 'detail'), node('code', base.slice(0, 7)), node('span', '→', 'detail'), node('p', 'Head ', 'detail'), node('code', head.slice(0, 7)));
|
|
101
72
|
const summary = node('div', '', 'pull-summary');
|
|
102
|
-
|
|
103
|
-
const change = coverage.delta === null ? 'No comparable base coverage' : `${points.format(coverage.delta)} pp from base`;
|
|
104
|
-
summary.append(summaryMetric('Total coverage', total, change, coverage.gate?.status), summaryMetric('Changed-line coverage', formatPercent(diff.percent), diff.percent === null
|
|
105
|
-
? diff.status === 'not-applicable' ? 'No measured changed lines' : 'Coverage unavailable'
|
|
106
|
-
: `${whole.format(diff.covered)} of ${whole.format(diff.total)} measured lines${diff.status === 'partial' ? ' · Partial' : ''}`, diff.gate?.status), summaryMetric('New issues', findings.added === null ? 'Unavailable' : whole.format(findings.added.length), findings.gate && findings.qualityCount !== null && findings.qualityCount !== findings.added?.length
|
|
107
|
-
? `Gate counted ${whole.format(findings.qualityCount)} quality issues`
|
|
108
|
-
: findings.added === null ? '' : 'Compared with base', findings.gate?.status));
|
|
73
|
+
summary.append(summaryMetric('Total coverage', ...totalCoverage(coverage), coverage.gate?.status), summaryMetric('Changed-line coverage', formatPercent(diff.percent), changedCoverage(diff), diff.gate?.status), summaryMetric('New issues', ...newIssues(findings), findings.gate?.status));
|
|
109
74
|
const result = node('div', '', 'pull-summary-block');
|
|
110
75
|
result.append(header, summary);
|
|
111
|
-
|
|
76
|
+
const measured = coverage.base || coverage.head || coverage.gate;
|
|
77
|
+
if (coverage.reason && measured)
|
|
112
78
|
result.append(node('p', coverageReasons[coverage.reason], 'detail'));
|
|
113
79
|
return result;
|
|
114
80
|
}
|
|
@@ -118,125 +84,9 @@ function summaryMetric(label, value, detail, gate) {
|
|
|
118
84
|
if (detail)
|
|
119
85
|
figure.append(node('p', detail, 'detail'));
|
|
120
86
|
if (gate) {
|
|
121
|
-
const badge = node('span',
|
|
122
|
-
|
|
123
|
-
}[gate] ?? gate, 'status pull-gate');
|
|
124
|
-
badge.dataset.status = gate === 'passed' ? 'complete' : gate === 'indeterminate' ? 'partial' : gate;
|
|
87
|
+
const badge = node('span', gateWords[gate] ?? gate, 'status pull-gate');
|
|
88
|
+
badge.dataset.status = gateStates[gate] ?? gate;
|
|
125
89
|
figure.append(badge);
|
|
126
90
|
}
|
|
127
91
|
return figure;
|
|
128
92
|
}
|
|
129
|
-
function reviewFiles(review) {
|
|
130
|
-
const section = node('section', '', 'pull-section');
|
|
131
|
-
const heading = node('h3', 'Changed files');
|
|
132
|
-
section.append(heading);
|
|
133
|
-
const { diff } = review;
|
|
134
|
-
if (diff.excludedPaths?.length) {
|
|
135
|
-
section.append(node('p', `Path exclusions · ${diff.excludedPaths.join(', ')}`, 'detail pull-exclusions'));
|
|
136
|
-
}
|
|
137
|
-
if (diff.files.length === 0 && diff.gaps.length === 0) {
|
|
138
|
-
section.append(node('p', diff.status === 'unavailable' ? 'Provide LCOV for this head revision to inspect its changed lines.'
|
|
139
|
-
: 'No added or modified source lines in the inspected scope.', 'detail'));
|
|
140
|
-
return section;
|
|
141
|
-
}
|
|
142
|
-
const files = new Map(diff.uncovered.map(file => [file.path, file.lines]));
|
|
143
|
-
const gaps = new Map(diff.gaps.map(gap => [gap.path, gap.reason]));
|
|
144
|
-
const rows = [...diff.files].sort((left, right) => missedCount(right) - missedCount(left) || right.addedLines - left.addedLines)
|
|
145
|
-
.map(record => {
|
|
146
|
-
const { path, addedLines, covered, total } = record;
|
|
147
|
-
const label = node('th');
|
|
148
|
-
const parts = path.split('/');
|
|
149
|
-
for (const [index, part] of parts.entries()) {
|
|
150
|
-
label.append(part);
|
|
151
|
-
if (index < parts.length - 1)
|
|
152
|
-
label.append('/', node('wbr'));
|
|
153
|
-
}
|
|
154
|
-
label.scope = 'row';
|
|
155
|
-
const missing = files.get(path);
|
|
156
|
-
const gap = gaps.get(path);
|
|
157
|
-
gaps.delete(path);
|
|
158
|
-
if (missing) {
|
|
159
|
-
const details = node('details', '', 'pull-missed-lines');
|
|
160
|
-
const ranges = lineRanges(missing);
|
|
161
|
-
details.append(node('summary', `${whole.format(missing.length)} missed ${missing.length === 1 ? 'line' : 'lines'}`), node('span', ranges.join(', ')));
|
|
162
|
-
label.append(details);
|
|
163
|
-
}
|
|
164
|
-
if (gap)
|
|
165
|
-
label.append(node('p', gap, 'detail'));
|
|
166
|
-
const row = node('tr');
|
|
167
|
-
row.append(label, cell(whole.format(addedLines), true), cell(covered === null || total === null ? '—' : `${whole.format(covered)} / ${whole.format(total)}`, true));
|
|
168
|
-
return row;
|
|
169
|
-
});
|
|
170
|
-
if (rows.length > 0)
|
|
171
|
-
section.append(table('Changed file coverage', ['File', 'Added lines', 'Covered / measured'], rows, 'pull-coverage-table'));
|
|
172
|
-
if (gaps.size > 0) {
|
|
173
|
-
const notes = node('ul', '', 'pull-gaps');
|
|
174
|
-
for (const [path, reason] of gaps)
|
|
175
|
-
notes.append(node('li', `${path} · ${reason}`));
|
|
176
|
-
section.append(node('h4', 'Coverage gaps'), notes);
|
|
177
|
-
}
|
|
178
|
-
return section;
|
|
179
|
-
}
|
|
180
|
-
function reviewIssues({ findings }) {
|
|
181
|
-
const section = node('section', '', 'pull-section');
|
|
182
|
-
section.append(node('h3', 'New issues'));
|
|
183
|
-
if (findings.added === null || findings.added.length === 0) {
|
|
184
|
-
section.append(node('p', findings.reason ? findingReasons[findings.reason] : 'No new issues in the inspected scope.', 'detail'));
|
|
185
|
-
return section;
|
|
186
|
-
}
|
|
187
|
-
const rows = findings.added.map(finding => {
|
|
188
|
-
const row = node('tr');
|
|
189
|
-
const message = node('th', finding.message);
|
|
190
|
-
message.scope = 'row';
|
|
191
|
-
message.append(node('p', [finding.tool, finding.rule].join(' · '), 'detail'));
|
|
192
|
-
const location = finding.path ? `${finding.path}${finding.line ? `:${finding.line}` : ''}` : '—';
|
|
193
|
-
row.append(message, cell(location), cell(finding.level));
|
|
194
|
-
return row;
|
|
195
|
-
});
|
|
196
|
-
section.append(table('Newly introduced findings', ['Finding', 'Source', 'Severity'], rows));
|
|
197
|
-
return section;
|
|
198
|
-
}
|
|
199
|
-
function lineRanges(lines) {
|
|
200
|
-
const ranges = [];
|
|
201
|
-
for (let start = 0; start < lines.length;) {
|
|
202
|
-
let end = start;
|
|
203
|
-
while (lines[end + 1] === lines[end] + 1)
|
|
204
|
-
end++;
|
|
205
|
-
ranges.push(start === end ? String(lines[start]) : `${lines[start]}–${lines[end]}`);
|
|
206
|
-
start = end + 1;
|
|
207
|
-
}
|
|
208
|
-
return ranges;
|
|
209
|
-
}
|
|
210
|
-
function missedCount({ covered, total }) {
|
|
211
|
-
return covered === null || total === null ? -1 : total - covered;
|
|
212
|
-
}
|
|
213
|
-
function formatPercent(value) {
|
|
214
|
-
return value === null ? 'Unavailable' : percentage.format(value / 100);
|
|
215
|
-
}
|
|
216
|
-
function table(label, headers, rows, className = '') {
|
|
217
|
-
const table = node('table', '', `pull-table ${className}`.trim());
|
|
218
|
-
const thead = node('thead');
|
|
219
|
-
const headings = node('tr');
|
|
220
|
-
for (const text of headers) {
|
|
221
|
-
const th = node('th', text);
|
|
222
|
-
th.scope = 'col';
|
|
223
|
-
headings.append(th);
|
|
224
|
-
}
|
|
225
|
-
thead.append(headings);
|
|
226
|
-
const body = node('tbody');
|
|
227
|
-
body.append(...rows);
|
|
228
|
-
table.append(thead, body);
|
|
229
|
-
table.setAttribute('aria-label', label);
|
|
230
|
-
return table;
|
|
231
|
-
}
|
|
232
|
-
function cell(text, numeric = false) {
|
|
233
|
-
return node('td', text, numeric ? 'numeric' : '');
|
|
234
|
-
}
|
|
235
|
-
function node(name, text = '', className = '') {
|
|
236
|
-
const element = document.createElement(name);
|
|
237
|
-
if (text)
|
|
238
|
-
element.textContent = text;
|
|
239
|
-
if (className)
|
|
240
|
-
element.className = className;
|
|
241
|
-
return element;
|
|
242
|
-
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Clause } from './viewer-filter.js';
|
|
2
|
+
import type { Suggestion } from './viewer-suggest.js';
|
|
3
|
+
export interface QueryField {
|
|
4
|
+
readonly element: HTMLElement;
|
|
5
|
+
/** Text typed but not yet made a chip; it filters paths as you type. */
|
|
6
|
+
readonly text: () => string;
|
|
7
|
+
/** Replaces the chips from outside, as when a language is picked on the bar; reports the change as typing does. */
|
|
8
|
+
readonly set: (clauses: readonly Clause[]) => void;
|
|
9
|
+
}
|
|
10
|
+
interface FieldOptions {
|
|
11
|
+
readonly suggestions: (text: string) => Suggestion[];
|
|
12
|
+
readonly change: (clauses: readonly Clause[], text: string) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The field: chips for the chosen clauses, then a text input; the list of suggestions hangs from it in one frame.
|
|
16
|
+
* Backspace in an empty input takes the last chip back into text, so a chip can be edited, not just removed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function queryField(clauses: readonly Clause[], options: FieldOptions): QueryField;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { element } from './viewer-dom.js';
|
|
2
|
+
import { clauseLabel, clauseText, parseWord, sameClause } from './viewer-filter.js';
|
|
3
|
+
import { languageColor } from './viewer-languages.js';
|
|
4
|
+
function dot(color) {
|
|
5
|
+
const node = element('span', 'qf-dot');
|
|
6
|
+
node.style.background = color;
|
|
7
|
+
return node;
|
|
8
|
+
}
|
|
9
|
+
/** A chip: what it selects, in words, and a button that takes it away. */
|
|
10
|
+
function chip(clause, remove) {
|
|
11
|
+
const node = element('span', `qf-chip qf-chip-${clause.kind}`);
|
|
12
|
+
const { key, value } = clauseLabel(clause);
|
|
13
|
+
if (clause.kind === 'lang')
|
|
14
|
+
node.append(dot(languageColor(clause.value)));
|
|
15
|
+
node.append(element('span', 'qf-chip-key', key), element('span', 'qf-chip-value', value));
|
|
16
|
+
const button = element('button', 'qf-remove');
|
|
17
|
+
button.type = 'button';
|
|
18
|
+
button.setAttribute('aria-label', `Remove ${key} ${value}`);
|
|
19
|
+
button.addEventListener('click', remove);
|
|
20
|
+
node.append(button);
|
|
21
|
+
return node;
|
|
22
|
+
}
|
|
23
|
+
function option(suggestion, id) {
|
|
24
|
+
const item = element('li', 'qf-option');
|
|
25
|
+
item.id = id;
|
|
26
|
+
item.setAttribute('role', 'option');
|
|
27
|
+
if (suggestion.color)
|
|
28
|
+
item.append(dot(suggestion.color));
|
|
29
|
+
item.append(element('span', 'qf-option-label', suggestion.label));
|
|
30
|
+
if (suggestion.detail)
|
|
31
|
+
item.append(element('span', 'qf-option-detail', suggestion.detail));
|
|
32
|
+
item.addEventListener('mousedown', event => event.preventDefault());
|
|
33
|
+
return item;
|
|
34
|
+
}
|
|
35
|
+
function groupHeading(group) {
|
|
36
|
+
const heading = element('li', 'qf-group', group);
|
|
37
|
+
heading.setAttribute('role', 'presentation');
|
|
38
|
+
return heading;
|
|
39
|
+
}
|
|
40
|
+
function combobox(listId) {
|
|
41
|
+
const input = element('input', 'qf-input');
|
|
42
|
+
input.type = 'text';
|
|
43
|
+
input.autocomplete = 'off';
|
|
44
|
+
input.spellcheck = false;
|
|
45
|
+
input.setAttribute('role', 'combobox');
|
|
46
|
+
input.setAttribute('aria-label', 'Filter files');
|
|
47
|
+
input.setAttribute('aria-autocomplete', 'list');
|
|
48
|
+
input.setAttribute('aria-expanded', 'false');
|
|
49
|
+
input.setAttribute('aria-controls', listId);
|
|
50
|
+
return input;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The field: chips for the chosen clauses, then a text input; the list of suggestions hangs from it in one frame.
|
|
54
|
+
* Backspace in an empty input takes the last chip back into text, so a chip can be edited, not just removed.
|
|
55
|
+
*/
|
|
56
|
+
export function queryField(clauses, options) {
|
|
57
|
+
let chosen = [...clauses];
|
|
58
|
+
let active = 0;
|
|
59
|
+
let shown = [];
|
|
60
|
+
const root = element('div', 'qf');
|
|
61
|
+
const box = element('div', 'qf-box');
|
|
62
|
+
const chips = element('span', 'qf-chips');
|
|
63
|
+
const list = element('ul', 'qf-options');
|
|
64
|
+
list.id = `qf-options-${Math.random().toString(36).slice(2, 8)}`;
|
|
65
|
+
list.setAttribute('role', 'listbox');
|
|
66
|
+
const input = combobox(list.id);
|
|
67
|
+
const popover = element('div', 'qf-popover');
|
|
68
|
+
popover.hidden = true;
|
|
69
|
+
const help = element('p', 'qf-help', 'Combine chips: same kind widens, different kinds narrow. Type complexity>10 or coverage<80% for a condition.');
|
|
70
|
+
popover.append(list, help);
|
|
71
|
+
box.append(chips, input);
|
|
72
|
+
root.append(box, popover);
|
|
73
|
+
function renderChips() {
|
|
74
|
+
chips.replaceChildren(...chosen.map((clause, index) => chip(clause, () => {
|
|
75
|
+
chosen.splice(index, 1);
|
|
76
|
+
commit();
|
|
77
|
+
input.focus();
|
|
78
|
+
})));
|
|
79
|
+
input.placeholder = chosen.length ? 'Add a filter' : 'Filter by language, component, condition or path';
|
|
80
|
+
}
|
|
81
|
+
function commit() {
|
|
82
|
+
renderChips();
|
|
83
|
+
options.change(chosen, input.value.trim());
|
|
84
|
+
if (!popover.hidden)
|
|
85
|
+
update();
|
|
86
|
+
}
|
|
87
|
+
function update() {
|
|
88
|
+
shown = options.suggestions(input.value);
|
|
89
|
+
active = Math.min(active, Math.max(0, shown.length - 1));
|
|
90
|
+
list.replaceChildren(...shown.flatMap((suggestion, index) => {
|
|
91
|
+
const item = option(suggestion, `${list.id}-${index}`);
|
|
92
|
+
item.addEventListener('click', () => choose(suggestion));
|
|
93
|
+
item.addEventListener('mousemove', () => {
|
|
94
|
+
if (active === index)
|
|
95
|
+
return;
|
|
96
|
+
active = index;
|
|
97
|
+
highlight();
|
|
98
|
+
});
|
|
99
|
+
return suggestion.group === shown[index - 1]?.group ? [item] : [groupHeading(suggestion.group), item];
|
|
100
|
+
}));
|
|
101
|
+
highlight();
|
|
102
|
+
}
|
|
103
|
+
function highlight() {
|
|
104
|
+
for (const item of list.querySelectorAll('.qf-option'))
|
|
105
|
+
item.classList.toggle('active', item.id === `${list.id}-${active}`);
|
|
106
|
+
const current = list.querySelector(`#${list.id}-${active}`);
|
|
107
|
+
if (!current) {
|
|
108
|
+
input.removeAttribute('aria-activedescendant');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
input.setAttribute('aria-activedescendant', current.id);
|
|
112
|
+
current.scrollIntoView({ block: 'nearest' });
|
|
113
|
+
}
|
|
114
|
+
function open() {
|
|
115
|
+
if (!popover.hidden)
|
|
116
|
+
return;
|
|
117
|
+
popover.hidden = false;
|
|
118
|
+
root.classList.add('open');
|
|
119
|
+
input.setAttribute('aria-expanded', 'true');
|
|
120
|
+
active = 0;
|
|
121
|
+
update();
|
|
122
|
+
document.addEventListener('pointerdown', outside, true);
|
|
123
|
+
}
|
|
124
|
+
function close() {
|
|
125
|
+
if (popover.hidden)
|
|
126
|
+
return;
|
|
127
|
+
popover.hidden = true;
|
|
128
|
+
root.classList.remove('open');
|
|
129
|
+
input.setAttribute('aria-expanded', 'false');
|
|
130
|
+
document.removeEventListener('pointerdown', outside, true);
|
|
131
|
+
}
|
|
132
|
+
function outside(event) {
|
|
133
|
+
if (!root.contains(event.target))
|
|
134
|
+
close();
|
|
135
|
+
}
|
|
136
|
+
function choose(suggestion) {
|
|
137
|
+
if (!chosen.some(clause => sameClause(clause, suggestion.clause)))
|
|
138
|
+
chosen.push(suggestion.clause);
|
|
139
|
+
input.value = '';
|
|
140
|
+
active = 0;
|
|
141
|
+
commit();
|
|
142
|
+
}
|
|
143
|
+
/** Enter takes the highlighted suggestion, or makes a chip of the typed text. */
|
|
144
|
+
function enter() {
|
|
145
|
+
const typed = input.value.trim();
|
|
146
|
+
const suggestion = shown[active];
|
|
147
|
+
if (suggestion && !popover.hidden)
|
|
148
|
+
choose(suggestion);
|
|
149
|
+
else if (typed)
|
|
150
|
+
choose({ group: '', label: typed, clause: parseWord(typed) ?? { kind: 'path', value: typed } });
|
|
151
|
+
}
|
|
152
|
+
function step(by) {
|
|
153
|
+
open();
|
|
154
|
+
if (shown.length)
|
|
155
|
+
active = (active + by + shown.length) % shown.length;
|
|
156
|
+
highlight();
|
|
157
|
+
}
|
|
158
|
+
/** Each key the field handles, and whether it takes the key from the browser. */
|
|
159
|
+
const keys = new Map([
|
|
160
|
+
['ArrowDown', () => { step(1); return true; }],
|
|
161
|
+
['ArrowUp', () => { step(-1); return true; }],
|
|
162
|
+
['Enter', () => { enter(); return true; }],
|
|
163
|
+
['Escape', () => {
|
|
164
|
+
if (popover.hidden)
|
|
165
|
+
return false;
|
|
166
|
+
close();
|
|
167
|
+
return true;
|
|
168
|
+
}],
|
|
169
|
+
['Backspace', () => {
|
|
170
|
+
if (input.value !== '' || !chosen.length)
|
|
171
|
+
return false;
|
|
172
|
+
input.value = clauseText(chosen.pop());
|
|
173
|
+
commit();
|
|
174
|
+
return true;
|
|
175
|
+
}],
|
|
176
|
+
]);
|
|
177
|
+
box.addEventListener('pointerdown', event => {
|
|
178
|
+
if (event.target !== box && event.target !== chips)
|
|
179
|
+
return;
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
input.focus();
|
|
182
|
+
});
|
|
183
|
+
input.addEventListener('focus', open);
|
|
184
|
+
input.addEventListener('input', () => {
|
|
185
|
+
open();
|
|
186
|
+
active = 0;
|
|
187
|
+
update();
|
|
188
|
+
options.change(chosen, input.value.trim());
|
|
189
|
+
});
|
|
190
|
+
input.addEventListener('keydown', event => {
|
|
191
|
+
if (keys.get(event.key)?.())
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
});
|
|
194
|
+
renderChips();
|
|
195
|
+
return {
|
|
196
|
+
element: root,
|
|
197
|
+
text: () => input.value.trim(),
|
|
198
|
+
set(next) {
|
|
199
|
+
chosen = [...next];
|
|
200
|
+
commit();
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Period, TrendView } from './viewer-trend-data.js';
|
|
2
|
+
export declare const pages: readonly ['overview', 'metrics', 'hotspots', 'trends', 'issues', 'diagnostics', 'settings', 'pulls'];
|
|
3
|
+
export type Page = typeof pages[number];
|
|
4
|
+
export type FilePage = 'metrics' | 'hotspots' | 'issues' | 'diagnostics';
|
|
5
|
+
/** Where the viewer is: a page at a commit, and what the page shows there. */
|
|
6
|
+
export interface Route {
|
|
7
|
+
page: Page;
|
|
8
|
+
sha: string;
|
|
9
|
+
directory?: string;
|
|
10
|
+
file?: string;
|
|
11
|
+
view?: TrendView;
|
|
12
|
+
period?: Period;
|
|
13
|
+
/** Metrics query and grouping. */
|
|
14
|
+
query?: string;
|
|
15
|
+
group?: string;
|
|
16
|
+
/** A source line in an open file. */
|
|
17
|
+
line?: number;
|
|
18
|
+
/** Issues filters: finding categories, comma-separated, and a severity. */
|
|
19
|
+
category?: string;
|
|
20
|
+
level?: string;
|
|
21
|
+
/** What Hotspots ranks by. */
|
|
22
|
+
rank?: string;
|
|
23
|
+
/** What an open file's lines show: findings, or coverage. */
|
|
24
|
+
layer?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function href(route: Route): string;
|
|
27
|
+
export declare function isFilePage(page: Page): page is FilePage;
|
|
28
|
+
/** The pages that read the inspection's details; the summary's counts serve the rest. */
|
|
29
|
+
export declare function needsDetails(page: Page): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Reads the route from a location hash. A bare commit opens its Overview; an unknown commit reads as the newest one.
|
|
32
|
+
* Components became a grouping of Metrics, so old links land there.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readRoute(hash: string, commits: ReadonlySet<string>, newest: string): Route;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isPeriod, isTrendView } from './viewer-trend-data.js';
|
|
2
|
+
export const pages = ['overview', 'metrics', 'hotspots', 'trends', 'issues', 'diagnostics', 'settings', 'pulls'];
|
|
3
|
+
/** The route's parts by their names in the URL, in the order the URL lists them. */
|
|
4
|
+
const parameters = [['directory', 'dir'], ['file', 'file'], ['view', 'view'], ['period', 'period'], ['query', 'q'], ['group', 'group'],
|
|
5
|
+
['line', 'line'], ['category', 'category'], ['level', 'level'], ['rank', 'rank'], ['layer', 'layer']];
|
|
6
|
+
export function href(route) {
|
|
7
|
+
const params = new URLSearchParams({ sha: route.sha });
|
|
8
|
+
for (const [key, name] of parameters) {
|
|
9
|
+
const value = route[key];
|
|
10
|
+
if (value)
|
|
11
|
+
params.set(name, String(value));
|
|
12
|
+
}
|
|
13
|
+
// Category lists read as written: category=structure,duplication.
|
|
14
|
+
return `#${route.page}?${params.toString().replaceAll('%2C', ',')}`;
|
|
15
|
+
}
|
|
16
|
+
export function isFilePage(page) {
|
|
17
|
+
return page === 'metrics' || page === 'hotspots' || page === 'issues' || page === 'diagnostics';
|
|
18
|
+
}
|
|
19
|
+
/** The pages that read the inspection's details; the summary's counts serve the rest. */
|
|
20
|
+
export function needsDetails(page) {
|
|
21
|
+
return isFilePage(page) || page === 'overview' || page === 'settings';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads the route from a location hash. A bare commit opens its Overview; an unknown commit reads as the newest one.
|
|
25
|
+
* Components became a grouping of Metrics, so old links land there.
|
|
26
|
+
*/
|
|
27
|
+
export function readRoute(hash, commits, newest) {
|
|
28
|
+
const [rawPage = '', query = ''] = hash.slice(1).split('?', 2);
|
|
29
|
+
if (commits.has(rawPage))
|
|
30
|
+
return { page: 'overview', sha: rawPage };
|
|
31
|
+
const params = new URLSearchParams(query);
|
|
32
|
+
const named = params.get('sha') ?? '';
|
|
33
|
+
const sha = commits.has(named) ? named : newest;
|
|
34
|
+
if (rawPage === 'components')
|
|
35
|
+
return { page: 'metrics', sha, group: 'components' };
|
|
36
|
+
const optional = (name) => params.get(name) ?? undefined;
|
|
37
|
+
const view = optional('view');
|
|
38
|
+
const period = optional('period');
|
|
39
|
+
const line = Number(params.get('line'));
|
|
40
|
+
return {
|
|
41
|
+
page: pages.find(candidate => candidate === rawPage) ?? 'overview',
|
|
42
|
+
sha,
|
|
43
|
+
directory: optional('dir'),
|
|
44
|
+
file: optional('file'),
|
|
45
|
+
view: isTrendView(view) ? view : undefined,
|
|
46
|
+
period: isPeriod(period) ? period : undefined,
|
|
47
|
+
query: optional('q'),
|
|
48
|
+
group: optional('group'),
|
|
49
|
+
line: line > 0 ? line : undefined,
|
|
50
|
+
category: optional('category'),
|
|
51
|
+
level: optional('level'),
|
|
52
|
+
rank: optional('rank'),
|
|
53
|
+
layer: optional('layer'),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
|
|
2
|
+
import type { PublicHistoryEntry } from '../../json/wire/public-history-model.js';
|
|
3
|
+
import type { ViewerData } from './viewer-data.js';
|
|
4
|
+
import type { BuiltinMetric, Metric } from './viewer-metrics.js';
|
|
5
|
+
import type { Page, Route } from './viewer-route.js';
|
|
6
|
+
import type { TrendData } from './viewer-trend-data.js';
|
|
7
|
+
/** The area the Overview opens on: maintainability where it was measured, else coverage, else complexity. */
|
|
8
|
+
export declare function firstArea({ reports, quality }: ViewerData): BuiltinMetric;
|
|
9
|
+
/** The Overview's quality tabs: one selected and focusable, the arrows moving between the visible ones. */
|
|
10
|
+
export declare function verdictTabs(select: (metric: BuiltinMetric) => void): (chosen: BuiltinMetric) => void;
|
|
11
|
+
export declare function showTab(page: Page, visible: boolean): void;
|
|
12
|
+
/** Tabs follow the code: pages with nothing to show leave the bar, and issues and diagnostics carry their count. */
|
|
13
|
+
export declare function updateTabs(page: Page, findings: number, diagnostics: number): void;
|
|
14
|
+
export declare function updateDetailsTabs(page: Page, details: InspectionDetails): void;
|
|
15
|
+
/** Shows the route's page and points the navigation at its commit; focus follows a page change made from the page. */
|
|
16
|
+
export declare function showPage(current: Route): void;
|
|
17
|
+
export declare function renderTrend(data: TrendData, selected: PublicHistoryEntry, metric: Metric, compact: boolean): void;
|
|
18
|
+
export declare function readOptional<T>(path: string): Promise<T | null>;
|
|
19
|
+
/** The project's name, where the export gives one, in the tab and the header. */
|
|
20
|
+
export declare function showTitle(): void;
|