import { For, Show, type JSX } from 'solid-js';
import type { ScanState } from '../types';
import { coverageLabel, resultCountsLabel } from '../scan-display';
const dispositions: Record = {
reported: { label: 'Finding reported', tone: 'warn' },
needs_follow_up: { label: 'Needs follow-up', tone: 'warn' },
no_issue_found: { label: 'No issue found', tone: 'good' },
rejected: { label: 'Rejected' },
not_applicable: { label: 'Not applicable' },
};
type Counted = { total: number | null; items: unknown[]; omitted: number };
/** One titled block of coverage. Hidden when the scan reported nothing for it. */
function Group(props: { title: string; list: Counted; children: JSX.Element }) {
return (
{props.title} {props.list.total}
{props.children}
{props.list.omitted} more not shown.
);
}
const Paths = (props: { items: string[] }) => (
{(path) => {path}}
);
export function Coverage(props: { run: ScanState }) {
const coverage = () => props.run.assessment?.coverage;
const matching = () => props.run.assessment?.repositoryFindings;
const stat = (value: number | null | undefined) => value ?? '–';
const empty = () => {
const c = coverage();
if (!c) return [];
return (
[
['review surfaces', c.surfaces],
['deferred work', c.deferred],
['open questions', c.openQuestions],
['exclusions', c.explicitExclusions],
['limitations', c.limitations],
] as const
)
.filter(([, list]) => !list.total)
.map(([name]) => name);
};
return (
{resultCountsLabel(props.run)}
Coverage {coverageLabel(props.run)}
The scan did not report what it reviewed.
}
>
{(c) => (
<>
- {stat(c().surfaces.total)}
- Surfaces reviewed
- {stat(c().deferred.total)}
- Deferred
- {stat(c().openQuestions.total)}
- Open questions
{(surface) => (
-
{surface.label ?? 'Unnamed surface'}
{surface.riskArea}
{dispositions[surface.disposition]?.label ?? 'Unknown'}
)}
{(item) => (
-
{item.reason ?? 'No reason reported'}
)}
{(item) => - {item.question ?? 'Question details unavailable'}
}
Scope
- Included
-
- Excluded
-
{(item) => (
<>
- Skipped
-
{item.reason}
>
)}
Nothing reported for {empty().join(', ')}.
>
)}
Known findings in this repository
- {stat(matching()?.open)}
- Open
- {stat(matching()?.closed)}
- Closed
- {stat(matching()?.confirmedInLatestScan)}
- Seen in this scan
);
}