Skip to content

fix(lint): remove redundant default case from exhaustive override-field switch#7451

Open
tomdebres wants to merge 1 commit into
stablyai:mainfrom
tomdebres:fix/source-control-override-note-exhaustive-switch
Open

fix(lint): remove redundant default case from exhaustive override-field switch#7451
tomdebres wants to merge 1 commit into
stablyai:mainfrom
tomdebres:fix/source-control-override-note-exhaustive-switch

Conversation

@tomdebres

@tomdebres tomdebres commented Jul 5, 2026

Copy link
Copy Markdown

Summary

pnpm lint currently fails on main:

src/renderer/src/components/settings/SourceControlActionRepoOverrideNote.tsx:35:5: error typescript(switch-exhaustiveness-check): The switch statement is exhaustive, so the default case is unnecessary.

Introduced by #7386. The switch in getRecipeOverrideFieldLabel covers every variant of SourceControlActionRecipeOverrideField, and config/oxlint-switch-exhaustiveness.json sets allowDefaultCaseForExhaustiveSwitch: false, so the hand-rolled never-guard default case is rejected.

This PR removes the default case. The dedicated lint:switch-exhaustiveness rule already fails the build if the union grows a new variant, so the compile-time guard it replaced is redundant — this matches the convention everywhere else in the renderer (no other component uses the _exhaustive pattern). No user-visible change.

Screenshots

No visual change.

Testing

  • pnpm lint (fails on main, passes on this branch)
  • pnpm typecheck
  • pnpm test (24,518 passed / 32 skipped)
  • pnpm build
  • Existing coverage: SourceControlActionRepoOverrideNote.test.tsx (5/5 passing) exercises all three override-field labels; the switch-exhaustiveness-check lint rule itself is the regression guard if the union grows a new variant, so no new tests were needed for a dead-code removal.

AI Review Report

Reviewed with Claude Code. Main risks checked: (1) whether removing the default case could introduce an implicit-undefined return path — it cannot, TypeScript proves the switch exhaustive over the union and tsgo --noEmit passes on all three tsconfigs; (2) whether the exhaustiveness safety net is weakened — it is not, typescript/switch-exhaustiveness-check (type-aware, allowDefaultCaseForExhaustiveSwitch: false) errors at lint time if SourceControlActionRecipeOverrideField gains a variant this switch does not handle; (3) convention alignment — no other renderer component uses the _exhaustive never-guard pattern. Cross-platform compatibility (macOS, Linux, Windows) was explicitly considered: the change is pure TypeScript control flow with no shortcuts, labels, paths, shell behavior, or Electron platform differences involved.

Security Audit

No security surface touched: the change removes an unreachable dead-code branch from a pure label-mapping function in the renderer. No input handling, command execution, path handling, auth, secrets, dependency, or IPC changes. No follow-up needed.

Notes

No platform-specific behavior. Zero runtime behavior change — the removed branch was unreachable for every value of the union type.

…ld switch

pnpm lint fails on main since stablyai#7386: the override-field switch in
SourceControlActionRepoOverrideNote covers every union variant, and the
switch-exhaustiveness config sets allowDefaultCaseForExhaustiveSwitch:
false, so the hand-rolled never-guard default is rejected. The lint rule
itself already fails the build if the union grows a new variant, so the
guard is redundant — remove it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A default branch was removed from the switch statement in the getRecipeOverrideFieldLabel function within SourceControlActionRepoOverrideNote.tsx. This branch previously performed a compile-time exhaustiveness check by assigning the field value to a never-typed variable and returning it. The switch statement now ends after the commandTemplate case without this fallback handling.

Changes

File Change Summary
SourceControlActionRepoOverrideNote.tsx Removed default branch with exhaustiveness check (never type assignment and return) from getRecipeOverrideFieldLabel switch statement

Related Issues: None specified.

Related PRs: None specified.

Suggested labels: None

Suggested reviewers: None

🐰 A switch once guarded, exhaustive and tight,
Now trails off quietly, out of sight.
No default whispers "never" to catch a stray case,
Just cases that fell through without any trace.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the PR’s main change: removing the redundant exhaustive switch default case to fix linting.
Description check ✅ Passed The description follows the template and includes summary, screenshots, testing, AI review, security audit, and notes.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant