Fixing issues

Fixing issues in SonarQube Cloud happens in the IDE. From the Team plan, you can get AI-suggested fixes for many code issues in your organization.

Depending on the issue, you may get fix suggestions:

Opening issues in your IDE

To speed up the time it takes to find and fix the issue, use connected mode to connect SonarQube Cloud with SonarQube for IDE and use the Open in IDE feature.

If you’ve already fixed the issue in your code, SonarQube for IDE will not be able to find it in the IDE; only matching code will be highlighted. Keep in mind that the revision or branch analyzed by SonarQube Cloud may not be the same as what you have opened in the IDE. When setting up connected mode, SonarQube for IDE considers the branch currently checked out in the IDE and tries to synchronize it with the most appropriate branch from the server. This is called branch matching in SonarQube for IDE.

To open an issue in your IDE, it’s easier if you are already running in connected mode:

  1. Follow the Retrieving issues instructions and open an issue's detail view.

  2. Select the Open in IDE button.

Getting AI-generated fix suggestions

This feature is available in the Team and Enterprise plans, see Subscription plans for more details. AI-generated fix suggestions are available for a select list of rules and languages.

After AI CodeFix for your organization, you can get an AI-generated fix suggestion for eligible issues. The suggestions are generated using Anthropic's Claude Sonnet 4 (recommended) or OpenAI's GPT-4o.

To generate a fix suggestion in your IDE:

  • Simply open your project in SonarQube for SonarQube for VS Code or SonarQube for IntelliJ using connected mode with SonarQube Cloud. In your IDE, select an issue marked with the $ai-icon-sparkle icon, open the Rule description > $ai-icon-sparkleAI CodeFix tab, and select $ai-icon-sparkleGenerate Fix. A fix will be generated in the code editor and you’ll have a chance to Apply or Decline the suggestion.

To generate a fix suggestion in SonarQube Cloud:

  • Follow the Retrieving issues instructions in SonarQube Cloud and open an issue's detail view. If an AI CodeFix is an option for that particular issue, you will see the $ai-icon-sparkleGenerate AI Fix button.

  • From either the Where is the Issue or the AI CodeFix tabs, select the Generate Fix button.

If an AI CodeFix is available for your issue, SonarQube Cloud will offer a Generate AI Fix button to select.

An AI CodeFix will be generated, and you’ll see a diff view in the AI CodeFix tab. Simply copy and paste the generated fix into your IDE; If you’re using SonarQube for IDE and have connected mode set up for SonarQube for IDE, feel free to use the Open in IDE feature to streamline the process.

  • If you are running SonarQube for Visual Studio, selecting View fix in IDE will offer you a diff view in the IDE which provides an opportunity to accept or reject the suggestion before committing the change.

An AI Code Assurance badge is available to any SonarQube Cloud plan to mark your AI projects as reviewed by SonarQube Cloud. Any user with project access can use the badge. For more detailed instructions, see the AI Code Assurance article on the AI settings page.

Note that for some issues, an AI CodeFix suggestion is not available. To learn more about which rules are eligible for AI CodeFix, please see the list of Rules covered with AI CodeFix.

Usage limits

Limits are placed on the AI CodeFix feature to manage abuse. Developers will be notified directly when the monthly allocation is reached for your organization. If the instance is blocked due to reaching the allowance, users attempting to generate a fix will see an error message. Usage quotas are reset on the first day of each month.

Creating Jira Cloud work items from SonarQube issues

You can create a Jira Cloud work item from a single or multiple SonarQube issues. See Jira Cloud integration for more information.

Last updated

Was this helpful?