Skip to content

chore(lint): resolve gocritic findings#720

Merged
skevetter merged 4 commits into
mainfrom
chore/gocritic-lint
Jul 23, 2026
Merged

chore(lint): resolve gocritic findings#720
skevetter merged 4 commits into
mainfrom
chore/gocritic-lint

Conversation

@skevetter

@skevetter skevetter commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Resolves all 39 gocritic linter findings reported by golangci-lint.

Changes by check

  • ifElseChain (26) – rewrote if / else if chains to switch statements
  • assignOp (6) – x = x + yx += y (e2e/framework/framework.go)
  • appendAssign (4) – pkg/agent/tunnelserver/tunnelserver.go:
    • variadic opts := append(options, …) now assigns back to options
    • append(UserCredentials.GitHttp, ProjectCredentials.GitHttp…)slices.Concat(…) to avoid mutating the shared UserCredentials backing array
  • deprecatedComment (3) – DEPRECATED: → canonical Deprecated: casing
  • exitAfterDefer (1) – cmd/internal/agentcontainer/daemon.go: defer stop() never ran before os.Exit; now calls stop() explicitly before exiting
  • singleCaseSwitch (1) – single-case type switch rewritten as a type assertion (pkg/types/types.go)

Verification

  • gocritic: 39 → 0
  • Also cleared 3 staticcheck and 1 modernize finding that flagged the same chains
  • go build ./... passes; affected-package tests pass (389)
  • golangci-lint fmt reports no diff

Summary by CodeRabbit

  • Bug Fixes

    • Improved process shutdown behavior so signal handling is restored before the daemon exits.
    • Workspace source types now report an explicit unknown type when no recognized source is configured.
    • Invalid option-enum JSON values now return a clear unsupported-type error.
  • Refactor

    • Simplified branching across workspace management, container startup, deployment monitoring, IDE selection, option resolution, and related workflows without changing expected behavior.
  • Documentation

    • Clarified deprecation wording for dev container settings and extensions.

Address all 39 gocritic findings:
- ifElseChain: rewrite if-else chains to switch statements
- assignOp: use += compound assignment
- appendAssign: assign append result to same slice; use slices.Concat
  where two distinct slice fields were combined (avoids aliasing)
- deprecatedComment: use canonical 'Deprecated:' casing
- exitAfterDefer: call stop() explicitly before os.Exit
- singleCaseSwitch: rewrite single-case type switch to type assertion
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 4807fa7
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a6170a03b98690008697b0b

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d5e0b96-0043-4b24-ab7f-033b9add8aea

📥 Commits

Reviewing files that changed from the base of the PR and between aea85a4 and 4807fa7.

📒 Files selected for processing (21)
  • cmd/internal/agentcontainer/daemon.go
  • cmd/internal/sh.go
  • cmd/pro/start.go
  • e2e/framework/framework.go
  • e2e/framework/util.go
  • pkg/agent/agent.go
  • pkg/agent/tunnelserver/tunnelserver.go
  • pkg/client/clientimplementation/daemonclient/client.go
  • pkg/client/clientimplementation/daemonclient/delete.go
  • pkg/client/clientimplementation/daemonclient/up.go
  • pkg/devcontainer/config/config.go
  • pkg/devcontainer/prebuild.go
  • pkg/driver/kubernetes/run.go
  • pkg/ide/ideparse/parse.go
  • pkg/inject/inject.go
  • pkg/options/resolver/resolve.go
  • pkg/platform/deploy.go
  • pkg/provider/workspace.go
  • pkg/ssh/config.go
  • pkg/types/types.go
  • pkg/workspace/list.go

📝 Walkthrough

Walkthrough

The pull request refactors conditional branches to switch statements across command, agent, client, platform, provider, and type-handling code. It also makes signal cleanup explicit, uses direct slice concatenation, and returns an unknown workspace-source type for unmatched sources.

Changes

Control-flow and collection refactors

Layer / File(s) Summary
Command and startup branching
cmd/internal/..., cmd/pro/start.go, e2e/framework/*
Startup validation, Docker image selection, container discovery, temporary-directory selection, signal cleanup, and platform binary-name construction are refactored.
Agent, tunnel, and daemon-client flows
pkg/agent/..., pkg/client/clientimplementation/daemonclient/*
Workspace handling, tunnel option and credential assembly, reachability validation, deletion polling, and task-result validation are updated.
Platform, configuration, and resolution branches
pkg/devcontainer/..., pkg/driver/kubernetes/run.go, pkg/ide/..., pkg/inject/..., pkg/options/..., pkg/platform/...
Prebuild selection, mount validation, IDE and option resolution, line reading, deployment status handling, and deprecation comments are refactored.
Provider, SSH, and JSON type behavior
pkg/provider/..., pkg/ssh/config.go, pkg/types/types.go, pkg/workspace/list.go
Workspace source formatting and typing, provider listing, SSH marker processing, and enum-array JSON validation are updated; unmatched workspace sources now return WorkspaceSourceUnknown.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main purpose: resolving gocritic lint findings.
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.

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.

@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 4807fa7
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a6170a075f3840007ba2e03

@skevetter
skevetter marked this pull request as ready for review July 23, 2026 02:01
@skevetter
skevetter merged commit 030c1bf into main Jul 23, 2026
63 of 64 checks passed
@skevetter
skevetter deleted the chore/gocritic-lint branch July 23, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant