In my current Hybris project one of coding standard is to publish SonarQube report before every push to master. This rule is nice, but not always everyone fallows it.

This is why I’ve wanted to introduce plugin that can automatically generates SonarQube analysis results in BitBucket (Stash) pull-request. And I’ve found it: SonarQube Stash (BitBucket) plugin.

The workflow looks as fallow:

user creates pull-request 
-> hook executes Jenkins job 
-> sonar-scanner executes analysis in preview mode 
-> Executing post-job org.sonar.plugins.stash.StashIssueReportingPostJob
-> SonarQube analysis overview has been reported to Stash.

It’s almost perfect, but instead of comments in lines with violations I get a lot of messages like this:

Comment "squid:S1134" cannot be pushed to Stash like it does not belong to diff view - nc3cockpit/src/com/nespresso/nc3/cockpit/components/header/ (line: 14)

How to fix “Comment cannot be pushed to Stash like it does not belong to diff view”

In my case the problem was with project configuration. Analysed code was in different location then GIT root directory:


Similar structure can be checked here:

Note that I’m referring to old version of this repo where this problem exists. In the newest revision whole project is configured in a way that problem “Comment cannot be pushed” is not occurring.

I’m executing sonar-scanner from Jenkins, so the working directory is ./ instead of ./src/. This is why my command was like this:

sonar-scanner sonar.projectBaseDir=./src/

and main



Full path to file:




Should be:


The Fix

Move your main file from ./src/ to ./, change into:


execute command:

sonar-scanner sonar.projectBaseDir=./



During development of my fix PR#56 (which is not need eventually), I created GIT repo to test the solution. If you fallow those two links you can find some more interesting things how it’s working.

And it’s all started from Issue: Comment “xxx” cannot be pushed to Stash like it does not belong to diff view.

Few weeks ago I watch one video on YouTube by Tomasz Dziurko: Jinkubator #28 – 1011 błędów w rekrutacji, które pokazują jaki będzie twój kod. It’s in polish, but some of you may enjoy. I really fall in love with this sentence: I write and read faily well ;-)

I write about this because yesterday I faced one English grammar problem. During implementation of one feature I’ve add an method to our interface:


It’s about returning list of codes for different categories. One of my code reviewer told me that this against English grammar – I couldn’t believe ;-)

First because other similar methods looks the same eg:


Second it was against my logic, but after all it occurs that my logic throws there RuntimeException ;-)

I even ask question about it on StackOverflow and the conclusion was:

As both a native English speaker and a Java programmer: getCategoryCodes() is preferable. getCategoriesCodes() implies to me that I am getting multiple codes for each category, or that the codes relate to the collection of categories, rather than a code for each category.

As an example from “real” English: a car has one driver; you would refer to the drivers of many cars as “car drivers”, not “cars drivers”.

If you are interested in more detailed discussion please read my post: Java naming conventions versus English language correctness