SonarLint helps you detect and fix quality issues as you write code. Like a spell checker, SonarLint squiggles flaws.
Installing SonarLint Plugin to IntelliJ Idea
- Click on Settings > Plugins
- Click on the Browse Repositories button
- Then type in “SonarLint” and click on the install button
- Restart your IDE if asked for.
Analyzing source code with SonarLint
With SonarLint, you can analyze the code at the codebase level, package level, file level or even a block of code. Select a source folder, package or file or block, or code then right-click and click on “Analyse with SonarLint” (Ctrl + Alt + S)
This option will analyze the selected code and generates a report. Once the analysis is complete you would see some results in the SonarLint tab.
You can see the reports for the current file, or complete the report by clicking on these tabs in the SonarLint tab.
Select any item in the report to see the rule and location on the right side as shown below.