Skip to content

CLI-694 Remove legacy state writes from Claude integration#554

Merged
tomshafir-sonarsource merged 6 commits into
masterfrom
bug/ts/CLI-694-integrate-claude-legacy-state
Jul 7, 2026
Merged

CLI-694 Remove legacy state writes from Claude integration#554
tomshafir-sonarsource merged 6 commits into
masterfrom
bug/ts/CLI-694-integrate-claude-legacy-state

Conversation

@tomshafir-sonarsource

@tomshafir-sonarsource tomshafir-sonarsource commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary by Tom

  • resolveSqaaProjectKey was the last piece of logic still reading the deprecated agentExtensions state field (everything else was migration or fallback only). It now reads the SQAA project key from the declarative sonar-sqaa-hook feature in integrations.installed, finishing the Claude integration's migration to declarative state.
  • Removed the Claude integration's legacy state write (updateStateAfterConfiguration) and related helpers (e.g. findExtensionsByProject).
  • Tests/helpers: agentExtensions is now referenced only in migration tests; all other logic tests assert against the declarative state. Updated the withSqaaExtension helper in environment-builder.ts to seed the new structure.
  • Extracted a shared SQAA_HOOK_FEATURE_ID constant (_common/sqaa-entitlement.ts), reused across the Claude/Codex declarations, the reader, and the test harness.

Summary by Gitar

  • Code removal:
    • Removed legacy state storage mechanisms src/cli/commands/integrate/_common/state.ts and src/cli/commands/integrate/claude/state.ts.
    • Eliminated redundant agentExtensions management in src/lib/state-manager.ts.
  • Refactored integration state:
    • Migrated Claude integration logic to use declarative integrations.installed state instead of the deprecated registry.
    • Updated resolveSqaaProjectKey to read sonar-sqaa-hook features directly from declarative integration state.
  • Testing:
    • Cleaned up integration tests to verify the new declarative state structure.
    • Updated unit tests for analyzeSqaa to reflect the transition from legacy extensions to integrated feature state.

This will update automatically on new commits.

@netlify

netlify Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploy Preview for sonarqube-cli canceled.

Name Link
🔨 Latest commit aabb7b3
🔍 Latest deploy log https://app.netlify.com/projects/sonarqube-cli/deploys/6a4ce02a9a039e0008c21d15

@tomshafir-sonarsource tomshafir-sonarsource force-pushed the bug/ts/CLI-694-integrate-claude-legacy-state branch from 2efde54 to b4f7fa0 Compare July 6, 2026 12:06
Comment thread tests/integration/harness/environment-builder.ts Outdated
@gitar-bot

gitar-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Removes legacy state storage for Claude integration and migrates to declarative state management, resolving the duplicate SQAA hook magic string issue.

✅ 1 resolved
Quality: SQAA hook feature id duplicated as a magic string

📄 tests/integration/harness/environment-builder.ts:150 📄 src/cli/commands/analyze/sqaa-auth.ts:131
recordSqaaHookFeature hardcodes featureId: 'sonar-sqaa-hook'. This literal is now repeated across the test harness, the production reader (sqaa-auth.ts), and the integration declaration(s). The test correctness silently depends on this string staying byte-identical to production — if the declaration id ever changes, the reader lookup and this seed will drift and tests may pass/fail misleadingly. Consider exporting a shared constant (e.g. SQAA_HOOK_FEATURE_ID) from the Claude declaration / feature module and reusing it here, matching the pattern already used for CLAUDE_INTEGRATION_ID and CONTEXT_AUGMENTATION_FEATURE_ID which are imported rather than hardcoded. This is a minor, non-blocking cleanup.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@tomshafir-sonarsource tomshafir-sonarsource marked this pull request as ready for review July 6, 2026 14:15
@tomshafir-sonarsource tomshafir-sonarsource changed the title CLI-694 Remove legacy state write on Claude integration CLI-694 Remove legacy state write from Claude integration Jul 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

removes sonar-a3s entries from state.json when SQAA hooks are installed via migration test still asserts agentExtensions contains sonar-sqaa. That only passes because runMigrations() → migrateToExtensionsRegistry() still writes legacy state

Please have a look at runMigrations code as well, and adjust the test to assert the declarative feature

@tomshafir-sonarsource tomshafir-sonarsource force-pushed the bug/ts/CLI-694-integrate-claude-legacy-state branch from 7fe3b6c to a0e5971 Compare July 7, 2026 10:06
@tomshafir-sonarsource tomshafir-sonarsource changed the title CLI-694 Remove legacy state write from Claude integration CLI-694 Remove legacy state writes from Claude integration Jul 7, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's hope it's all good 😂

@tomshafir-sonarsource tomshafir-sonarsource merged commit 7fd04bf into master Jul 7, 2026
21 checks passed
@tomshafir-sonarsource tomshafir-sonarsource deleted the bug/ts/CLI-694-integrate-claude-legacy-state branch July 7, 2026 11:44
@gitar-bot

gitar-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Migration to declarative state for Claude integration is complete, removing legacy state writes and redundant agentExtensions management. The duplicate SQAA hook feature ID magic string was also consolidated into a shared constant.

✅ 1 resolved
Quality: SQAA hook feature id duplicated as a magic string

📄 tests/integration/harness/environment-builder.ts:150 📄 src/cli/commands/analyze/sqaa-auth.ts:131
recordSqaaHookFeature hardcodes featureId: 'sonar-sqaa-hook'. This literal is now repeated across the test harness, the production reader (sqaa-auth.ts), and the integration declaration(s). The test correctness silently depends on this string staying byte-identical to production — if the declaration id ever changes, the reader lookup and this seed will drift and tests may pass/fail misleadingly. Consider exporting a shared constant (e.g. SQAA_HOOK_FEATURE_ID) from the Claude declaration / feature module and reusing it here, matching the pattern already used for CLAUDE_INTEGRATION_ID and CONTEXT_AUGMENTATION_FEATURE_ID which are imported rather than hardcoded. This is a minor, non-blocking cleanup.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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