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
|
@@ -1,73 +1,5 @@
|
|
|
1
|
-
import type { InspectionContext } from '../../json/wire/inspection-context-model.js';
|
|
2
|
-
import type { QualitySummary } from '../../json/wire/domain-types.js';
|
|
3
1
|
import type { PublicHistoryEntry } from '../../json/wire/public-history-model.js';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
export type TrendView = Metric | 'debt-changes' | 'diff-coverage';
|
|
7
|
-
export type Period = '30' | '100' | 'all';
|
|
8
|
-
export interface TrendData {
|
|
9
|
-
readonly reports: readonly PublicHistoryEntry[];
|
|
10
|
-
readonly quality: Record<string, QualitySummary>;
|
|
11
|
-
readonly context: Record<string, InspectionContext> | null;
|
|
12
|
-
readonly compact: boolean;
|
|
13
|
-
/** Link to the Trends page for a commit, keeping or replacing the view and period. */
|
|
14
|
-
readonly link: (sha: string, view?: TrendView, period?: Period) => string;
|
|
15
|
-
}
|
|
16
|
-
export declare function isTrendView(value: string | null | undefined): value is TrendView;
|
|
17
|
-
export declare function isPeriod(value: string | null | undefined): value is Period;
|
|
18
|
-
/** Views that have data in this history, in display order. */
|
|
19
|
-
export declare function availableViews(data: TrendData): TrendView[];
|
|
20
|
-
/** The whole curve by default; only a very long history opens on its last hundred inspections. */
|
|
21
|
-
export declare function defaultPeriod(total: number): Period;
|
|
22
|
-
/** The inspections shown for a period, oldest first, always including the selected one. */
|
|
23
|
-
export declare function windowOf(reports: readonly PublicHistoryEntry[], selected: PublicHistoryEntry, period: Period): PublicHistoryEntry[];
|
|
24
|
-
export interface Window {
|
|
25
|
-
readonly start: number;
|
|
26
|
-
readonly end: number;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The slice of history a chart shows, newest first by index. Picking a commit inside the current slice keeps it, so
|
|
30
|
-
* the axes and scale stay where the eye left them; only a commit outside it moves the slice, which then centres on
|
|
31
|
-
* that commit so its neighbours on both sides are in view. The newest commits are the default slice.
|
|
32
|
-
*/
|
|
33
|
-
export declare function stableWindow(reports: readonly PublicHistoryEntry[], index: number, size: number, key: string): Window;
|
|
34
|
-
/**
|
|
35
|
-
* The inspections a time chart can place: when the history has commit times, one without (a root commit has no churn
|
|
36
|
-
* window to read it from) cannot be put on the time axis, so it stays out of the chart and in the table.
|
|
37
|
-
*/
|
|
38
|
-
export declare function charted(shown: readonly PublicHistoryEntry[]): PublicHistoryEntry[];
|
|
39
|
-
/** Commit time of an inspection, or null for exports made before commit times were recorded. */
|
|
40
|
-
export declare function commitTime(report: PublicHistoryEntry): number | null;
|
|
41
|
-
export declare function seriesPoints(data: TrendData, shown: readonly PublicHistoryEntry[], metric: Metric, selected: string, link: (sha: string) => string): ChartPoint[];
|
|
42
|
-
/**
|
|
43
|
-
* Where the green and the red flag stand: the best and the worst value of the series, each at the inspection that
|
|
44
|
-
* first reached it, the way a flag is planted where a summit was reached. Neutral metrics get no flags, and neither
|
|
45
|
-
* does a series with fewer than three measurements or one that reads as unchanged from its best to its worst.
|
|
46
|
-
*
|
|
47
|
-
* The extremes are the raw minimum and maximum, as the line draws them: a tolerant "beats" is not transitive, and a
|
|
48
|
-
* first value within rounding of both ends used to hide them. A value reaches an extreme when it equals it up to
|
|
49
|
-
* floating-point noise, so a flag never stands beside a point the line shows lower or higher.
|
|
50
|
-
*/
|
|
51
|
-
export declare function plantFlags(values: readonly (number | null)[], metric: Metric): {
|
|
52
|
-
best: number | null;
|
|
53
|
-
worst: number | null;
|
|
54
|
-
};
|
|
55
|
-
/** Only what the chart cannot say by itself; empty when there is nothing to add. */
|
|
56
|
-
export declare function trendLegend(points: readonly ChartPoint[], data: TrendData): string;
|
|
2
|
+
import type { Period, TrendData, TrendView } from './viewer-trend-data.js';
|
|
3
|
+
export type { Period, TrendData, TrendView } from './viewer-trend-data.js';
|
|
57
4
|
/** Renders the whole page; returns the slot for the changed-line coverage history when that view is chosen. */
|
|
58
5
|
export declare function renderTrendsPage(container: HTMLElement, data: TrendData, selected: PublicHistoryEntry, requested: TrendView | undefined, requestedPeriod: Period | undefined): HTMLElement | null;
|
|
59
|
-
/** The measure drawn beside a series as a grey line on its own scale: the time behind the ratio, the lines behind the share. */
|
|
60
|
-
export declare const companions: Readonly<Partial<Record<Metric, Metric>>>;
|
|
61
|
-
export interface SeriesOptions {
|
|
62
|
-
readonly compact: boolean;
|
|
63
|
-
readonly height?: number | undefined;
|
|
64
|
-
readonly labelCurrent?: boolean;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* A series with its companion, as the Overview draws it: the series in ink on the left scale, the companion in grey on
|
|
68
|
-
* the right, and a key whose entries switch each line on and off. The last line shown cannot be switched off; with one
|
|
69
|
-
* left it takes the left scale. The choice is remembered for this viewer. Returns whether anything was drawn.
|
|
70
|
-
*/
|
|
71
|
-
export declare function renderSeries(chart: HTMLElement, key: HTMLElement, data: TrendData, shown: readonly PublicHistoryEntry[], metric: Metric, selected: string, link: (sha: string) => string, options: SeriesOptions): boolean;
|
|
72
|
-
/** Remediation time ticks in whole hours once the series reaches two hours. */
|
|
73
|
-
export declare function tickUnit(points: readonly ChartPoint[], metric: Metric): number;
|
|
@@ -1,169 +1,47 @@
|
|
|
1
|
-
import { renderBarChart
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { renderBarChart } from './viewer-chart.js';
|
|
2
|
+
import { element } from './viewer-dom.js';
|
|
3
|
+
import { splitter } from './viewer-layout.js';
|
|
4
|
+
import { definitionOf } from './viewer-metrics.js';
|
|
5
|
+
import { availableViews, charted, defaultPeriod, viewLabel, windowOf } from './viewer-trend-data.js';
|
|
6
|
+
import { periodControl, viewNavigation } from './viewer-trend-nav.js';
|
|
7
|
+
import { debtChanges, seriesPoints, signedDuration, tickUnit, trendLegend } from './viewer-trend-points.js';
|
|
8
|
+
import { renderSeries } from './viewer-trend-series.js';
|
|
9
|
+
const definitions = {
|
|
10
|
+
'debt-changes': 'Change in estimated remediation time from the previous inspection.',
|
|
11
|
+
'diff-coverage': 'Coverage of added lines in saved pull request reviews, against each review threshold.',
|
|
10
12
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
/** The series the page opens on: the one asked for, else technical debt, else the first this history has. */
|
|
14
|
+
function chosenView(views, requested) {
|
|
15
|
+
if (requested && views.includes(requested))
|
|
16
|
+
return requested;
|
|
17
|
+
return views.includes('debt') ? 'debt' : views[0] ?? 'code-lines';
|
|
18
|
+
}
|
|
19
|
+
/** Remediation time as one bar per inspection's change; returns the legend under the chart. */
|
|
20
|
+
function drawDebtChanges({ data, selected, shown, frame, link }) {
|
|
21
|
+
const bars = debtChanges(data, shown, selected.sha, link);
|
|
22
|
+
const chart = element('div', 'chart');
|
|
23
|
+
frame.append(chart);
|
|
24
|
+
renderBarChart(chart, bars, { format: signedDuration, compact: data.compact, upIsWorse: true, tickUnit: tickUnit(bars.map(bar => bar.value), 'effort') });
|
|
25
|
+
return trendLegend(bars);
|
|
13
26
|
}
|
|
14
|
-
const builtinGroups = [
|
|
15
|
-
['Maintainability', ['debt', 'debt-changes', 'duplication', 'cognitive', 'complexity', 'smells']],
|
|
16
|
-
// Branch and function coverage come from the registry, where the coverage report has them.
|
|
17
|
-
['Coverage', ['coverage', 'branch-coverage', 'function-coverage', 'diff-coverage']],
|
|
18
|
-
['Security', ['security']],
|
|
19
|
-
['Size', ['code-lines', 'files', 'functions', 'classes', 'comments']],
|
|
20
|
-
];
|
|
21
27
|
/**
|
|
22
|
-
* The
|
|
23
|
-
*
|
|
28
|
+
* The same chart as the Overview: the series, its companion in grey, and a key that switches either line. The title
|
|
29
|
+
* repeats the item chosen in the sidebar; the key under the chart names each line. Returns the legend under the chart.
|
|
24
30
|
*/
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
function drawSeries({ data, selected, shown, view, frame, link }) {
|
|
32
|
+
const chart = element('div', 'chart');
|
|
33
|
+
const key = element('p', 'trend-key');
|
|
34
|
+
frame.append(chart, key);
|
|
35
|
+
const metric = view;
|
|
36
|
+
if (!renderSeries({ chart, key, data, shown, metric, selected: selected.sha, link }, { compact: data.compact })) {
|
|
37
|
+
chart.append(element('p', 'detail empty', 'No measurements for this series in the shown inspections.'));
|
|
32
38
|
}
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
/** A view the registry names, not one the viewer draws by hand. */
|
|
36
|
-
function pluginKey(view) {
|
|
37
|
-
return view !== 'debt-changes' && view !== 'diff-coverage' && !(view in metricLabels);
|
|
38
|
-
}
|
|
39
|
-
export function isTrendView(value) {
|
|
40
|
-
return value === 'debt-changes' || value === 'diff-coverage' || (isMetric(value) && groups().some(([, views]) => views.includes(value)));
|
|
41
|
-
}
|
|
42
|
-
export function isPeriod(value) {
|
|
43
|
-
return value === '30' || value === '100' || value === 'all';
|
|
44
|
-
}
|
|
45
|
-
/** Views that have data in this history, in display order. */
|
|
46
|
-
export function availableViews(data) {
|
|
47
|
-
const has = (metric) => data.reports.some(report => value(data, report, metric) !== null);
|
|
48
|
-
return groups().flatMap(([, views]) => views).filter(view => view === 'diff-coverage' || (view === 'debt-changes' ? has('effort') : has(view)));
|
|
49
|
-
}
|
|
50
|
-
/** The whole curve by default; only a very long history opens on its last hundred inspections. */
|
|
51
|
-
export function defaultPeriod(total) {
|
|
52
|
-
return total <= 1000 ? 'all' : '100';
|
|
53
|
-
}
|
|
54
|
-
/** The inspections shown for a period, oldest first, always including the selected one. */
|
|
55
|
-
export function windowOf(reports, selected, period) {
|
|
56
|
-
const limit = period === 'all' ? reports.length : Number(period);
|
|
57
|
-
const { start, end } = stableWindow(reports, reports.indexOf(selected), limit, 'trends');
|
|
58
|
-
return reports.slice(start, end).reverse();
|
|
59
|
-
}
|
|
60
|
-
const windows = new Map();
|
|
61
|
-
/**
|
|
62
|
-
* The slice of history a chart shows, newest first by index. Picking a commit inside the current slice keeps it, so
|
|
63
|
-
* the axes and scale stay where the eye left them; only a commit outside it moves the slice, which then centres on
|
|
64
|
-
* that commit so its neighbours on both sides are in view. The newest commits are the default slice.
|
|
65
|
-
*/
|
|
66
|
-
export function stableWindow(reports, index, size, key) {
|
|
67
|
-
const total = reports.length;
|
|
68
|
-
const head = reports[0]?.sha;
|
|
69
|
-
const previous = windows.get(key);
|
|
70
|
-
let result;
|
|
71
|
-
if (previous && previous.size === size && previous.total === total && previous.head === head
|
|
72
|
-
&& index >= previous.start && index < previous.end)
|
|
73
|
-
result = { start: previous.start, end: previous.end };
|
|
74
|
-
else if (index < size)
|
|
75
|
-
result = { start: 0, end: Math.min(size, total) };
|
|
76
|
-
else {
|
|
77
|
-
const end = Math.min(total, Math.max(0, index - Math.floor(size / 2)) + size);
|
|
78
|
-
result = { start: Math.max(0, end - size), end };
|
|
79
|
-
}
|
|
80
|
-
windows.set(key, { ...result, size, total, head });
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* The inspections a time chart can place: when the history has commit times, one without (a root commit has no churn
|
|
85
|
-
* window to read it from) cannot be put on the time axis, so it stays out of the chart and in the table.
|
|
86
|
-
*/
|
|
87
|
-
export function charted(shown) {
|
|
88
|
-
const timed = shown.filter(report => commitTime(report) !== null);
|
|
89
|
-
return timed.length ? timed : [...shown];
|
|
90
|
-
}
|
|
91
|
-
/** Commit time of an inspection, or null for exports made before commit times were recorded. */
|
|
92
|
-
export function commitTime(report) {
|
|
93
|
-
const time = report.committedAt === undefined ? NaN : Date.parse(report.committedAt);
|
|
94
|
-
return Number.isFinite(time) ? time : null;
|
|
95
|
-
}
|
|
96
|
-
export function seriesPoints(data, shown, metric, selected, link) {
|
|
97
|
-
const points = shown.map(report => {
|
|
98
|
-
const measured = value(data, report, metric);
|
|
99
|
-
const previous = data.reports[data.reports.indexOf(report) + 1];
|
|
100
|
-
const before = previous ? value(data, previous, metric) : null;
|
|
101
|
-
const boundary = data.context?.[report.sha]?.boundary ?? null;
|
|
102
|
-
const change = boundary !== 'changed' && measured !== null && before !== null ? difference(measured, before, metric) : null;
|
|
103
|
-
return point(report, measured === null ? 'No measurement' : formatMetric(measured, metric), change, measured, selected, link, boundary);
|
|
104
|
-
});
|
|
105
|
-
const flags = plantFlags(points.map(entry => entry.value), metric);
|
|
106
|
-
return points.map((entry, index) => flags.best === index ? { ...entry, flag: 'best' }
|
|
107
|
-
: flags.worst === index ? { ...entry, flag: 'worst' } : entry);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Where the green and the red flag stand: the best and the worst value of the series, each at the inspection that
|
|
111
|
-
* first reached it, the way a flag is planted where a summit was reached. Neutral metrics get no flags, and neither
|
|
112
|
-
* does a series with fewer than three measurements or one that reads as unchanged from its best to its worst.
|
|
113
|
-
*
|
|
114
|
-
* The extremes are the raw minimum and maximum, as the line draws them: a tolerant "beats" is not transitive, and a
|
|
115
|
-
* first value within rounding of both ends used to hide them. A value reaches an extreme when it equals it up to
|
|
116
|
-
* floating-point noise, so a flag never stands beside a point the line shows lower or higher.
|
|
117
|
-
*/
|
|
118
|
-
export function plantFlags(values, metric) {
|
|
119
|
-
const none = { best: null, worst: null };
|
|
120
|
-
const better = betterOf(metric);
|
|
121
|
-
if (better === 'none')
|
|
122
|
-
return none;
|
|
123
|
-
const measured = values.flatMap((entry, index) => entry === null ? [] : [index]);
|
|
124
|
-
if (measured.length < 3)
|
|
125
|
-
return none;
|
|
126
|
-
const raw = measured.map(index => values[index]);
|
|
127
|
-
const lowest = Math.min(...raw);
|
|
128
|
-
const highest = Math.max(...raw);
|
|
129
|
-
const [bestValue, worstValue] = better === 'lower' ? [lowest, highest] : [highest, lowest];
|
|
130
|
-
if (difference(bestValue, worstValue, metric).direction === 'same')
|
|
131
|
-
return none;
|
|
132
|
-
const reached = (target) => measured.find(index => Math.abs(values[index] - target) <= 1e-9 * Math.max(1, Math.abs(target)));
|
|
133
|
-
const best = reached(bestValue);
|
|
134
|
-
const worst = reached(worstValue);
|
|
135
|
-
return best === worst ? none : { best, worst };
|
|
136
|
-
}
|
|
137
|
-
function point(report, shownValue, change, measured, selected, link, boundary) {
|
|
138
|
-
const time = commitTime(report);
|
|
139
|
-
const inspectedAt = Date.parse(report.generatedAt);
|
|
140
|
-
const when = time !== null ? dateTime.format(time) : Number.isFinite(inspectedAt) ? `Inspected ${dateTime.format(inspectedAt)}` : 'Date unavailable';
|
|
141
|
-
const notes = report.status === 'partial' ? ['Partial inspection'] : [];
|
|
142
|
-
if (boundary)
|
|
143
|
-
notes.push(boundary === 'changed' ? 'Inspection profile changed' : 'Profile comparison unavailable');
|
|
144
|
-
return {
|
|
145
|
-
value: measured, time, boundary,
|
|
146
|
-
label: Number.isFinite(time ?? inspectedAt) ? shortDate.format(time ?? inspectedAt) : report.sha.slice(0, 7),
|
|
147
|
-
title: `${report.sha.slice(0, 7)}, ${when}: ${shownValue}${change && change.direction !== 'same' ? `, ${change.text}` : ''}`,
|
|
148
|
-
tip: { heading: when, commit: report.sha.slice(0, 7), ...(report.subject ? { subject: report.subject } : {}), value: shownValue, change, notes },
|
|
149
|
-
href: link(report.sha),
|
|
150
|
-
current: report.sha === selected,
|
|
151
|
-
partial: report.status === 'partial',
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
/** Only what the chart cannot say by itself; empty when there is nothing to add. */
|
|
155
|
-
export function trendLegend(points, data) {
|
|
156
|
-
const parts = [
|
|
157
|
-
points.some(point => point.partial && point.value !== null) ? 'Dashed dots mark partial inspections' : '',
|
|
158
|
-
points.some(point => point.boundary === 'changed') ? 'Dashed lines mark profile changes' : '',
|
|
159
|
-
points.some(point => point.boundary === 'unavailable') ? 'Dotted lines mark missing profile information' : '',
|
|
160
|
-
].filter(Boolean);
|
|
161
|
-
return parts.length ? `${parts.join('. ')}.` : '';
|
|
39
|
+
return trendLegend(seriesPoints(data, shown, metric, selected.sha, link));
|
|
162
40
|
}
|
|
163
41
|
/** Renders the whole page; returns the slot for the changed-line coverage history when that view is chosen. */
|
|
164
42
|
export function renderTrendsPage(container, data, selected, requested, requestedPeriod) {
|
|
165
43
|
const views = availableViews(data);
|
|
166
|
-
const view =
|
|
44
|
+
const view = chosenView(views, requested);
|
|
167
45
|
const period = requestedPeriod ?? defaultPeriod(data.reports.length);
|
|
168
46
|
const shown = charted(windowOf(data.reports, selected, period));
|
|
169
47
|
const link = (sha) => data.link(sha, view, period);
|
|
@@ -173,11 +51,7 @@ export function renderTrendsPage(container, data, selected, requested, requested
|
|
|
173
51
|
layout.append(main, splitter(layout), viewNavigation(data, views, view, selected, period));
|
|
174
52
|
const head = element('div', 'trend-head');
|
|
175
53
|
const heading = element('div');
|
|
176
|
-
|
|
177
|
-
const definition = element('p', 'detail', view === 'debt-changes' ? 'Change in estimated remediation time from the previous inspection.'
|
|
178
|
-
: view === 'diff-coverage' ? 'Coverage of added lines in saved pull request reviews, against each review threshold.'
|
|
179
|
-
: definitionOf(view));
|
|
180
|
-
heading.append(headline);
|
|
54
|
+
heading.append(element('h2', 'trend-headline', viewLabel(view)));
|
|
181
55
|
head.append(heading);
|
|
182
56
|
// The title stands above the frame; the frame holds the period, the chart, its key, and what the series means.
|
|
183
57
|
const frame = element('div', 'trend-frame panel');
|
|
@@ -185,239 +59,14 @@ export function renderTrendsPage(container, data, selected, requested, requested
|
|
|
185
59
|
tools.append(periodControl(data, selected.sha, view, period));
|
|
186
60
|
frame.append(tools);
|
|
187
61
|
main.append(head, frame);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
headline.textContent = viewLabel('diff-coverage');
|
|
192
|
-
slot = element('div', 'trend-slot');
|
|
62
|
+
const page = { data, selected, shown, view, frame, link };
|
|
63
|
+
const slot = view === 'diff-coverage' ? element('div', 'trend-slot') : null;
|
|
64
|
+
if (slot)
|
|
193
65
|
frame.append(slot);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const effort = seriesPoints(data, shown, 'effort', selected.sha, link);
|
|
197
|
-
const bars = effort.map((point, index) => {
|
|
198
|
-
// The first shown inspection compares with the one just before the window, when there is one.
|
|
199
|
-
const report = shown[index];
|
|
200
|
-
const previous = data.reports[data.reports.indexOf(report) + 1];
|
|
201
|
-
const before = previous ? value(data, previous, 'effort') : null;
|
|
202
|
-
const change = point.boundary !== 'changed' && point.value !== null && before !== null ? point.value - before : null;
|
|
203
|
-
const reason = !previous ? 'First inspection' : point.boundary === 'changed' ? 'Profile changed' : 'Not measured before';
|
|
204
|
-
const total = point.value === null ? 'No measurement' : `${formatMetric(point.value, 'effort')} in total`;
|
|
205
|
-
const shownChange = change === null ? reason : signedDuration(change);
|
|
206
|
-
// Flags mark the best and worst total; the bars show per-inspection changes, so they carry none.
|
|
207
|
-
return { ...point, value: change, flag: undefined,
|
|
208
|
-
title: `${report.sha.slice(0, 7)}, ${point.tip.heading}: ${shownChange}`,
|
|
209
|
-
tip: { ...point.tip, value: shownChange, change: null, notes: [total, ...point.tip.notes] } };
|
|
210
|
-
});
|
|
211
|
-
headline.textContent = viewLabel('debt-changes');
|
|
212
|
-
const chart = element('div', 'chart');
|
|
213
|
-
frame.append(chart);
|
|
214
|
-
renderBarChart(chart, bars, { format: signedDuration, compact: data.compact, upIsWorse: true, tickUnit: tickUnit(bars, 'effort') });
|
|
215
|
-
legend = trendLegend(bars, data);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
// The same chart as the Overview: the series, its companion in grey, and a key that switches either line.
|
|
219
|
-
// The title repeats the item chosen in the sidebar; the key under the chart names each line.
|
|
220
|
-
headline.textContent = viewLabel(view);
|
|
221
|
-
const chart = element('div', 'chart');
|
|
222
|
-
const key = element('p', 'trend-key');
|
|
223
|
-
frame.append(chart, key);
|
|
224
|
-
if (!renderSeries(chart, key, data, shown, view, selected.sha, link, { compact: data.compact })) {
|
|
225
|
-
chart.append(element('p', 'detail empty', 'No measurements for this series in the shown inspections.'));
|
|
226
|
-
}
|
|
227
|
-
legend = trendLegend(seriesPoints(data, shown, view, selected.sha, link), data);
|
|
228
|
-
}
|
|
229
|
-
frame.append(definition);
|
|
66
|
+
const legend = slot ? '' : view === 'debt-changes' ? drawDebtChanges(page) : drawSeries(page);
|
|
67
|
+
frame.append(element('p', 'detail', definitions[view] ?? definitionOf(view)));
|
|
230
68
|
if (legend)
|
|
231
69
|
frame.append(element('p', 'detail legend', legend));
|
|
232
70
|
container.replaceChildren(layout);
|
|
233
71
|
return slot;
|
|
234
72
|
}
|
|
235
|
-
function viewNavigation(data, views, current, selected, period) {
|
|
236
|
-
const sha = selected.sha;
|
|
237
|
-
const wrapper = element('aside', 'trend-picker fx-aside');
|
|
238
|
-
const navigation = element('nav', 'trend-nav');
|
|
239
|
-
navigation.setAttribute('aria-label', 'Trend series');
|
|
240
|
-
const select = document.createElement('select');
|
|
241
|
-
for (const [group, members] of groups()) {
|
|
242
|
-
const present = members.filter(view => views.includes(view));
|
|
243
|
-
if (!present.length)
|
|
244
|
-
continue;
|
|
245
|
-
const block = element('div', 'trend-group');
|
|
246
|
-
const title = element('h3', '', group);
|
|
247
|
-
const reading = groupReading(data, selected, group);
|
|
248
|
-
if (reading)
|
|
249
|
-
title.append(reading);
|
|
250
|
-
block.append(title);
|
|
251
|
-
const list = element('ul');
|
|
252
|
-
const options = document.createElement('optgroup');
|
|
253
|
-
options.label = group;
|
|
254
|
-
for (const view of present) {
|
|
255
|
-
const item = element('li');
|
|
256
|
-
const link = element('a', '', viewLabel(view));
|
|
257
|
-
link.href = data.link(sha, view, period);
|
|
258
|
-
// Each series carries its value at the selected commit, in the tabs' counter.
|
|
259
|
-
const metric = view === 'debt-changes' || view === 'diff-coverage' ? null : view;
|
|
260
|
-
const reading = metric === null ? null : value(data, selected, metric);
|
|
261
|
-
// The group's own label carries the signal (the grade, the coverage); a row reads like a summary table.
|
|
262
|
-
if (metric !== null && reading !== null)
|
|
263
|
-
link.append(element('span', 'trend-value', formatMetric(reading, metric)));
|
|
264
|
-
if (view === current)
|
|
265
|
-
link.setAttribute('aria-current', 'page');
|
|
266
|
-
item.append(link);
|
|
267
|
-
list.append(item);
|
|
268
|
-
options.append(new Option(viewLabel(view), view, false, view === current));
|
|
269
|
-
}
|
|
270
|
-
block.append(list);
|
|
271
|
-
navigation.append(block);
|
|
272
|
-
select.append(options);
|
|
273
|
-
}
|
|
274
|
-
select.addEventListener('change', () => { location.hash = data.link(sha, select.value, period); });
|
|
275
|
-
const label = element('label', 'trend-select', 'Series');
|
|
276
|
-
label.append(select);
|
|
277
|
-
wrapper.append(navigation, label);
|
|
278
|
-
return wrapper;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* What a quality group comes to at the selected commit, in the label the Overview uses for it: the maintainability
|
|
282
|
-
* grade in its colour and line coverage (green from 95%). Other groups carry no total: it would repeat a row.
|
|
283
|
-
*/
|
|
284
|
-
function groupReading(data, selected, group) {
|
|
285
|
-
if (group === 'Maintainability') {
|
|
286
|
-
const grade = data.quality[selected.sha]?.maintainability?.grade;
|
|
287
|
-
if (!grade)
|
|
288
|
-
return null;
|
|
289
|
-
const label = element('span', 'trend-reading trend-reading-grade', grade);
|
|
290
|
-
label.dataset.grade = grade;
|
|
291
|
-
return label;
|
|
292
|
-
}
|
|
293
|
-
if (group === 'Coverage') {
|
|
294
|
-
const ratio = value(data, selected, 'coverage');
|
|
295
|
-
if (ratio === null)
|
|
296
|
-
return null;
|
|
297
|
-
const label = element('span', 'trend-reading', formatMetric(ratio, 'coverage'));
|
|
298
|
-
if (ratio >= .95)
|
|
299
|
-
label.classList.add('trend-reading-good');
|
|
300
|
-
return label;
|
|
301
|
-
}
|
|
302
|
-
return null;
|
|
303
|
-
}
|
|
304
|
-
function periodControl(data, sha, view, period) {
|
|
305
|
-
// The choices say what they are ("Last 100 inspections"), so the label is for screen readers only.
|
|
306
|
-
const label = element('label', 'trend-period');
|
|
307
|
-
label.append(element('span', 'visually-hidden', 'Period'));
|
|
308
|
-
const select = document.createElement('select');
|
|
309
|
-
const total = data.reports.length;
|
|
310
|
-
for (const option of ['30', '100']) {
|
|
311
|
-
if (Number(option) < total)
|
|
312
|
-
select.append(new Option(`Last ${option} inspections`, option, false, option === period));
|
|
313
|
-
}
|
|
314
|
-
select.append(new Option(`All ${total} inspections`, 'all', false, period === 'all' || Number(period) >= total));
|
|
315
|
-
select.addEventListener('change', () => { location.hash = data.link(sha, view, select.value); });
|
|
316
|
-
label.append(select);
|
|
317
|
-
return label;
|
|
318
|
-
}
|
|
319
|
-
/** The measure drawn beside a series as a grey line on its own scale: the time behind the ratio, the lines behind the share. */
|
|
320
|
-
export const companions = { debt: 'effort', coverage: 'uncovered-lines' };
|
|
321
|
-
const hiddenKey = 'repometry.hidden-series';
|
|
322
|
-
let hiddenSeries;
|
|
323
|
-
function hidden() {
|
|
324
|
-
if (!hiddenSeries) {
|
|
325
|
-
try {
|
|
326
|
-
hiddenSeries = new Set(JSON.parse(localStorage.getItem(hiddenKey) ?? '[]'));
|
|
327
|
-
}
|
|
328
|
-
catch {
|
|
329
|
-
hiddenSeries = new Set();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return hiddenSeries;
|
|
333
|
-
}
|
|
334
|
-
function remember() {
|
|
335
|
-
try {
|
|
336
|
-
localStorage.setItem(hiddenKey, JSON.stringify([...hidden()]));
|
|
337
|
-
}
|
|
338
|
-
catch {
|
|
339
|
-
// Without storage the choice lasts for this page only.
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* A series with its companion, as the Overview draws it: the series in ink on the left scale, the companion in grey on
|
|
344
|
-
* the right, and a key whose entries switch each line on and off. The last line shown cannot be switched off; with one
|
|
345
|
-
* left it takes the left scale. The choice is remembered for this viewer. Returns whether anything was drawn.
|
|
346
|
-
*/
|
|
347
|
-
export function renderSeries(chart, key, data, shown, metric, selected, link, options) {
|
|
348
|
-
const pair = companions[metric];
|
|
349
|
-
const second = pair ? shown.map(report => value(data, report, pair)) : [];
|
|
350
|
-
// A companion earns its line only once it can draw one, that is, from two measurements on.
|
|
351
|
-
const paired = pair !== undefined && second.filter(item => item !== null).length >= 2;
|
|
352
|
-
const main = seriesPoints(data, shown, metric, selected, link);
|
|
353
|
-
const hasData = main.some(point => point.value !== null) || (paired && second.some(item => item !== null));
|
|
354
|
-
function draw() {
|
|
355
|
-
const showMain = !paired || !hidden().has(metric);
|
|
356
|
-
const showSecond = paired && !hidden().has(pair);
|
|
357
|
-
const lead = showMain ? metric : pair;
|
|
358
|
-
const base = showMain ? main : seriesPoints(data, shown, pair, selected, link);
|
|
359
|
-
// The card under the pointer names the grey series too.
|
|
360
|
-
const points = showMain && showSecond ? base.map((point, index) => second[index] == null ? point
|
|
361
|
-
: { ...point, tip: { ...point.tip, notes: [`${labelOf(pair)}: ${formatMetric(second[index], pair)}`, ...point.tip.notes] } }) : base;
|
|
362
|
-
chart.classList.toggle('chart-companion-only', !showMain);
|
|
363
|
-
if (points.some(point => point.value !== null)) {
|
|
364
|
-
renderLineChart(chart, points, { format: number => formatMetric(number, lead), ratio: isPercent(lead), compact: options.compact,
|
|
365
|
-
height: options.height, tickUnit: tickUnit(points, lead), labelCurrent: options.labelCurrent ?? true,
|
|
366
|
-
secondary: showMain && showSecond ? { values: second, format: number => formatMetric(number, pair), tickUnit: tickUnit(second.map(item => ({ value: item })), pair) } : undefined });
|
|
367
|
-
}
|
|
368
|
-
else
|
|
369
|
-
chart.replaceChildren(element('p', 'detail empty', 'No measurements for this series in the shown inspections.'));
|
|
370
|
-
key.hidden = !paired;
|
|
371
|
-
if (!paired) {
|
|
372
|
-
key.replaceChildren();
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
key.replaceChildren(...[[metric, 'main', showMain], [pair, 'second', showSecond]].map(([series, kind, on]) => {
|
|
376
|
-
const item = document.createElement('button');
|
|
377
|
-
item.type = 'button';
|
|
378
|
-
item.className = `trend-key-item trend-key-${kind}`;
|
|
379
|
-
item.textContent = labelOf(series);
|
|
380
|
-
item.setAttribute('aria-pressed', String(on));
|
|
381
|
-
// The one line left stays: a chart of nothing says nothing.
|
|
382
|
-
item.disabled = on && !(showMain && showSecond);
|
|
383
|
-
item.addEventListener('click', () => {
|
|
384
|
-
if (on)
|
|
385
|
-
hidden().add(series);
|
|
386
|
-
else
|
|
387
|
-
hidden().delete(series);
|
|
388
|
-
remember();
|
|
389
|
-
draw();
|
|
390
|
-
key.querySelector(`.trend-key-${kind}`)?.focus();
|
|
391
|
-
});
|
|
392
|
-
return item;
|
|
393
|
-
}));
|
|
394
|
-
}
|
|
395
|
-
if (hasData)
|
|
396
|
-
draw();
|
|
397
|
-
else {
|
|
398
|
-
chart.replaceChildren();
|
|
399
|
-
key.hidden = true;
|
|
400
|
-
}
|
|
401
|
-
return hasData;
|
|
402
|
-
}
|
|
403
|
-
/** Remediation time ticks in whole hours once the series reaches two hours. */
|
|
404
|
-
export function tickUnit(points, metric) {
|
|
405
|
-
const minutes = metric === 'effort' || pluginSpec(metric)?.descriptor.unit === 'minutes';
|
|
406
|
-
return minutes && points.some(point => Math.abs(point.value ?? 0) >= 120) ? 60 : 1;
|
|
407
|
-
}
|
|
408
|
-
function value(data, report, metric) {
|
|
409
|
-
return metricValue(report, metric, data.quality[report.sha], data.context?.[report.sha]);
|
|
410
|
-
}
|
|
411
|
-
function signedDuration(minutes) {
|
|
412
|
-
if (Math.round(minutes) === 0)
|
|
413
|
-
return '0 min';
|
|
414
|
-
return `${minutes > 0 ? '+' : '−'}${formatMetric(Math.abs(minutes), 'effort')}`;
|
|
415
|
-
}
|
|
416
|
-
function element(tag, className, text) {
|
|
417
|
-
const node = document.createElement(tag);
|
|
418
|
-
if (className)
|
|
419
|
-
node.className = className;
|
|
420
|
-
if (text !== undefined)
|
|
421
|
-
node.textContent = text;
|
|
422
|
-
return node;
|
|
423
|
-
}
|