Fixing your code issues
Depending on the issue, you may get fix suggestions:
- In the How can I fix it? tab of the issue's detail view.
- From the Team plan, generated through AI: see Getting AI-generated fix suggestions below.
Opening issues in your IDE
To speed up the time it takes to find and fix the issue, use Connected Mode to connect SonarCloud with SonarLint and use the Open in IDE feature.
If you’ve already fixed the issue in your code, SonarLint 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 SonarCloud may not be the same as what you have opened in the IDE. When setting up connected mode, SonarLint 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 SonarLint).
To open an issue in your IDE, it's easier if you are already running in connected mode:
- Retrieve the issue and open its detail view.
- Select the Open in IDE button.
Getting AI-generated fix suggestions
This feature is available in Early Access, in the Team and Enterprise plans. AI-generated fix suggestions are available for a select list of rules and languages.
When AI-CodeFix is enabled for your organization by an Organization Admin, you can get an AI-generated fix suggestion for eligible issues. The suggestions are generated using OpenAI's GPT-4.
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 the Generate Fix button.
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 SonarLint and have Connected Mode set up, feel free to use the Open in IDE feature to streamline the process.
- If you are running SonarLint for Visual Studio, selecting Open in IDE will directly paste the fix suggestion into your IDE.
An AI Code Assurance badge is available to any SonarCloud plan to mark your AI projects as reviewed by SonarCloud. Any user with project access can use the badge. For more detailed instructions, see the Marking a project as containing AI-generated code article on the AI settings page.
Note that for some issues, an AI CodeFix suggestion is not available.
Was this page helpful?