Analyse all git differences from IntelliJ across base branch

Continuing the discussion from Analyze all git differences from a branch:

We have an entire SonarQube setup in our CI/CD pipeline, however, in the interest of improving our iteration time on addressing the issues reported by SonarQube, is there a way to trigger SonarLint in IntelliJ which compares the changes across the current branch and the base branch?

Important: The “Analyse VCS Changed Files” trigger button under the report tab of SonarLint does not suffice, since my changes are already committed and pushed to my remote.

8 Likes

+1 on this

+1 on this. Would be really helpful to know, if there is way to trigger the same.

  • 1 it would be great to have it.

Hello @judepereira,
we do not currently offer the the analysis of changes across the current branch and the base branch directly in the IDE with SonarLint.
On the other hand, you have the Pull Request Analysis functionality in SonarQube, which enables to see all the new issues that you are about to add into the main branch with your pull request.
You can see the documentation of the feature here: https://docs.sonarqube.org/latest/analysis/pull-request/ .
Please note that the above functionality is only available in SonarQube Developer Edition and above.
Does this functionality answers your needs?

Hey Marco,
We already use SonarQube Developer edition with PR analysis. However, my question is to enable this in the IDE itself, as for a typical CI pipeline, it takes 12 minutes to get to the Sonar feedback (since running our tests takes 7 minutes, and running Sonar analysis across the entire project takes about 6 minutes).

Having a similar feature in the IDE would increase productivity significantly.

Thanks @judepereira for the precise description of your usecase. The implementation of this functionality is not in our short-term roadmap so I cannot give you any ETA today.

Nevertheless, we constantly adjust our priorities based on different factors, including Community requests (and votes for those threads :slight_smile: ) - so we are definitely tracking your request. To this extent, I have recategorised this thread into “Suggest new features” so other users can vote for it if they are interested.

Sounds good @Marco_Comi. Thank you :slight_smile:

@Marco_Comi out of sheer curiosity, is it possible for me to implement this via the open source plugin? Or would it require some more tinkering in some closed source place?

Hi @judepereira,
as SonarLint for IntelliJ is open source, in principle it is possible for anyone to implement functionalities on top of the existing code. At the same time also notice that we are not actively looking to merge feature contributions, especially for quite complex usecases like this one, where you will need to take into account - just to give a few examples:

  • what is your comparison baseline (for example in Git the main branch is not necessarily always the “master” branch)
  • when you compare current branch with base branch, some lines of codes may have been modified (or just moved a few lines up or down…) so it is not always straightforward to filter new issues when you compare across branches.

You can find a few more info here: https://github.com/SonarSource/sonarlint-intellij#contributing

Yes, I do agree that that makes sense. I was thinking that I’d present a branch picker, and then analyse the diff across that. It won’t be accurate, but it’ll be 90% accurate :slight_smile: