Code Duplication, Quality Gate and Default branch

We have switched to the new sonar 8.3 and now we use it together with another part of our company, but we need different configurations to sonar.

The first big problem is, that we have a quality gate, that allows only 3% code duplication, but we want to exclude Typescript tests (**/*.spec.ts) from it, but only for our team. The idea was, to disable it by command line. For that I’ve tried to use “-Dsonar.cpd.exclusions” for that. But there was no different after using it. Can I still use this property? It was removed from the docs in 7.8 or something like that but I never read that it’s deprecated.
The second problem is, that we have a different quality gate. At the moment, when we push a new project to gitlab, the pipeline run sonar and the project will be created in sonar with the default quality gate and we have to contact one of our sonar admins to change that.
The last problem is the default compare branch. By default it use the master branch, but in most of our projects we merge to develop.

Would be nice if we can set this settings in the command line, to not need to have an admin to change things every week. Is there a way at least for some of the problems?

Hi,

Welcome to the community!

We generally try to keep it to one question per thread. It can get quite tangled if you have followups on multiple subjects in a single thread. So I’m going to make an attempt here, but I may ask you to split some of this out if you have further questions.

Tests shouldn’t actually be included in duplication calculation. This can probably be handled by refining your definitions of sonar.sources and sonar.tests.

That parameter isn’t deprecated & should still work. (Having it in the docs seemed to encourage people to set it via analysis parameters and we really believe it’s best to set exclusions through the UI.) No way to diagnose what’s going on here without more data.

Here you have 3 options

  • change what the default is (you saw this coming, right? :smile:)
  • make sure the permissions template grants project admin to the “Creator” so that you can then edit the QG assignment without needing to bother the global admin. Of course, if your GL analysis is using a technical account (which is actually best practice) this won’t work.
  • provision the project before it’s first analysis (see what I said above about Creator rights) and set it’s QG then.

Well timed! The fix for this is actually coming in 8.4: MMF-1994.

 
HTH,
Ann

Hi Ann,

thanks for the answer. On stackoverflow i found “-Dsonar.qualitygate” to set the used quality gate but it refered to the sonarqube v2, so I think, it’s not available anymore :frowning:

I will try it once more to fix the tests. Maybe something wrong with my config if it’s normally work.

Sadly I can’t change the default and provision is also not an option for us. We might try it with permission templates. The weird thing is, that I’m the guy who have to configure our wrapper to work with the new sonar and every project has to work directly in sonar, but I don’t have full admin permissions :sweat_smile: So, I have to figure out what to do and then tell the admin where to click :roll_eyes:

Thanks for your help!