Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does sonar:sonar work?

We want to use SonarQube with some CI tool in our project. Sonar Server url is configured in main pom.xml.

There are several team memebers in the project. So what happen when one team member executes sonar:sonar locally with his local changes, then another team member executes sonar:sonar with his local changes, and then someone executes sonar:sonar from CI tool (it is configured to analyse source code in Git repository)?

Will SonarQube display issues related team members local changes? What if there are differences between team members local source code and source code in Git repository?

like image 548
RuF Avatar asked Sep 19 '16 12:09

RuF


2 Answers

sonar:sonar executes analysis and sends the results to the server - assuming you're running it with the token of an account that has the appropriate privileges.

Developers should not be running this type of analysis locally to check their changes. Instead, they should be using SonarLint and perhaps pull request analysis (depending on your infrastructure).

(EDIT: Pull request analysis has been deprecated and replaced by a fuller-featured Branch analysis($).)

To expand a little on why developers shouldn't be using sonar:sonar locally: it updates the central server in a last-saved-wins manner. So if you've edited A.java and analyzed it locally before commit, and I've renamed A.java to B.java and done a similar pre-commit local analysis... what's visible on the SonarQube server? Depends on who saved/analyzed last.

Instead, sonar:sonar should be run only from your CI tool on the checked-in code that's already visible to the whole team.

like image 129
G. Ann - SonarSource Team Avatar answered Oct 10 '22 14:10

G. Ann - SonarSource Team


As you said that sonar server url is cofigured in mail pom.xml and your team member's run sonar:sonar command at there local machine. But because of all referring to the same server url. So all changes will reflect for a common project. If you want to see then difference separately for each team member. then either you need to update the project name distinct from each other. Other wise you will see latest one there.

Sonar gives you difference in graphical manner. as well as you can compare two build too.

Second If user has administrator grant only then they can update sonar server else not.

like image 43
Tej Kiran Avatar answered Oct 10 '22 13:10

Tej Kiran