Permanent Exceptions - Custom Rules

Hello to everyone in the community,
I have a few questions about SonarCloud.

Repo Language: Swift

1- I have a framework that I use in all my projects, and this framework has a function that I use, and I call this function with the same parameters more than once for various reasons. Sonar analysis naturally marks this as duplication. But actually this is not a duplication for my projects. My question is: can I ensure that for all of my projects as permanently not counted as duplication?

2- A similar issue with my first question. Again, in all of my projects, there is a string constant that I use and it contains “password” text. Actually this is a key I use for localization in the app interface. SonarCloud naturally marks this as CodeSmell. But actually this is not a code smell for my projects. My question is: can I ensure that for all of my projects as permanently not counted as CodeSmell?

3- Can I add exceptions project specific? Like the exceptions that I told my questions above? In other words, an exception is active in one project and deactive in another.

4- My last question: Is it possible to define custom rules on SonarCloud like SonarQube? I’m not talking about Quality Profile and Quality Gate. And can the content of an existing rule be modified? like regex of the rule.

I hope the questions will be enlightening for people who have similar questions.
Thank you very much for your answers in advance.

Hi Mustafa,

  1. We currently don’t have a way to accept or ignore some duplication, but I remember that we already had some internal discussions about this, I just can’t tell when we will tackle this subject, it’s not very high currently in our priorities. But you might be able to get around this by increasing a little bit the duplication threshold in your quality gate.

  2. You could create a custom quality profile and eventually disable this rule if it only bring noise to you. It’s also possible to customize a bit this rule when you activate it in a custom quality profile:
    image

  3. Yes you can create multiple quality profiles with different set of rules.

  4. No we don’t support custom rules on SonarCloud, we also don’t support community analyzers/plugins. But still some rules can be customized (like the regex) when they are activated in a new quality profile. The current experience to customize those rule is not so great, if you want to change a rule that is already activated in one of your quality profile, you will have to deactivate it and then reactivate it to update the parameter.

HTH

Thank you for answers

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.