-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Bug: Dead Code in flattenParams
File: internal/intent/parser.go ~line 351
Description
In the flattenParams function, for float64 values that are whole numbers, the code computes a value via a complex strings.TrimRight/strings.Replace chain and assigns it to result[k] — then immediately overwrites it with fmt.Sprintf("%g", val) on the very next line. The first assignment is dead code and never used.
Reproduction
case float64:
if val == float64(int(val)) {
result[k] = strings.TrimRight(strings.TrimRight( // ← DEAD: immediately overwritten
strings.Replace(
strings.Replace(
fmt.Sprintf("%f", val), ".", "", 1),
"0", "", -1),
"0"), "")
// Simpler: just use Sprintf
result[k] = fmt.Sprintf("%g", val) // ← actual assignment
}Fix
Remove the dead first assignment. Both integer and non-integer float64 values should use the same fmt.Sprintf("%g", val) path:
case float64:
result[k] = fmt.Sprintf("%g", val)Impact
- Dead code clutters the function and confuses future readers (the comment says "Simpler: just use Sprintf" but leaves the original around)
- No behavioral impact at runtime since the second assignment wins
Reactions are currently unavailable