repometry 0.4.1 → 0.5.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 +4 -0
- package/package.json +1 -1
- package/target/main/resources/report/json/report-v2.schema.json +13 -1
- package/target/main/resources/viewer/files.css +7 -3
- package/target/main/resources/viewer/styles.css +2 -2
- package/target/main/ts/api/git/git.d.ts +1 -0
- package/target/main/ts/api/git/git.js +12 -0
- package/target/main/ts/api/git/inspection-source.js +2 -8
- package/target/main/ts/api/git/local.d.ts +1 -1
- package/target/main/ts/api/git/local.js +39 -5
- 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/compose/analyze-snapshot.d.ts +3 -2
- package/target/main/ts/compose/analyze-snapshot.js +82 -29
- package/target/main/ts/compose/inspect.d.ts +5 -0
- package/target/main/ts/compose/inspect.js +10 -6
- 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/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 +1 -0
- package/target/main/ts/core/engine/plan.js +22 -3
- package/target/main/ts/core/engine/plugin.d.ts +8 -1
- 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.js +1 -1
- package/target/main/ts/core/model/code-structure.d.ts +3 -0
- package/target/main/ts/core/model/code-structure.js +4 -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/line-coverage.d.ts +5 -1
- package/target/main/ts/core/model/line-coverage.js +14 -11
- package/target/main/ts/core/model/measurement.js +1 -1
- package/target/main/ts/core/model/plugin-data.d.ts +2 -0
- package/target/main/ts/core/model/plugin-data.js +15 -1
- package/target/main/ts/core/model/quality-summary.js +1 -1
- package/target/main/ts/core/model/scanner-import.js +1 -1
- package/target/main/ts/core/model/snapshot.d.ts +1 -0
- package/target/main/ts/core/model/snapshot.js +5 -1
- 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/plugin.d.ts +7 -1
- package/target/main/ts/plugin.js +3 -1
- 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/language-js/function-facts.d.ts +1 -0
- package/target/main/ts/plugins/language-js/function-facts.js +30 -4
- 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-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 +0 -77
- 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 +112 -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 -363
- 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 +49 -0
- package/target/main/ts/report/html/app/viewer-trend-data.js +105 -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/badges.js +41 -18
- 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/replace-file.d.ts +1 -0
- package/target/main/ts/report/json/store/replace-file.js +14 -0
- package/target/main/ts/report.d.ts +1 -0
- package/target/main/ts/report.js +1 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** The DOM building blocks every page of the viewer shares. */
|
|
2
|
+
const integer = new Intl.NumberFormat();
|
|
3
|
+
const percentFormat = new Intl.NumberFormat(undefined, { style: 'percent', maximumFractionDigits: 1 });
|
|
4
|
+
/** Paths compare as people read them: numbers by value, so file10 follows file9. */
|
|
5
|
+
export const collator = new Intl.Collator(undefined, { numeric: true });
|
|
6
|
+
export function element(tag, className, text) {
|
|
7
|
+
const node = document.createElement(tag);
|
|
8
|
+
if (className)
|
|
9
|
+
node.className = className;
|
|
10
|
+
if (text)
|
|
11
|
+
node.textContent = text;
|
|
12
|
+
return node;
|
|
13
|
+
}
|
|
14
|
+
export function svgElement(tag) {
|
|
15
|
+
return document.createElementNS('http://www.w3.org/2000/svg', tag);
|
|
16
|
+
}
|
|
17
|
+
export function link(href, label, className) {
|
|
18
|
+
const result = element('a', className, label);
|
|
19
|
+
result.href = href;
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
/** A link that opens another site in a new tab, without handing it this page. */
|
|
23
|
+
export function externalLink(href, label, className) {
|
|
24
|
+
const result = link(href, label, className);
|
|
25
|
+
result.target = '_blank';
|
|
26
|
+
result.rel = 'noopener noreferrer';
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
/** One row of a description list, with a quieter line of context under the value. */
|
|
30
|
+
export function fact(label, value, context) {
|
|
31
|
+
const pair = element('div');
|
|
32
|
+
pair.append(element('dt', '', label), element('dd', '', value));
|
|
33
|
+
if (context)
|
|
34
|
+
pair.append(element('dd', 'fx-note', context));
|
|
35
|
+
return pair;
|
|
36
|
+
}
|
|
37
|
+
/** A table that scrolls on its own, named so the region can be found and scrolled from the keyboard. */
|
|
38
|
+
export function scrollableTable(table, label) {
|
|
39
|
+
const region = element('div', 'table-scroll fx-table-scroll');
|
|
40
|
+
region.setAttribute('role', 'region');
|
|
41
|
+
region.setAttribute('aria-label', label);
|
|
42
|
+
region.tabIndex = 0;
|
|
43
|
+
region.append(table);
|
|
44
|
+
return region;
|
|
45
|
+
}
|
|
46
|
+
export function count(value) {
|
|
47
|
+
return value == null ? '—' : integer.format(value);
|
|
48
|
+
}
|
|
49
|
+
export function percent(value) {
|
|
50
|
+
return percentFormat.format(value);
|
|
51
|
+
}
|
|
52
|
+
export function quantity(amount, noun) {
|
|
53
|
+
return `${count(amount)} ${noun}${amount === 1 ? '' : 's'}`;
|
|
54
|
+
}
|
|
55
|
+
export function parentPath(path) {
|
|
56
|
+
return path.slice(0, Math.max(0, path.lastIndexOf('/')));
|
|
57
|
+
}
|
|
58
|
+
export function basename(path) {
|
|
59
|
+
return path.slice(path.lastIndexOf('/') + 1);
|
|
60
|
+
}
|
|
61
|
+
export function inside(path, directory) {
|
|
62
|
+
return directory === '' || path.startsWith(`${directory}/`);
|
|
63
|
+
}
|
|
64
|
+
/** Whether any of the strings holds the lowercased query; an empty query holds everywhere. */
|
|
65
|
+
export function contains(query, strings) {
|
|
66
|
+
return query === '' || strings.some(value => value?.toLowerCase().includes(query));
|
|
67
|
+
}
|
|
68
|
+
/** Storage that a private window or a blocked site refuses: reads fall back, writes are forgotten. */
|
|
69
|
+
export function stored(storage, key) {
|
|
70
|
+
try {
|
|
71
|
+
return storage().getItem(key);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function store(storage, key, value) {
|
|
78
|
+
try {
|
|
79
|
+
if (value === null)
|
|
80
|
+
storage().removeItem(key);
|
|
81
|
+
else
|
|
82
|
+
storage().setItem(key, value);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Without storage the choice lasts for this page only.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** An element of the page by its id; the page's own markup holds every id the viewer asks for. */
|
|
89
|
+
export function byId(id) {
|
|
90
|
+
return document.getElementById(id);
|
|
91
|
+
}
|
|
92
|
+
/** A quiet status line in place of a container's content: loading, empty, or failed. */
|
|
93
|
+
export function notice(container, text) {
|
|
94
|
+
const paragraph = document.createElement('p');
|
|
95
|
+
paragraph.className = 'detail empty';
|
|
96
|
+
paragraph.setAttribute('role', 'status');
|
|
97
|
+
paragraph.textContent = text;
|
|
98
|
+
container.replaceChildren(paragraph);
|
|
99
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
|
|
2
|
+
import type { Directory, Metrics, Navigation } from './viewer-inspection.js';
|
|
3
|
+
export interface SelectionCounts {
|
|
4
|
+
/** Files a plugin read, and lockfiles, among the selected ones. */
|
|
5
|
+
readonly analysed: number;
|
|
6
|
+
readonly lockfiles: number;
|
|
7
|
+
/** How the selection reads against its folder, where a query narrowed it. */
|
|
8
|
+
readonly selection?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** The totals of a folder, or of the files a query selected in it. */
|
|
11
|
+
export declare function directorySummary(entry: Directory, { analysed, lockfiles, selection }: SelectionCounts): HTMLElement;
|
|
12
|
+
export interface SourceHooks {
|
|
13
|
+
/** Brings a line of the open source into view. */
|
|
14
|
+
readonly reveal?: (line: number) => void;
|
|
15
|
+
/** The loaded source text, which names anonymous functions by their first line. */
|
|
16
|
+
readonly text?: string;
|
|
17
|
+
}
|
|
18
|
+
/** An open file's figures, the links to what it was charged with, and its functions. */
|
|
19
|
+
export declare function fileDetails(details: InspectionDetails, entry: Metrics, navigation: Navigation, hooks?: SourceHooks): HTMLElement;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { basename, count, element, fact, link, parentPath, quantity } from './viewer-dom.js';
|
|
2
|
+
import { coverageContext, coverageRatio, coverageText, duplicationContext, duplicationText, effortText } from './viewer-file-figures.js';
|
|
3
|
+
import { lockfilesLabel } from './viewer-languages.js';
|
|
4
|
+
import { coverageKinds, localValue, measured, measuredFileMetrics } from './viewer-inspection.js';
|
|
5
|
+
import { atPath } from './viewer-locations.js';
|
|
6
|
+
import { format } from './viewer-metric-format.js';
|
|
7
|
+
import { labelOf, size } from './viewer-metrics.js';
|
|
8
|
+
import { lineSnippet } from './viewer-source-view.js';
|
|
9
|
+
import { highlightCode } from './viewer-tokenizer.js';
|
|
10
|
+
/** A fact where the inspection took the measurement; a measurement it did not take leaves no row behind. */
|
|
11
|
+
function factIf(shown, label, value, context) {
|
|
12
|
+
return shown ? [fact(label, value, context)] : [];
|
|
13
|
+
}
|
|
14
|
+
function panel(label, title, className = 'fx-aside') {
|
|
15
|
+
const aside = element('aside', className);
|
|
16
|
+
aside.setAttribute('aria-label', label);
|
|
17
|
+
const heading = element('div', 'fx-aside-heading');
|
|
18
|
+
heading.append(element('h2', '', title));
|
|
19
|
+
return { panel: aside, heading };
|
|
20
|
+
}
|
|
21
|
+
/** The totals of a folder, or of the files a query selected in it. */
|
|
22
|
+
export function directorySummary(entry, { analysed, lockfiles, selection }) {
|
|
23
|
+
const { panel: aside, heading } = panel(selection ? 'Selection totals' : 'Folder totals', selection ? 'Selection' : basename(entry.path) || 'All files');
|
|
24
|
+
// The breadcrumbs above name the folder; only a selection needs its words here.
|
|
25
|
+
if (selection)
|
|
26
|
+
heading.append(element('p', 'fx-aside-path fx-aside-selection', selection));
|
|
27
|
+
const facts = element('dl', 'fx-kv');
|
|
28
|
+
const quality = entry.quality;
|
|
29
|
+
const partial = analysed !== entry.files;
|
|
30
|
+
facts.append(
|
|
31
|
+
// Every tracked file counts here; Trends counts the analysed ones, so both say which they are.
|
|
32
|
+
fact('Tracked files', count(entry.files)), ...factIf(partial, labelOf('files'), count(analysed)), ...factIf(lockfiles > 0, lockfilesLabel, count(lockfiles)), ...factIf(quality?.codeLines !== undefined, labelOf('code-lines'), count(quality?.codeLines)),
|
|
33
|
+
// Physical lines are what the language bar weighs once some files are ignored, so its total stands here too.
|
|
34
|
+
...factIf(quality?.codeLines === undefined || partial, labelOf('lines'), count(entry.lines)), ...factIf(entry.bytes !== undefined, 'Size', size(entry.bytes)), ...factIf(entry.functions !== null, labelOf('functions'), count(entry.functions)), fact(labelOf('complexity'), count(entry.complexity?.maximum)), ...factIf(quality?.cognitiveComplexity !== undefined, labelOf('cognitive'), count(quality?.cognitiveComplexity)), ...factIf(quality?.duplication !== undefined, labelOf('duplication'), duplicationText(entry)), ...factIf(quality?.maintainability !== undefined, labelOf('effort'), effortText(quality?.maintainability?.effortMinutes)), ...factIf(coverageRatio(entry) !== null, labelOf('coverage'), coverageText(entry)),
|
|
35
|
+
// Other plugins' totals follow Repometry's own, where this inspection ran them and they roll up; the counts behind
|
|
36
|
+
// a ratio read through it.
|
|
37
|
+
...measuredFileMetrics().filter(spec => spec.descriptor.aggregate !== 'none' && !spec.ratioPart)
|
|
38
|
+
.map(spec => fact(spec.short, format(spec, localValue(entry, spec)))));
|
|
39
|
+
aside.append(heading, facts);
|
|
40
|
+
return aside;
|
|
41
|
+
}
|
|
42
|
+
function fileFacts(details, entry) {
|
|
43
|
+
const facts = element('dl', 'fx-kv');
|
|
44
|
+
const quality = entry.quality;
|
|
45
|
+
const window = details.metrics.churnWindow;
|
|
46
|
+
const kinds = coverageKinds().flatMap(spec => {
|
|
47
|
+
const value = measured(spec.descriptor) ? localValue(entry, spec) : null;
|
|
48
|
+
return value === null ? [] : [fact(spec.short, format(spec, value))];
|
|
49
|
+
});
|
|
50
|
+
facts.append(...factIf(quality?.codeLines !== undefined, labelOf('code-lines'), count(quality?.codeLines)), fact(labelOf('lines'), count(entry.lines)), ...factIf(entry.bytes !== undefined, 'Size', size(entry.bytes)), ...factIf(quality?.commentLines !== undefined, labelOf('comments'), count(quality?.commentLines)), fact(labelOf('functions'), count(entry.functions)), ...factIf(Boolean(quality?.classes), labelOf('classes'), count(quality?.classes)), fact(labelOf('complexity'), count(entry.complexity?.maximum)), ...factIf(quality?.cognitiveComplexity !== undefined, labelOf('cognitive'), count(quality?.cognitiveComplexity)), fact(labelOf('coverage'), coverageText(entry), coverageContext(entry)), ...kinds, ...factIf(Boolean(quality?.duplication), labelOf('duplication'), duplicationText(entry), duplicationContext(entry)), ...factIf(Boolean(quality?.maintainability), labelOf('effort'), effortText(quality?.maintainability?.effortMinutes)), ...factIf(quality?.churn !== undefined, 'Git changes', count(quality?.churn), window ? `${count(window.lookbackDays)}-day window` : undefined));
|
|
51
|
+
return facts;
|
|
52
|
+
}
|
|
53
|
+
/** Links to the file's findings and diagnostics, where it has some. */
|
|
54
|
+
function fileLinks(details, entry, navigation) {
|
|
55
|
+
const findings = details.findings?.filter(item => atPath(item, entry.path)).length ?? 0;
|
|
56
|
+
const links = element('p', 'fx-aside-links');
|
|
57
|
+
if (findings)
|
|
58
|
+
links.append(link(navigation.href('issues', { file: entry.path }), quantity(findings, 'finding'), 'fx-inline-link'));
|
|
59
|
+
if (entry.diagnosticCount)
|
|
60
|
+
links.append(link(navigation.href('diagnostics', { file: entry.path }), quantity(entry.diagnosticCount, 'diagnostic'), 'fx-inline-link'));
|
|
61
|
+
return links.childElementCount ? [links] : [];
|
|
62
|
+
}
|
|
63
|
+
/** The side column has room for the functions, most complex first; a long file folds the rest away. */
|
|
64
|
+
function functionSection(details, path, hooks) {
|
|
65
|
+
const functions = details.functions.filter(record => record.path === path).sort((a, b) => b.complexity - a.complexity);
|
|
66
|
+
if (!functions.length)
|
|
67
|
+
return [];
|
|
68
|
+
const list = (records) => hooks.reveal ? sourceFunctionList(records, hooks.reveal, hooks.text) : functionList(records);
|
|
69
|
+
const section = element('section', 'fx-aside-section');
|
|
70
|
+
section.append(element('h3', '', 'Functions by complexity'), list(functions.slice(0, 10)));
|
|
71
|
+
if (functions.length > 10) {
|
|
72
|
+
const rest = element('details', 'fx-functions');
|
|
73
|
+
rest.append(element('summary', '', `${functions.length - 10} more`), list(functions.slice(10)));
|
|
74
|
+
section.append(rest);
|
|
75
|
+
}
|
|
76
|
+
return [section];
|
|
77
|
+
}
|
|
78
|
+
/** An open file's figures, the links to what it was charged with, and its functions. */
|
|
79
|
+
export function fileDetails(details, entry, navigation, hooks = {}) {
|
|
80
|
+
// The breadcrumbs above name the folder, so the title is the file alone.
|
|
81
|
+
const { panel: aside, heading } = panel('File details', basename(entry.path), 'fx-aside fx-file');
|
|
82
|
+
const close = link(navigation.href('metrics', { directory: parentPath(entry.path) }), '', 'fx-close');
|
|
83
|
+
close.setAttribute('aria-label', 'Close file details');
|
|
84
|
+
close.title = 'Close file details';
|
|
85
|
+
heading.append(close);
|
|
86
|
+
aside.append(heading, fileFacts(details, entry), ...fileLinks(details, entry, navigation), ...functionSection(details, entry.path, hooks));
|
|
87
|
+
return aside;
|
|
88
|
+
}
|
|
89
|
+
/** Functions as buttons that bring their first line into view; an anonymous one is named by that line's code. */
|
|
90
|
+
function sourceFunctionList(functions, reveal, text) {
|
|
91
|
+
const list = element('ol', 'fx-function-list fx-function-jumps');
|
|
92
|
+
list.append(...functions.map(record => {
|
|
93
|
+
const row = element('li');
|
|
94
|
+
const anonymous = record.name === '(anonymous)' && Boolean(text) && record.line !== null;
|
|
95
|
+
const snippet = anonymous ? lineSnippet(text, record.line) : null;
|
|
96
|
+
const button = element('button', 'fx-function-jump');
|
|
97
|
+
button.type = 'button';
|
|
98
|
+
button.disabled = record.line === null;
|
|
99
|
+
const name = element(snippet ? 'code' : 'span', 'fx-function-name');
|
|
100
|
+
if (snippet)
|
|
101
|
+
name.append(...highlightCode(record.path, snippet));
|
|
102
|
+
else
|
|
103
|
+
name.textContent = record.name;
|
|
104
|
+
button.append(name);
|
|
105
|
+
if (record.line !== null)
|
|
106
|
+
button.append(element('span', 'fx-function-line', `${record.line}`));
|
|
107
|
+
button.addEventListener('click', () => { if (record.line !== null)
|
|
108
|
+
reveal(record.line); });
|
|
109
|
+
row.append(button, element('strong', 'fx-function-score', count(record.complexity)));
|
|
110
|
+
return row;
|
|
111
|
+
}));
|
|
112
|
+
return list;
|
|
113
|
+
}
|
|
114
|
+
function functionList(functions) {
|
|
115
|
+
const list = element('ol', 'fx-function-list');
|
|
116
|
+
list.append(...functions.map(record => {
|
|
117
|
+
const row = element('li');
|
|
118
|
+
const subject = element('div');
|
|
119
|
+
subject.append(element('strong', '', record.line === null ? record.name : `${record.name} · line ${record.line}`));
|
|
120
|
+
row.append(subject, element('strong', 'fx-function-score', count(record.complexity)));
|
|
121
|
+
return row;
|
|
122
|
+
}));
|
|
123
|
+
return list;
|
|
124
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HotspotMetric, Metrics, Navigation } from './viewer-inspection.js';
|
|
2
|
+
/** How a file's or a folder's figures read: ratios as percentages, a dash for what was not measured. */
|
|
3
|
+
export declare function coverageRatio(entry: Metrics): number | null;
|
|
4
|
+
export declare function coverageText(entry: Metrics): string;
|
|
5
|
+
export declare function coverageContext(entry: Metrics): string | undefined;
|
|
6
|
+
export declare function duplicationRatio(entry: Metrics): number | null;
|
|
7
|
+
export declare function duplicationText(entry: Metrics): string;
|
|
8
|
+
export declare function duplicationContext(entry: Metrics): string | undefined;
|
|
9
|
+
/** Remediation time, or a dash where maintainability was not measured. */
|
|
10
|
+
export declare function effortText(minutes: number | null | undefined): string;
|
|
11
|
+
/** What a file scores on the metric the code map and the ranking show; null where it was not measured. */
|
|
12
|
+
export declare function hotspotScore(entry: Metrics, metric: HotspotMetric): number | null;
|
|
13
|
+
/** Orders two entries by a column, unmeasured last whichever way the column sorts, and by path between equals. */
|
|
14
|
+
export declare function compareEntries(a: Metrics, b: Metrics, measurement: (row: Metrics) => string | number | null, ascending: boolean): number;
|
|
15
|
+
export declare function fileHref(navigation: Pick<Navigation, 'href'>, file: string): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { collator, count, parentPath, percent } from './viewer-dom.js';
|
|
2
|
+
import { localValue } from './viewer-inspection.js';
|
|
3
|
+
import { duration, pluginSpec } from './viewer-metrics.js';
|
|
4
|
+
/** How a file's or a folder's figures read: ratios as percentages, a dash for what was not measured. */
|
|
5
|
+
export function coverageRatio(entry) {
|
|
6
|
+
const coverage = entry.lineCoverage;
|
|
7
|
+
return coverage && coverage.total > 0 ? coverage.covered / coverage.total : null;
|
|
8
|
+
}
|
|
9
|
+
export function coverageText(entry) {
|
|
10
|
+
return ratioText(coverageRatio(entry));
|
|
11
|
+
}
|
|
12
|
+
export function coverageContext(entry) {
|
|
13
|
+
const value = entry.lineCoverage;
|
|
14
|
+
return value && value.total > 0 ? `${count(value.covered)} of ${count(value.total)} lines` : undefined;
|
|
15
|
+
}
|
|
16
|
+
export function duplicationRatio(entry) {
|
|
17
|
+
const value = entry.quality?.duplication;
|
|
18
|
+
return value && value.codeLines > 0 ? value.duplicatedLines / value.codeLines : null;
|
|
19
|
+
}
|
|
20
|
+
export function duplicationText(entry) {
|
|
21
|
+
return ratioText(duplicationRatio(entry));
|
|
22
|
+
}
|
|
23
|
+
export function duplicationContext(entry) {
|
|
24
|
+
const value = entry.quality?.duplication;
|
|
25
|
+
return value && value.codeLines > 0 ? `${count(value.duplicatedLines)} of ${count(value.codeLines)} code lines` : undefined;
|
|
26
|
+
}
|
|
27
|
+
function ratioText(value) {
|
|
28
|
+
return value === null ? '—' : percent(value);
|
|
29
|
+
}
|
|
30
|
+
/** Remediation time, or a dash where maintainability was not measured. */
|
|
31
|
+
export function effortText(minutes) {
|
|
32
|
+
return minutes == null ? '—' : duration(minutes);
|
|
33
|
+
}
|
|
34
|
+
const builtinScores = {
|
|
35
|
+
complexity: entry => entry.complexity?.maximum,
|
|
36
|
+
cognitive: entry => entry.quality?.cognitiveComplexity,
|
|
37
|
+
duplication: entry => entry.quality?.duplication?.duplicatedLines,
|
|
38
|
+
churn: entry => entry.quality?.churn,
|
|
39
|
+
missedLines: entry => entry.lineCoverage && entry.lineCoverage.total > 0 ? entry.lineCoverage.total - entry.lineCoverage.covered : null,
|
|
40
|
+
};
|
|
41
|
+
/** What a file scores on the metric the code map and the ranking show; null where it was not measured. */
|
|
42
|
+
export function hotspotScore(entry, metric) {
|
|
43
|
+
const plugin = pluginSpec(metric);
|
|
44
|
+
if (plugin)
|
|
45
|
+
return localValue(entry, plugin);
|
|
46
|
+
// A name that is neither a plugin's nor one of the rankings reads as uncovered lines, the last of them.
|
|
47
|
+
return (builtinScores[metric] ?? builtinScores.missedLines)(entry) ?? null;
|
|
48
|
+
}
|
|
49
|
+
/** Orders two entries by a column, unmeasured last whichever way the column sorts, and by path between equals. */
|
|
50
|
+
export function compareEntries(a, b, measurement, ascending) {
|
|
51
|
+
const left = measurement(a);
|
|
52
|
+
const right = measurement(b);
|
|
53
|
+
if (left === null || right === null)
|
|
54
|
+
return Number(left === null) - Number(right === null) || collator.compare(a.path, b.path);
|
|
55
|
+
const difference = typeof left === 'number' && typeof right === 'number' ? left - right : collator.compare(String(left), String(right));
|
|
56
|
+
return (ascending ? difference : -difference) || collator.compare(a.path, b.path);
|
|
57
|
+
}
|
|
58
|
+
export function fileHref(navigation, file) {
|
|
59
|
+
return navigation.href('metrics', { directory: parentPath(file), file });
|
|
60
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
|
|
2
|
+
import type { Metrics, Navigation } from './viewer-inspection.js';
|
|
3
|
+
/**
|
|
4
|
+
* An open file: its source with the inspection laid on its lines, and its figures and functions beside it. The
|
|
5
|
+
* functions lead into the code, and a chosen line goes into the URL so the place can be shared.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fileView(details: InspectionDetails, navigation: Navigation, file: Metrics, load: (path: string) => Promise<string | null>): HTMLElement;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { segmented } from './viewer-controls.js';
|
|
2
|
+
import { copyPathButton } from './viewer-copy.js';
|
|
3
|
+
import { basename, count, element, externalLink, parentPath, store, stored } from './viewer-dom.js';
|
|
4
|
+
import { fileDetails } from './viewer-file-aside.js';
|
|
5
|
+
import { languageColor, languageOf } from './viewer-languages.js';
|
|
6
|
+
import { breadcrumbs, splitter } from './viewer-layout.js';
|
|
7
|
+
import { lineIn } from './viewer-locations.js';
|
|
8
|
+
import { isSourceLayer, lineReadings, setSourceLayer } from './viewer-line-coverage.js';
|
|
9
|
+
import { renderSource } from './viewer-source-view.js';
|
|
10
|
+
/** A file's line coverage, where the inspection's coverage report names the file. */
|
|
11
|
+
function fileCoverage(details, path) {
|
|
12
|
+
const coverage = details.lineCoverage;
|
|
13
|
+
return coverage && Object.hasOwn(coverage, path) ? coverage[path] : undefined;
|
|
14
|
+
}
|
|
15
|
+
const layerKey = 'repometry.source-layer';
|
|
16
|
+
/** The URL's choice of what lines show, else the one made earlier in this session, else the findings. */
|
|
17
|
+
function sourceLayer(requested) {
|
|
18
|
+
if (isSourceLayer(requested))
|
|
19
|
+
return requested;
|
|
20
|
+
const remembered = stored(() => sessionStorage, layerKey);
|
|
21
|
+
return isSourceLayer(remembered) ? remembered : 'issues';
|
|
22
|
+
}
|
|
23
|
+
/** The file's name with its full path a click away; a refused clipboard shows the path in the name's place, selected. */
|
|
24
|
+
function sourceName(path) {
|
|
25
|
+
// The folder is in the breadcrumbs right above; the head names the file alone, with its full path on hover.
|
|
26
|
+
const name = element('code', 'fx-source-path', basename(path));
|
|
27
|
+
name.title = path;
|
|
28
|
+
const named = element('span', 'fx-source-name');
|
|
29
|
+
named.append(name, copyPathButton(path, () => {
|
|
30
|
+
name.textContent = path;
|
|
31
|
+
return name;
|
|
32
|
+
}));
|
|
33
|
+
return named;
|
|
34
|
+
}
|
|
35
|
+
function sourceMeta(file) {
|
|
36
|
+
const language = languageOf(file.path);
|
|
37
|
+
const dot = element('span', 'fx-language-dot');
|
|
38
|
+
dot.style.background = languageColor(language);
|
|
39
|
+
const meta = element('span', 'fx-source-meta');
|
|
40
|
+
meta.append(dot, `${language} · ${count(file.lines)} lines`);
|
|
41
|
+
return meta;
|
|
42
|
+
}
|
|
43
|
+
/** The findings that mark the file's lines, at their place in it. */
|
|
44
|
+
function sourceNotes(details, path) {
|
|
45
|
+
return (details.findings ?? []).flatMap(finding => {
|
|
46
|
+
const line = lineIn(finding, path);
|
|
47
|
+
return line ? [{ line, level: finding.level, title: finding.rule, message: finding.message }] : [];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* An open file: its source with the inspection laid on its lines, and its figures and functions beside it. The
|
|
52
|
+
* functions lead into the code, and a chosen line goes into the URL so the place can be shared.
|
|
53
|
+
*/
|
|
54
|
+
export function fileView(details, navigation, file, load) {
|
|
55
|
+
const view = element('div', 'fx-view');
|
|
56
|
+
const keep = { query: navigation.query ?? '', group: navigation.group ?? '' };
|
|
57
|
+
const nav = { ...navigation,
|
|
58
|
+
href: (target, options) => target === 'metrics' ? navigation.href('metrics', { ...keep, ...options }) : navigation.href(target, options) };
|
|
59
|
+
view.append(breadcrumbs('metrics', nav, parentPath(file.path)));
|
|
60
|
+
const split = element('div', 'fx-split fx-split-source');
|
|
61
|
+
const main = element('section', 'fx-source panel');
|
|
62
|
+
main.setAttribute('aria-label', 'Source');
|
|
63
|
+
const head = element('div', 'fx-source-head');
|
|
64
|
+
const meta = sourceMeta(file);
|
|
65
|
+
// Lines show the findings, or the tests' coverage where the file has it; without coverage the head stays as it was.
|
|
66
|
+
const coverage = fileCoverage(details, file.path);
|
|
67
|
+
let layer = coverage ? sourceLayer(navigation.layer) : 'issues';
|
|
68
|
+
let line = navigation.line;
|
|
69
|
+
const place = () => nav.href('metrics', { directory: parentPath(file.path), file: file.path, ...line ? { line } : {},
|
|
70
|
+
...layer === 'coverage' ? { layer } : {} });
|
|
71
|
+
const body = element('div', 'fx-source-body');
|
|
72
|
+
const toggle = coverage ? segmented('Lines show', [['issues', 'Issues'], ['coverage', 'Coverage']], layer, value => {
|
|
73
|
+
layer = value;
|
|
74
|
+
store(() => sessionStorage, layerKey, layer);
|
|
75
|
+
setSourceLayer(body, layer);
|
|
76
|
+
history.replaceState(history.state, '', place());
|
|
77
|
+
}) : null;
|
|
78
|
+
toggle?.classList.add('fx-source-layer');
|
|
79
|
+
const tools = element('div', 'fx-source-tools');
|
|
80
|
+
tools.append(...toggle ? [toggle] : [], meta);
|
|
81
|
+
head.append(sourceName(file.path), tools);
|
|
82
|
+
// The forge's page for the file, at the chosen line, whether or not the text opens here.
|
|
83
|
+
const page = navigation.sourcePage?.(file.path, navigation.line);
|
|
84
|
+
const forge = page ? externalLink(page.href, `View on ${page.provider}`, 'fx-source-forge') : null;
|
|
85
|
+
if (forge)
|
|
86
|
+
meta.append(' · ', forge);
|
|
87
|
+
body.append(element('p', 'fx-note fx-source-wait', 'Loading source…'));
|
|
88
|
+
main.append(head, body);
|
|
89
|
+
let aside = fileDetails(details, file, nav);
|
|
90
|
+
split.append(main, splitter(split), aside);
|
|
91
|
+
view.append(split);
|
|
92
|
+
const functions = details.functions.filter(record => record.path === file.path);
|
|
93
|
+
const choose = (chosen) => {
|
|
94
|
+
line = chosen;
|
|
95
|
+
history.replaceState(history.state, '', place());
|
|
96
|
+
const moved = navigation.sourcePage?.(file.path, chosen);
|
|
97
|
+
if (forge && moved)
|
|
98
|
+
forge.href = moved.href;
|
|
99
|
+
};
|
|
100
|
+
void load(file.path).then(text => {
|
|
101
|
+
if (text === null) {
|
|
102
|
+
// No locator, a private repository, a commit never pushed: one quiet state, and the forge's page when there is one.
|
|
103
|
+
body.replaceChildren(element('p', 'fx-source-missing', 'Source not available'));
|
|
104
|
+
// Nothing to shade: the head is the one a file without coverage has.
|
|
105
|
+
toggle?.remove();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const reveal = renderSource(body, text, {
|
|
109
|
+
path: file.path,
|
|
110
|
+
functions: functions.flatMap(record => record.line === null ? [] : [{ line: record.line, complexity: record.complexity, name: record.name }]),
|
|
111
|
+
notes: sourceNotes(details, file.path), line: navigation.line, choose,
|
|
112
|
+
coverage: coverage && lineReadings(coverage), layer,
|
|
113
|
+
});
|
|
114
|
+
const next = fileDetails(details, file, nav, { text, reveal: target => { reveal(target); choose(target); } });
|
|
115
|
+
aside.replaceWith(next);
|
|
116
|
+
aside = next;
|
|
117
|
+
});
|
|
118
|
+
return view;
|
|
119
|
+
}
|
|
@@ -1,46 +1,5 @@
|
|
|
1
|
-
import type { FileMetricsReport } from '../../json/wire/file-metrics-model.js';
|
|
2
1
|
import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
|
|
3
|
-
import type {
|
|
4
|
-
type View = 'metrics' | 'hotspots' | 'diagnostics' | 'issues';
|
|
5
|
-
type Metrics = FileMetricsReport['files'][number];
|
|
6
|
-
type BuiltinHotspot = keyof FileMetricsReport['hotspots'];
|
|
7
|
-
/** What the code map and the ranking measure: one of Repometry's rankings, or another plugin's metric by its key. */
|
|
8
|
-
export type HotspotMetric = BuiltinHotspot | PluginMetric;
|
|
9
|
-
interface Navigation {
|
|
10
|
-
readonly directory: string;
|
|
11
|
-
readonly file: string;
|
|
12
|
-
/** The Metrics query and grouping from the URL. */
|
|
13
|
-
readonly query?: string | undefined;
|
|
14
|
-
readonly group?: string | undefined;
|
|
15
|
-
/** A source line to bring into view. */
|
|
16
|
-
readonly line?: number | undefined;
|
|
17
|
-
/** The Issues filters from the URL: finding categories, comma-separated, and a severity. */
|
|
18
|
-
readonly category?: string | undefined;
|
|
19
|
-
readonly level?: string | undefined;
|
|
20
|
-
/** What Hotspots ranks by. */
|
|
21
|
-
readonly rank?: string | undefined;
|
|
22
|
-
/** What an open file's lines show: its findings (the default) or its coverage. */
|
|
23
|
-
readonly layer?: string | undefined;
|
|
24
|
-
/** Source text of a file at this commit; absent where the view cannot load source. */
|
|
25
|
-
readonly source?: ((path: string) => Promise<string | null>) | undefined;
|
|
26
|
-
/** The file's page on its forge, when the export names one. */
|
|
27
|
-
readonly sourcePage?: ((path: string, line?: number) => {
|
|
28
|
-
readonly href: string;
|
|
29
|
-
readonly provider: string;
|
|
30
|
-
} | null) | undefined;
|
|
31
|
-
href(view: View, options?: LinkOptions): string;
|
|
32
|
-
}
|
|
33
|
-
export interface LinkOptions {
|
|
34
|
-
readonly directory?: string;
|
|
35
|
-
readonly file?: string;
|
|
36
|
-
readonly query?: string;
|
|
37
|
-
readonly group?: string;
|
|
38
|
-
readonly line?: number;
|
|
39
|
-
readonly category?: string;
|
|
40
|
-
readonly level?: string;
|
|
41
|
-
readonly rank?: string;
|
|
42
|
-
readonly layer?: string;
|
|
43
|
-
}
|
|
2
|
+
import type { Navigation, View } from './viewer-inspection.js';
|
|
44
3
|
/**
|
|
45
4
|
* The finding categories Repometry counts as code smells, mirroring core's quality summary (structure and
|
|
46
5
|
* duplication), so the Overview's smell count links to exactly the findings it counts.
|
|
@@ -48,80 +7,5 @@ export interface LinkOptions {
|
|
|
48
7
|
export declare const codeSmellCategories: readonly ['structure', 'duplication'];
|
|
49
8
|
/** The finding categories behind the security level, as the Overview's security column counts them. */
|
|
50
9
|
export declare const securityCategories: readonly ['security', 'dependency', 'secret', 'infrastructure'];
|
|
10
|
+
/** The pages that read one inspection: Metrics (or an open file), Hotspots, Findings and Diagnostics. */
|
|
51
11
|
export declare function renderFileView(container: HTMLElement, view: View, details: InspectionDetails, navigation: Navigation): void;
|
|
52
|
-
/** The folders all of whose files are only counted, found in one pass over the files. */
|
|
53
|
-
export declare function unreadFolders(files: readonly Pick<Metrics, 'path' | 'analysed'>[]): Set<string>;
|
|
54
|
-
/**
|
|
55
|
-
* The entries a page shows, 1-based, counting rows and not the fold of ignored files, which takes a place in the list
|
|
56
|
-
* but is no entry of its own. None where the page holds only the fold.
|
|
57
|
-
*/
|
|
58
|
-
export declare function entryRange(display: readonly {
|
|
59
|
-
readonly kind: string;
|
|
60
|
-
}[], first: number, shown: number): [number, number] | null;
|
|
61
|
-
type MapShape = 'rings' | 'tiles';
|
|
62
|
-
interface SunburstOptions {
|
|
63
|
-
readonly metric: HotspotMetric;
|
|
64
|
-
readonly directory?: string;
|
|
65
|
-
readonly compact?: boolean;
|
|
66
|
-
/** Rings (a sunburst) or tiles (a treemap); the last choice is remembered for this viewer. */
|
|
67
|
-
readonly shape?: MapShape;
|
|
68
|
-
/** Offered beside the map's title, where the page lets the viewer switch shapes. */
|
|
69
|
-
readonly reshape?: (shape: MapShape) => void;
|
|
70
|
-
/** More controls for the map's title row, such as what it is coloured by. */
|
|
71
|
-
readonly controls?: HTMLElement;
|
|
72
|
-
/** Sizes only, in grey: the map stands for an area with no measurement of its own, as security without a scanner. */
|
|
73
|
-
readonly muted?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Security: each file's worst finding level, 0 none to 4 critical, coloured in the grade steps of the security mark.
|
|
76
|
-
* A folder takes the worst level inside it. Files missing from the map have no findings.
|
|
77
|
-
*/
|
|
78
|
-
readonly levels?: ReadonlyMap<string, number>;
|
|
79
|
-
href(view: 'hotspots' | 'metrics', options?: {
|
|
80
|
-
directory?: string;
|
|
81
|
-
file?: string;
|
|
82
|
-
}): string;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* The top of a relative colour scale, per level: files against files, folders against the folders at their depth. One
|
|
86
|
-
* scale for both would let a folder's sum outshine every file in it, and the map would read hot folders over pale files.
|
|
87
|
-
*/
|
|
88
|
-
export declare function relativePeaks(entries: readonly {
|
|
89
|
-
readonly path: string;
|
|
90
|
-
readonly folder: boolean;
|
|
91
|
-
readonly score: number;
|
|
92
|
-
}[]): (path: string, folder: boolean) => number;
|
|
93
|
-
export declare function renderSunburst(details: InspectionDetails, options: SunburstOptions): HTMLElement;
|
|
94
|
-
/**
|
|
95
|
-
* The handle between a list and its side panel: a line that shows on hover and drags the panel wider or narrower.
|
|
96
|
-
* Arrow keys move it too, a double click restores the default, and the width is remembered for this viewer.
|
|
97
|
-
*/
|
|
98
|
-
export declare function splitter(split: HTMLElement): HTMLElement;
|
|
99
|
-
/**
|
|
100
|
-
* The compact map's stand-in while the inspection loads: the same frame, switch and canvas size in a flat tone, so the
|
|
101
|
-
* column keeps its shape and the map fades in where it will stand.
|
|
102
|
-
*/
|
|
103
|
-
export declare function mapStub(): HTMLElement;
|
|
104
|
-
/** The profile's limits for a metric with a meaningful scale, when they are well formed; otherwise the defaults. */
|
|
105
|
-
export declare function bandLimits(details: Pick<InspectionDetails, 'bands'>, metric: HotspotMetric): readonly number[] | undefined;
|
|
106
|
-
export declare function band(entry: Metrics, metric: HotspotMetric, score: number, highest: number, limits?: readonly number[] | undefined): number;
|
|
107
|
-
/** Each file's worst level spread to the folders above it. */
|
|
108
|
-
export declare function spreadLevels(files: ReadonlyMap<string, number>): Map<string, number>;
|
|
109
|
-
/** The common copy glyph, two offset sheets, with the check it turns into once copied. */
|
|
110
|
-
export declare function copyIcon(): SVGSVGElement;
|
|
111
|
-
export declare function navigationButtons(label: string, previous: () => void, next: () => void): {
|
|
112
|
-
section: HTMLElement;
|
|
113
|
-
update: (page: number, pages: number) => void;
|
|
114
|
-
};
|
|
115
|
-
export declare function searchField(text: string, placeholder: string): {
|
|
116
|
-
label: HTMLLabelElement;
|
|
117
|
-
input: HTMLInputElement;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* A dropdown of checkboxes: none ticked means all. The button names what is chosen, so the filter reads at a glance;
|
|
121
|
-
* each option carries its count. It hides itself when there is nothing to choose between.
|
|
122
|
-
*/
|
|
123
|
-
export declare function multiChoice(text: string, all: string, plural: string, options: readonly (readonly [string, string, number])[], change: () => void, initial?: Iterable<string>): {
|
|
124
|
-
element: HTMLDetailsElement;
|
|
125
|
-
values: Set<string>;
|
|
126
|
-
};
|
|
127
|
-
export {};
|