Gaming gate with whitespace commit

  • ALM used: GitHub
  • CI system used: customized Jenkins
  • Java
  • Error observed: Sonar properly blocks merge when violation is introduced but whitespace commit turns it green again and no longer blocks
  • Create a new branch and related PR with a violation, like two methods with the same impl
  • The merge is blocked
  • Push a whitespace-only change
  • Sonar shows as green again and the merge is unblocked

Is this expected behavior? thank you

Hi,

Welcome to the community!

Can you share some more details? Are we talking about PR analysis? If so, what gets picked up as new after your whitespace commit?

 
Thx,
Ann

Hi Ann,

Thank you!

I think what we want is actually branch analysis – we have short-lived feature/bugfix branches and regulary merge back to main. Does this sound like the use case for branch analysis? I think it is but confirmation would be appreciated!

We managed to configure the sonar UI to consider new code:

  • for main: compare to previous version
  • for branches: compare to main

Which matches what I believe we need. BUT: we get a warning:

Could not find ref 'main' in refs/heads, refs/remotes, refs/remotes/upstream or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis

which means our git clone is shallow? The build system is a bit opaque so the only way I have found to “unshallow” the code is with exec-maven-plugin . Does this seem like the right path?

So, two questions:

  1. Is branch analysis the right path for short lived branches?
  2. Would git fetch —unshallow be expected to resolve the Could not find ref ‘main’…?

Thank you!

Hi,

I would actually recommend PR analysis instead. I mean, you can use short-lived branch analysis for this, but the case for it is really subsumed by PR analysis.

These prerequisites are listed for PR analysis, but they really apply to both. Make sure they’re in place and the warning should go away.

 
HTH,
Ann