# Fixing issues

## Fix suggestions

Depending on the issue, you may get fix suggestions:

* In the **How can I fix it?** tab of the issue's detail view.
* If an AI-generated fix suggestion is available for your issue, the **AI CodeFix** tab will appear. See [#getting-ai-generated-fix-suggestions](#getting-ai-generated-fix-suggestions "mention") for more details.

## Opening issues in your IDE <a href="#opening-in-ide" id="opening-in-ide"></a>

To speed up the time it takes to find and fix the issue, use [connected-mode](https://docs.sonarsource.com/sonarqube-server/user-guide/connected-mode "mention") to connect SonarQube Server with SonarQube for IDE and use the **Open in IDE** feature.

{% hint style="info" %}
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 Server 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).
{% endhint %}

To open an issue in your IDE, it’s easier if you are already running in [connected-mode](https://docs.sonarsource.com/sonarqube-server/user-guide/connected-mode "mention"):

1. Retrieve the issue and open its detail view. See [retrieving](https://docs.sonarsource.com/sonarqube-server/user-guide/issues/retrieving "mention") for more information.
2. In the **Where is the issue?** tab, select **Open in IDE**.

## Getting AI-generated fix suggestions <a href="#getting-ai-generated-fix-suggestions" id="getting-ai-generated-fix-suggestions"></a>

*AI CodeFix is only available in SonarQube Server* [*Enterprise and Data Center editions*](https://www.sonarsource.com/plans-and-pricing/sonarqube/) to provide AI-generated fixes for your issues.

AI-generated fix suggestions are available for a select set of rules in Java, JavaScript, TypeScript, Python, C#, and C++. To learn more about which rules are eligible for AI CodeFix, see the list of [#ai-codefix-rules](https://docs.sonarsource.com/sonarqube-server/quality-standards-administration/managing-rules/rules-for-ai-codefix#ai-codefix-rules "mention").

When an Instance Admin enables AI CodeFix for your project, you can get an AI-generated fix suggestion for eligible issues. The suggestions are generated using <code class="expression">space.vars.SQS\_20261\_Supported\_LLM\_version</code> your own Azure OpenAI LLM Service model. See [#enabling-ai-generated-fix-suggestions](https://docs.sonarsource.com/sonarqube-server/ai-capabilities/ai-codefix#enabling-ai-generated-fix-suggestions "mention") for more information.

To generate a fix suggestion:

* Retrieve the issue and open its detail view. If an AI CodeFix is an option for that particular issue, you will see the **Generate AI Fix** button.
* From either the **Where is the Issue?** or the **AI CodeFix** tabs, select **Generate Fix**.

An AI CodeFix will be generated, and you’ll see a diff view in the **AI CodeFix** tab. If you’re using SonarQube for IDE and have [connected-mode](https://docs.sonarsource.com/sonarqube-server/user-guide/connected-mode "mention") set up, select **View fix in IDE** to streamline the process and see the diff view in your IDE. Then, simply copy and paste the generated fix into your IDE.

* If you are running SonarQube for Visual Studio, selecting **View fix in IDE** will directly paste the fix suggestion into your IDE.

The easiest way to use AI CodeFix is by using AI CodeFix in your IDE. Simply open your project in SonarQube for [VS Code](https://app.gitbook.com/o/2ibCvzwZt86Nlk2zloB7/s/6LPRABg3ubAJhpfR5K0Y/ "mention") or SonarQube for [IntelliJ](https://app.gitbook.com/o/2ibCvzwZt86Nlk2zloB7/s/NvI4wotPmITyM0mnsmtp/ "mention"). In your IDE, select an issue marked with the ![$ai-icon-sparkle](https://content.gitbook.com/content/3VWSqvZ4eaBLWvA6epdv/blobs/bFdE3axsVUA94MupDyPC/4be9087a2b059c269f15df202838af7a74e71a96.svg) icon, open the **Rule description** > ![$ai-icon-sparkle](https://content.gitbook.com/content/3VWSqvZ4eaBLWvA6epdv/blobs/bFdE3axsVUA94MupDyPC/4be9087a2b059c269f15df202838af7a74e71a96.svg)**AI CodeFix** tab, and select ![$ai-icon-sparkle](https://content.gitbook.com/content/3VWSqvZ4eaBLWvA6epdv/blobs/bFdE3axsVUA94MupDyPC/4be9087a2b059c269f15df202838af7a74e71a96.svg)**Generate Fix**. A fix will be generated in the code editor and you’ll have a chance to **Apply** or **Decline** the suggestion.

* See the IntelliJ page for [AI CodeFix #AI CodeFix in your IDE](https://app.gitbook.com/s/NvI4wotPmITyM0mnsmtp/ai-capabilities/ai-codefix#ai-codefix "mention")
* See the VS Code page for [AI CodeFix #AI CodeFix in your IDE](https://app.gitbook.com/s/6LPRABg3ubAJhpfR5K0Y/ai-capabilities/ai-codefix#ai-codefix "mention")

An AI Code Assurance badge is available to mark your AI projects as reviewed by SonarQube Server. Any user with project access can use the badge. For more detailed instructions, see the [#label-projects-with-ai-code](https://docs.sonarsource.com/sonarqube-server/quality-standards-administration/ai-code-assurance/overview#label-projects-with-ai-code "mention") article for more information.

## Usage limits <a href="#limits" id="limits"></a>

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.

SonarQube Server instances that are using a self-hosted LLM are not subject to Sonar’s limits however, you may encounter rate limits from your self-hosted LLM provider.
