Skip to content

chore(cleanup): dead code + fnm error-wrapping + nvm Current() test gap from cleanup-feature PR #61

Description

@dipto0321

Describe the bug

Small cleanup items found while reviewing the post-upgrade cleanup feature (PR #56 / issue #41), bundled since each is a one-line-to-small fix:

  1. Dead code in internal/cli/cleanup.go:166,177: confirm := true is declared and then only ever referenced via _ = confirm — it never actually gates anything (the real control flow is a continue elsewhere). Leftover from a refactor; delete both lines.
  2. Dead code in internal/cli/upgrade.go:110: _ = yes immediately after yes has already been fully consumed by the cleanup-flag resolution block above it (lines 94-109). Remove.
  3. internal/detector/fnm.go:247 (GlobalNpmPrefix's final error path) drops the underlying os.Stat error entirely:
    return "", fmt.Errorf("fnm global npm prefix for %s not found at %s or %s", v, prefix, filepath.Join(dir, "installation", "lib", "node_modules"))
    No %w, no err2 included, even though every one of its 6 sibling implementations (asdf, mise, n, nodenv, nvm, volta) correctly wraps the underlying OS error with %w in the equivalent function. Low severity (message quality/debuggability only), but worth making consistent.
  4. internal/detector/nvm.go's Current() method has zero test coverage at the method level. nvm_test.go only tests parseNVMCurrent (the pure output parser) — there's no TestNVMCurrent_InvokesShell-style test asserting NVM.Current() actually builds and runs the source ... && nvm current script, unlike every other manager (fnm, mise, n, nodenv, asdf, volta all have this test). Given Current() is the safety-critical gate protecting the active version from deletion (see the related "Current() error leaves active version unprotected" issue), this is worth closing.

Severity

Low individually — bundled as one chore PR since none needs its own review cycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions