Skip to content

[Code Quality] Fix pkg/console/list.go: replace fmt.Scanf with injected reader #46641

Description

@github-actions

Description

pkg/console/list.go:76 uses fmt.Scanf("%d", &choice) in the non-TTY fallback path, while the rest of the function accepts a reader abstraction. This bypasses dependency injection and may read from the wrong input source in scripted or non-interactive contexts.

Suggested Changes

  • Replace fmt.Scanf("%d", &choice) with a read from the injected reader (matching the pattern in confirm.go)
  • Ensure the fallback path is consistent with how pkg/console/confirm.go handles non-interactive input

Files Affected

  • pkg/console/list.go (line 76)
  • Reference: pkg/console/confirm.go (pattern to follow)

Success Criteria

  • fmt.Scanf removed from list.go
  • Non-TTY fallback reads from the injected reader
  • Existing tests pass; add test for non-TTY path with a bytes.Reader if not present

Source

Extracted from Terminal Stylist Analysis #46584

Priority

Medium — Correctness issue in non-interactive/scripted usage

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 40.8 AIC · ⌖ 6.1 AIC · ⊞ 7K ·

  • expires on Jul 20, 2026, 11:13 AM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions