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 Enterprise edition, 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, you can open the issue in your IDE provided the Connected Mode has been properly set up in order to connect SonarLint with SonarQube.
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 SonarQube 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:
- Retrieve the issue and open its detail view.
- In the Where is the issue? tab, select Open in IDE.
Getting AI-generated fix suggestions
This feature is available in Early Access, in Enterprise Edition and above.
If AI-generated fix suggestions are activated in your SonarQube instance, you can generate fix suggestions for the issues detected in your projects. The suggestions are generated using OpenAI's GPT-4.
To generate a fix suggestion:
- Retrieve the issue and open its detail view.
- Go to the Where is the Issue or the Code Fix tab and click the Generate Fix button.
You can then copy the generated fix suggestion to your IDE:
- manually, by copying and pasting the suggestion into your IDE.
- using the Code Fix > View Fix in IDE button if you use Connected Mode. This feature is available with SonarLint for VS Code, IntelliJ, and Eclipse.
Note that for some issues, AI-generated fix suggestions are not available.
Was this page helpful?