buildValueCandidates function presentation ✓ 100.0%
Last updated: 2026-02-24T21:07:57.586Z
Metrics
LOC: 35
Complexity: 12
Params: 2
Coverage: 100.0% (19/19 lines, 17x executed)
Signature
buildValueCandidates(value: string, maxLength: number): : string[]
Architecture violations
- [warning] max-cyclomatic-complexity: 'buildValueCandidates' has cyclomatic complexity 12 (max 10)
Source Code
function buildValueCandidates(value: string, maxLength: number): string[] {
const candidates: string[] = [];
const pushCandidate = (candidate: string): void => {
if (!candidate && candidate !== "") return;
if (!candidates.includes(candidate)) {
candidates.push(candidate);
}
};
pushCandidate(value);
const trimmed = value.trim();
if (trimmed !== value) pushCandidate(trimmed);
const collapsedWhitespace = value.replace(/\s+/g, " ").trim();
if (collapsedWhitespace && collapsedWhitespace !== value) {
pushCandidate(collapsedWhitespace);
}
const digitsOnly = value.replace(/\D+/g, "");
if (digitsOnly && digitsOnly !== value) {
pushCandidate(digitsOnly);
}
if (maxLength > 0) {
for (const candidate of [...candidates]) {
if (candidate.length > maxLength) {
pushCandidate(candidate.slice(0, maxLength));
}
}
}
return candidates;
}
No outgoing dependencies.
Impact (Incoming)
| Source | Type |
|---|---|
| adaptGeneratedValue | calls |