fix(lint): resolve all nestif findings - #876
Conversation
nestif is on by default once enabled, same as funcorder/cyclop -- no separate opt-in setting. Fixes all 5 pre-existing violations by extracting the deeply-nested block into a well-named helper: - pkg/daemon/platform/local_server.go: watchPlatform's nested if err != nil -> updatePlatformAuthStatus - pkg/devcontainer/delete.go: Delete's non-compose branch -> stopAndDeleteContainer - pkg/provider/workspace.go: ParseWorkspaceSource's git-prefix branch -> parseGitWorkspaceSource - pkg/ssh/server/ssh.go: getCommand's su/shell argv construction -> buildSuArgs, buildShellArgs - pkg/workspace/id.go: ToID's two top-level branches -> idFromPROrBranch, idFromRepoPath (preserves the pre-existing dead len(splitted)==2 check inside idFromRepoPath -- that branch is unreachable in both the old and new code, unrelated to this fix) All extractions are behavior-preserving; verified against existing test coverage (pkg/workspace/id_test.go's TestToID exercises every branch, pkg/provider's TestParseWorkspaceSource_GitURLs covers the git path). No logic changes.
✅ Deploy Preview for images-devsy-sh canceled.
|
✅ Deploy Preview for devsydev canceled.
|
|
Warning Review limit reached
Next review available in: 56 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe change extracts existing authentication, deletion, Git parsing, SSH argument, and workspace ID logic into focused helper methods. Existing behavior remains unchanged, including error handling, argument construction, and identifier normalization. ChangesHelper-based control-flow refactors
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
idFromRepoPath is only reached from ToID's else branch (len(splitted) != 2), so its len(splitted) == 2 check could never be true. Drop the dead branch and the now-unused splitted parameter.
Summary
Like
funcorderandcyclop,nestifis already fully active once enabled -- no separate opt-in setting exists, so all 5 pre-existing findings are fixed here in one PR.Each fix extracts the deeply-nested block into a well-named helper:
pkg/daemon/platform/local_server.go:watchPlatform's nestedif err != nil->updatePlatformAuthStatuspkg/devcontainer/delete.go:Delete's non-compose stop-then-delete branch ->stopAndDeleteContainerpkg/provider/workspace.go:ParseWorkspaceSource's git-prefix branch ->parseGitWorkspaceSourcepkg/ssh/server/ssh.go:getCommand'ssu/shell argv construction ->buildSuArgs,buildShellArgspkg/workspace/id.go:ToID's two top-level branches ->idFromPROrBranch,idFromRepoPath(preserves a pre-existing deadlen(splitted)==2check inside the repo-path branch -- unreachable in both the old and new code, unrelated to this fix)No behavior changes. Verified against existing test coverage:
pkg/workspace/id_test.go'sTestToIDexercises every branch (PR reference, branch name, repo URL, local dir, truncation), andpkg/provider'sTestParseWorkspaceSource_GitURLscovers the git path.Summary by CodeRabbit