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.
Triggering an 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.
JavaScript and TypeScript analysis
To perform CSS, JavaScript, or TypeScript analysis, SonarLint must find the file path to your Node.js. If you have troubles, go to Eclipse > Settings to open the Preferences menu, then find SonarLint and set your Node.js executable path.
File exclusions
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.
Using Eclipse plugins to index your project
SonarLint uses some Eclipse plugins to index your project to exclude certain files and folders in your compilation or build output directories. This improves overall performance and lowers the memory footprint.
To opt out of these exclusions, right-click on your project, select Properties > SonarLint, and clear the Rely on Eclipse plugins checkbox.
Each project should be assessed individually. Changing your selection requires a restart of the IDE
Was this page helpful?