New issues introduced by branch is not being detected by branch analysis

  • SonarQube 7.7 Enterprise Edition, sonar-maven-plugin 3.6.0.1398 scanner, SonarJava plugin

How to reproduce:

In the “master” mainline, there’s an existing Java class that uses a particular api in one of its methods. Example: “import java.time.Instant;”

In a new feature branch, that same method was removed since it was no longer required, but the developer forgot to remove the “import java.time.Instant;” line.

The feature branch analysis did NOT report an issue with the unused import.

Upon the merge of the feature branch into master, a new “unused import” issue was detected when “master” was reanalyzed.

How can this be prevented? Can the branch analysis feature be enhances to fail on all new issues introduced by the feature branch? Even if the new issue occured on a line NOT being modified by the feature branch?

thanks,
David

Hey David,

I haven’t gone and tested your exact use-case, but I think the situation you described is covered by MMF-1390 - Short-lived branches and PRs should show all new issues, not just the ones on changed code, which you should feel free to vote for. :slight_smile:

Colin

2 Likes

Thanks Colin for your quick response. Yes, MMF-1390 appears to describe the same issue I’m having. I’m looking forward to its resolution.

We’ve also encountered a similar problem but from the opposite side. One of our users has complained that they are being dinged for a change to a file that was made by someone else. The file was changed recently, but by someone else. So why is SonarQube complaining to me about someone else’s change in a section of the file I didn’t touch. So Also very much looking forward to that feature.