Skip to content

refactor: reduce lint complexity#223

Draft
mariusvniekerk wants to merge 3 commits intomainfrom
refactor/reduce-complexity
Draft

refactor: reduce lint complexity#223
mariusvniekerk wants to merge 3 commits intomainfrom
refactor/reduce-complexity

Conversation

@mariusvniekerk
Copy link
Copy Markdown
Collaborator

Summary

  • enable gocognit and gocyclo in golangci-lint with threshold 20
  • split high-complexity Go functions into smaller helpers across CLI, GitHub sync, server, workspace, terminal, testutil, and tooling code
  • update workspace delete/runtime cleanup flow to preserve dirty-delete sessions while keeping forced deletes safe

Test Plan

  • make lint
  • make test

@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented Apr 30, 2026

roborev: Combined Review (aa23ec9)

Medium risk: GraphQL sync failure handling can be masked by REST fallback.

Medium

  • internal/github/sync.go:1512 - When GraphQL fetching succeeds but doSyncRepoGraphQL fails, the refactor returns false, falls back to REST, and can clear the failure if REST succeeds. Previously this path marked the MR sync scope as failed and skipped REST fallback, preserving force-refresh/backoff behavior. The same regression exists for issues in indexSyncRepoIssuesGraphQL.

    Fix: Distinguish “GraphQL unavailable/fetch failed” from “GraphQL sync failed”; return an explicit failure flag or error so failedScope is preserved.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented May 1, 2026

roborev: Combined Review (7b2426d)

High-level verdict: Changes need follow-up before merge due to workspace deletion race risk and missing required e2e coverage.

High

  • internal/server/huma_routes.go:3317
    BeginStopping was moved inside the Delete callback, but workspace.Manager.Delete only invokes that callback after preflight/dirty checks. The stopping guard no longer covers the full delete operation, so a concurrent launch can pass the runtime guard during deletion and race with StopWorkspace or worktree cleanup.
    Fix: Start BeginStopping before calling workspaces.Delete and defer EndStopping after it returns, or move the manager callback earlier so the guard covers the full delete flow.

  • internal/github/sync_test.go:4226
    The GraphQL sync retry-state fix only adds unit coverage. This changes core sync/data-flow behavior and failure recovery, and the repository guidelines require e2e coverage for bug fixes in these paths.
    Fix: Add an e2e/API+SQLite full-stack test that exercises a GraphQL PR or issue sync failure and verifies the repo failure state is preserved for the next sync.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented May 1, 2026

roborev: Combined Review (61e91fc)

Code review verdict: no Medium, High, or Critical findings were reported.

All reviewed agents found the code clean for reportable issues.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@mariusvniekerk mariusvniekerk marked this pull request as draft May 1, 2026 11:52
mariusvniekerk and others added 3 commits May 1, 2026 09:49
Enable gocognit and gocyclo with a threshold of 20, then split complex functions into smaller helpers so the new checks pass.
GraphQL fetch failures should still fall back to REST, but failures while applying successfully fetched GraphQL data must remain visible to the scoped retry/backoff logic. The previous boolean result collapsed those cases, so a successful REST fallback could clear failedRepos and skip the forced refresh needed on the next sync cycle.

Add regression coverage for both MR and issue GraphQL sync failures that would otherwise be masked by REST fallback.
Keep workspace runtime stopping markers active for the full delete operation so concurrent launches cannot race with preflight or cleanup. Add API-plus-SQLite coverage for GraphQL sync failures preserving retry invalidation state.
@mariusvniekerk mariusvniekerk force-pushed the refactor/reduce-complexity branch from 61e91fc to 06a3440 Compare May 1, 2026 14:07
@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented May 1, 2026

roborev: Combined Review (06a3440)

No Medium, High, or Critical findings were reported across the reviews.

All agents reported the code as clean or provided no findings.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

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