Skip to content

Commit 1a94fd6

Browse files
committed
Make MapWeight use exhaustive switch expression over ProvenanceKind
Replace if-chain with a switch expression that explicitly handles Inferred and Extractive variants and throws ArgumentOutOfRangeException for unrecognized enum values.
1 parent f0dddb0 commit 1a94fd6

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

backend/src/Taskdeck.Application/Services/ProvenanceQueryService.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ internal static string BuildValue(ProvenanceField field)
155155
/// </summary>
156156
internal static string MapWeight(ProvenanceKind kind, double confidence)
157157
{
158-
if (kind == ProvenanceKind.Inferred)
159-
return "inferred";
160-
161-
// Extractive: confidence determines primary vs contextual.
162-
return confidence >= 0.7 ? "primary" : "contextual";
158+
return kind switch
159+
{
160+
ProvenanceKind.Inferred => "inferred",
161+
ProvenanceKind.Extractive => confidence >= 0.7 ? "primary" : "contextual",
162+
_ => throw new ArgumentOutOfRangeException(nameof(kind), kind, "Unrecognized ProvenanceKind")
163+
};
163164
}
164165
}

0 commit comments

Comments
 (0)