Skip to content

fix(lint): resolve dupl findings - #891

Merged
skevetter merged 2 commits into
mainfrom
lint/dupl-findings
Aug 6, 2026
Merged

fix(lint): resolve dupl findings#891
skevetter merged 2 commits into
mainfrom
lint/dupl-findings

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Resolves 3 of 5 dupl duplicate pairs (9 findings). One pair is deferred; workspace_server.go's pair is untouched by design.

Extracted a shared helper (genuine duplication):

  • cmd/pro/provider/ssh.go / stop.go: both Run methods duplicated the full dial-and-execute body (client init, workspace lookup, dial, stream). Extracted dialAndExecute into a new cmd/pro/provider/exec.go, parameterized by sub-resource action and env flags.

Suppressed, following existing repo convention:

  • cmd/pro/check_update.go NewCheckUpdateCmd / cmd/pro/health.go NewHealthCmd
  • cmd/pro/daemon/netcheck.go NewNetcheckCmd / cmd/pro/daemon/status.go NewStatusCmd

Both are cobra command-factory boilerplate. The repo already has this exact pattern suppressed elsewhere (NewCreateCmd/NewUpdateCmd in cmd/pro/workspace, and NewHealthCmd itself already carried a //nolint:duplNewCheckUpdateCmd was just missing its half). Added matching //nolint:dupl // structurally similar to X; intentional sibling factory comments rather than inventing a generic cobra-wiring abstraction across unrelated command types.

Test duplication:

  • pkg/options/resolver/resolver_test.go: extracted setupParentChildGraph for the two near-identical parent/child precedence tests, kept as separate test functions since they assert distinct scenarios.

Deferred (not touched):

golangci-lint run --enable-only=dupl --max-same-issues=0 ./... now reports exactly the 2 remaining workspace_server.go findings (the deferred pair), not zero.

Extracted a shared dialAndExecute helper (cmd/pro/provider/exec.go) for
the genuinely duplicated dial+execute body in ssh.go/stop.go, parameterized
by sub-resource action and env flags.

The remaining three pairs are cobra command factory boilerplate
(NewCheckUpdateCmd/NewHealthCmd, NewNetcheckCmd/NewStatusCmd) that already
have an established repo convention of //nolint:dupl with a
'structurally similar; intentional sibling factory' reason (see
NewCreateCmd/NewUpdateCmd, NewHealthCmd) -- followed the same convention
rather than introducing a generic cobra-wiring abstraction across
unrelated command types.

Extracted a setupParentChildGraph helper for the two near-identical
resolver_test.go cases, keeping them as separate, individually runnable
test functions since they assert distinct precedence scenarios.

pkg/ts/workspace_server.go's pair is intentionally left as-is: it's the
exact handler pair refactored in #890 (Director -> Rewrite migration),
not yet merged. Deferred to a follow-up to avoid a conflicting refactor.
@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

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

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@skevetter, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: af18e8e9-9c7e-4fe5-bd30-d1130fe5ad20

📥 Commits

Reviewing files that changed from the base of the PR and between 4279672 and e4e198f.

📒 Files selected for processing (7)
  • cmd/pro/check_update.go
  • cmd/pro/daemon/netcheck.go
  • cmd/pro/daemon/status.go
  • cmd/pro/provider/exec.go
  • cmd/pro/provider/ssh.go
  • cmd/pro/provider/stop.go
  • pkg/options/resolver/resolver_test.go

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 Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit e4e198f
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a7496353158b700082d7bb1

@github-actions github-actions Bot added the size/l label Aug 6, 2026
Two self-inflicted findings from the earlier dupl fix:

- pkg/options/resolver/resolver_test.go: moved the unexported
  setupParentChildGraph helper after all exported ResolverTestSuite test
  methods (funcorder wants unexported methods last on a struct).

- cmd/pro/provider/exec.go: dialAndExecute had 7 params, over the repo's
  revive argument-limit of 4. Bundled configPath/action/envFlags/stdin/
  stdout/stderr into a dialAndExecuteParams struct (ctx stays separate),
  matching the existing <funcName>Params convention used elsewhere in
  cmd/pro (loginParams, createClusterParams, waitForWorkspacePhaseParams).
  Updated both call sites in ssh.go and stop.go.

That struct extraction reduced ssh.go/stop.go's Run bodies to a single
parameterized call, which made the two files dupl-flag themselves as a
whole (lines 1-51 in each) -- the same cobra-sibling-factory pattern as
the check_update/health and netcheck/status pairs already suppressed
elsewhere in this PR. Added matching //nolint:dupl directives (had to
place them above the package clause, since dupl's clone range for these
two files starts at line 1).
@skevetter
skevetter merged commit 3f8f61b into main Aug 6, 2026
115 of 117 checks passed
@skevetter
skevetter deleted the lint/dupl-findings branch August 6, 2026 23:56
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