Skip to content

CLI-499 skip sqaa during global integration#312

Open
sophio-japharidze-sonarsource wants to merge 1 commit into
masterfrom
CLI-499_skip_sqaa_during_global_integration
Open

CLI-499 skip sqaa during global integration#312
sophio-japharidze-sonarsource wants to merge 1 commit into
masterfrom
CLI-499_skip_sqaa_during_global_integration

Conversation

@sophio-japharidze-sonarsource
Copy link
Copy Markdown
Contributor

No description provided.

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the CLI-491_add_instruction_files_to_codex_integration branch 2 times, most recently from 9a3d012 to 74ba72a Compare May 21, 2026 14:46
@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the CLI-499_skip_sqaa_during_global_integration branch from 87c9bd8 to b56884b Compare May 21, 2026 14:49
@sophio-japharidze-sonarsource sophio-japharidze-sonarsource marked this pull request as ready for review May 21, 2026 14:55
@sonar-review-alpha
Copy link
Copy Markdown
Contributor

sonar-review-alpha Bot commented May 21, 2026

Summary

What changed: This PR prevents SQAA (SonarQube Agentic Analysis) from being installed during global integration, even when the organization is entitled to it. SQAA is project-scoped functionality that must only be installed on a per-project basis.

Changes made:

  • Added a guard in both Claude and Copilot integrations: !isGlobal && sqaaEntitled controls whether SQAA is actually installed
  • Renamed sqaaEnabledsqaaEntitled throughout to clarify the distinction between entitlement and actual installation
  • Refactored health check/token repair logic into runHealthCheckAndRepair() helper function for clarity
  • When users run a global integration and their org is SQAA-entitled, they now receive a warning with instructions to re-run per-project to enable SQAA
  • Updated both integration and unit tests to verify SQAA is not installed during global setup, but the user is guided appropriately

Why it matters: Prevents a scope violation where project-level state/hooks were being installed globally, which would cause issues with per-project SQAA setup later.

What reviewers should know

Start here: Look at the core logic changes in both src/cli/commands/integrate/claude/index.ts (lines 85-92) and src/cli/commands/integrate/copilot/index.ts (lines 59-63) — these are the key guards that prevent SQAA installation during global mode.

Key decisions:

  • SQAA entitlement is still checked (line 89 in claude) because users need to know they can enable it per-project; only installation is gated
  • The new runHealthCheckAndRepair() function (lines 211-247 in claude) is a refactoring that also simplifies the main flow

What reviewers should verify:

  1. The installSqaa variable correctly evaluates to false for global installs, preventing all SQAA artifacts (hooks, state, migrations) from being installed
  2. Both integrations (Claude + Copilot) handle the guard identically for consistency
  3. User-facing warnings (around line 266 in claude, line 107 in copilot) clearly direct users to re-run per-project
  4. Test changes accurately reflect that global installs should produce no SQAA artifacts but do warn users
  5. The refactored runHealthCheckAndRepair() maintains the original health check + optional repair logic without behavioral changes

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

sonar-review-alpha[bot]

This comment was marked as outdated.

@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the CLI-491_add_instruction_files_to_codex_integration branch 2 times, most recently from 30974b8 to 9dc48b6 Compare May 21, 2026 15:14
@sophio-japharidze-sonarsource sophio-japharidze-sonarsource force-pushed the CLI-499_skip_sqaa_during_global_integration branch from b56884b to 8815a8f Compare May 21, 2026 15:17
sonar-review-alpha[bot]

This comment was marked as outdated.

Base automatically changed from CLI-491_add_instruction_files_to_codex_integration to master May 21, 2026 15:29
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha Bot left a comment

Choose a reason for hiding this comment

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

Clean, well-scoped fix. The installSqaa = !isGlobal && sqaaEntitled guard is applied consistently across all three call sites (runMigrations, installSqaaHook, updateStateAfterConfiguration), and the runHealthCheckAndRepair refactor faithfully preserves the original repair logic. One logic duplication worth tidying up.

🗣️ Give feedback

Comment on lines +269 to +271
if (sqaaEntitled) {
warn(
'SonarQube Agentic Analysis is project-scoped and is not enabled by this global install. Run `sonar integrate claude --project <key>` from a project directory to enable it for that project.',
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.

Logic duplication: This warning message is functionally identical to the one in src/cli/commands/integrate/copilot/index.ts:108-110 — same first sentence, same structure, only the command name differs. Any future wording change (e.g. renaming "SonarQube Agentic Analysis" or adjusting the hint syntax) requires two edits in non-obvious locations.

Extract a shared helper parameterised on the integration name (e.g. in integrate/_common/):

export function warnSqaaSkippedOnGlobalInstall(integration: 'claude' | 'copilot'): void {
  warn(
    `SonarQube Agentic Analysis is project-scoped and is not enabled by this global install. ` +
    `Run \`sonar integrate ${integration} --project <key>\` from a project directory to enable it for that project.`,
  );
}

Then call it from both reportHookInstallationOutcome and reportInstallationOutcome.

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