Skip to content

refactor: Remove dead code and stale references#2530

Merged
louisgv merged 2 commits intomainfrom
qa/code-quality
Mar 12, 2026
Merged

refactor: Remove dead code and stale references#2530
louisgv merged 2 commits intomainfrom
qa/code-quality

Conversation

@la14-1
Copy link
Member

@la14-1 la14-1 commented Mar 12, 2026

Summary

  • Deduplicated generateCsrfState() helper: the identical function existed in both digitalocean/digitalocean.ts and shared/oauth.ts. Exported it from shared/oauth.ts (which digitalocean.ts already imports) and removed the duplicate copy from digitalocean.ts.

Scan Results by Category

a) Dead code: No unused functions found in sh/shared/*.sh or packages/cli/src/. All exported functions have callers.

b) Stale references: No references to non-existent files found. All source calls in shell scripts and import paths in TypeScript resolve to existing files.

c) Python usage: No python3 -c or python -c calls found anywhere in shell scripts. Project already correctly uses bun eval and jq.

d) Duplicate utilities: Found and fixed one duplicate — generateCsrfState() was defined identically in both digitalocean/digitalocean.ts and shared/oauth.ts. Consolidated into shared module.

e) Stale comments: No stale comments referencing removed infrastructure, old test files, or deleted functions found.

Files Modified

  • packages/cli/src/shared/oauth.ts — exported generateCsrfState
  • packages/cli/src/digitalocean/digitalocean.ts — removed duplicate generateCsrfState, imported from shared

Test Plan

  • bunx @biomejs/biome check src/ — 0 errors
  • bun test — 1396 pass, 0 fail

-- qa/code-quality

The identical generateCsrfState() helper existed in both
digitalocean/digitalocean.ts and shared/oauth.ts. Export it from
oauth.ts (which digitalocean.ts already imports) and remove the
duplicate copy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Review

Verdict: APPROVED
Commit: 41aa90b

Findings

No security issues found. This PR safely deduplicates the generateCsrfState() function by:

  • Removing duplicate implementation from digitalocean.ts
  • Exporting from shared oauth.ts module
  • Maintaining identical cryptographic implementation (crypto.getRandomValues with 128-bit entropy)

Tests

  • bun test: PASS (1396 tests, 0 failures)
  • biome lint: PASS (0 errors)
  • Code duplication: FIXED (function now centralized)

Security Analysis

  • CSRF token generation remains cryptographically secure
  • No command injection vectors
  • No credential leaks
  • No unsafe eval/source usage
  • Proper ESM imports/exports

-- security/pr-reviewer

@louisgv louisgv merged commit 6bdef06 into main Mar 12, 2026
5 checks passed
@louisgv louisgv deleted the qa/code-quality branch March 12, 2026 13:33
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.

2 participants