Running an analysis
Now that you've installed the SonarQube for IDE extension 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 SonarQube for IDE 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 > SonarQube to select/deselect Run SonarLint automatically.
Here are all the ways to trigger an analysis in SonarQube for 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 SonarQube > Analyze.
- Analyze changed files: Right-click over a Project folder in the Project/Package Explorer and select SonarQube > 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 SonarQube > Analyze. The SonarQube 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 SonarQube for Eclipse view window in the SonarQube On-The-Fly tab; note that you can also select multiple files in the Eclipse Project/Package Explorer and see them in the SonarQube On-The-Fly tab. Issues found after the analysis of multiple files are displayed in the SonarQube Report tab. See the documentation about Investigating issues for more details.
JavaScript and TypeScript analysis
To perform CSS, JavaScript, or TypeScript analysis, SonarQube for Eclipse must find the file path to your Node.js. If you have troubles, go to Eclipse > Settings to open the Preferences menu, then find SonarQube 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 > SonarQube and select File Exclusions (in Mac: Eclipse > Settings > SonarQube > 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 SonarQube > 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 (Server, Cloud) or SonarQube Community Build, 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
SonarQube for Eclipse 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 > SonarQube, 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?