Skip to content

bug: dead code in flattenParams (intent/parser.go) #61

@jpleva91

Description

@jpleva91

Bug: Dead Code in flattenParams

File: internal/intent/parser.go

In the flattenParams function, the float64 branch has dead code — a complex string manipulation expression that is immediately overwritten on the very next line:

case float64:
    if val == float64(int(val)) {
        result[k] = strings.TrimRight(strings.TrimRight(
            strings.Replace(
                strings.Replace(
                    fmt.Sprintf("%f", val), ".", "", 1),
                "0", "", -1),
            "0"), "")
        // Simpler: just use Sprintf   ← comment left in from debugging
        result[k] = fmt.Sprintf("%g", val)  // ← overwrites the above
    } else {
        result[k] = fmt.Sprintf("%g", val)
    }

The if val == float64(int(val)) branch does the same thing as the else branch — both produce fmt.Sprintf("%g", val). The entire if/else can be collapsed to a single line.

Fix:

case float64:
    result[k] = fmt.Sprintf("%g", val)

Impact: No functional impact (result is the same), but dead code increases maintenance burden and signals incomplete refactoring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions