How to let Sonar only do analyses for modified part in new commit

  • which versions are you using
    sonar-maven-plugin: (default-cli)
    SonarQube version: 7.9.4

  • what are you trying to achieve
    The problem I am facing is that: Every time when l push a commit to Gerrit, Jenkins will trigger a sonar check to check if the code is following the rules. But Sonar will not only give me a warning for code l just pushed, but also give warning for code from before in the same file. What l want is to let the sonar only warn me about my new changes or check only my new code, how can l make this happen? Thank you


Welcome to the community!

First, your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

xxx → 7.9.6 → 8.9.2 → 9.0.1 (last step optional)

Regarding your actual question, it seems like you’re looking for PR analysis, which is available starting in Developer Edition($).


Thank you for your reply, l will try to ask my team and update our Sonar. :slight_smile:

For the Pull Request Analysis you mentioned, do you mind teaching me how or showing me where l can see the instruction to make the analysis only show violations for newly modified code (instead of the whole file) in my commit on Gerrit :slight_smile:

Sorry for the stupid question, l am new to work, Therefore l am not that familiar with Sonar.


Hi Leo,

I have no familiarity with Gerrit.

Assuming you’re already licensed for Developer Edition, the docs should get you started.


Thank you for your help, Ann. l will try to figure it out. :slight_smile: Hope you a nice day

1 Like