MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / endCapText

Function endCapText

ui/src/lib/flow-model.ts:141–186  ·  view source on GitHub ↗
(boundary: WireFlowBoundary)

Source from the content-addressed store, hash-verified

139const plural = (n: number, one: string, many: string): string => (n === 1 ? one : many);
140
141export function endCapText(boundary: WireFlowBoundary): EndCapText {
142 const sites: EndCapSite[] = boundary.sites.map((site) => {
143 const notes: string[] = [];
144 if (site.key === null) notes.push('the key is a runtime value');
145 if (site.moreSites > 0) {
146 notes.push(`+${site.moreSites} more such ${plural(site.moreSites, 'site', 'sites')} here`);
147 }
148 return {
149 headline: `${site.label} at line ${site.line}`,
150 key: site.key,
151 notes,
152 candidates: site.candidates,
153 candidateHeading:
154 site.candidates.length > 0
155 ? `${site.candidates.length} candidate ${plural(site.candidates.length, 'target', 'targets')} \u203a`
156 : null,
157 candidateNote: site.candidateNote,
158 };
159 });
160
161 const missedNames = boundary.missed.map((m) => m.name);
162 return {
163 intro:
164 boundary.sites.length > 0
165 ? `${boundary.node.name} chooses its next call at runtime.`
166 : `${boundary.node.name} is the last symbol on this path.`,
167 sites,
168 quiet:
169 boundary.sites.length > 0
170 ? null
171 : 'No dynamic-dispatch site was detected in its body, so nothing here explains the break.',
172 uncertainHeading:
173 boundary.uncertain.total > 0
174 ? `${boundary.uncertain.total} name-only ${plural(boundary.uncertain.total, 'match', 'matches')} not followed (confidence < 0.6)`
175 : null,
176 uncertain: boundary.uncertain.items,
177 further:
178 boundary.further.total > 0
179 ? `It makes ${boundary.further.total} further resolved ${plural(boundary.further.total, 'call', 'calls')} this path does not need.`
180 : null,
181 missed:
182 missedNames.length > 0
183 ? `Never reaches ${missedNames.join(', ')}${boundary.missed.length < missedNames.length ? '…' : '.'}`
184 : null,
185 };
186}
187
188/** Exact rendered height of an end cap, which its CSS then pins as a minimum. */
189export function endCapHeight(boundary: WireFlowBoundary): number {

Callers 3

capRowsFunction · 0.90
endCapHeightFunction · 0.85

Calls 4

mapMethod · 0.80
pushMethod · 0.80
pluralFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected