Running an analysis
Now that you've installed SonarLint in your IDE, running an analysis is straight-forward. For the most part, new analyses are automatically triggered when you open a file, as you type, or with each file save following a change in the code. Below we've outlined other ways to trigger a SonarLint analysis.
Automatic analysis can be controlled on a per-project basis: Right-click on a project in the Project or Package Explorer, open Properties > SonarLint to select/deselect Run SonarLint automatically.
Here are all the ways to trigger a SonarLint analysis in Eclipse:
- Detect issues on file open and save (default): When the file is opened, autosaved, or manually saved.
- On-demand: Selections of one or more files can be analyzed together by right-clicking over a file selection in the Eclipse Project Explorer, then select SonarLint > Analyze.
- Analyze changed files: Right-click over a Project folder in the Project/Package Explorer and select SonarLint > Analyze changed files to run an analysis on all uncommitted files. Your project must be under Git source control and you must have Egit installed.
- By selection: Use this method to get feedback on issues found in a set of files or set of projects. Select one or more files/projects in the Project Explorer, then right-click and select SonarLint > Analyze. The SonarLint Report view will open automatically and present issues found in your selection.
There’s a status bar in the lower right corner to report the state of analysis. Issues found after an analysis of the active file are displayed in the SonarLint view window in the SonarLint On-The-Fly tab; note that you can also select multiple files in the Eclipse Project/Package Explorer and see them in the SonarLint On-The-Fly tab. Issues found after the analysis of multiple files are displayed in the SonarLint Report tab. See the documentation about Investigating issues for more details.
It’s possible to limit the analysis using this same navigation path (as above). In Windows, go to Project > Properties > SonarLint and select File Exclusions (in Mac: Eclipse > Settings > SonarLint > File Exclusions). There you can specify files to exclude. More details about File Exclusions can be found here.
It is also possible to exclude a file or files from the Eclipse Explorer window. Select one or more files in the Explorer, then right-click and select SonarLint > Exclude.
A custom change to the configuration such as initializing Connected Mode or when modifying your selected rule set, will trigger a new analysis because it could lead to different results. In addition, when binding a project to SonarQube or SonarCloud, a new analysis will be triggered for all open files. See the documentation on [Connected Mode]() for more details.
© 2015-2023, SonarSource S.A, Switzerland. Except where otherwise noted, content in this space is licensed under the GNU Lesser General Public License, Version 3.0. SONARLINT is a trademark of SonarSource SA. All other trademarks and copyrights are the property of their respective owners. See SonarSource.com for everything you need to know about the Sonar Solution.