Allow configuring rule parameters in code

I’ve read How do we change the ‘parameters’ to rules? and I saw that you have multiple ways to change parameter rules:

  • In the SonarCloud/SonarQube web UI
  • In IDE settings

None of these are ideal for me, because I need a single-source-of-truth one place where I can configure my settings, and usually I do configuration in my code source repository:

  • If I disable a rule completely in my build tool or sonar-project.properties file, every tool including SonarQube for IDE should pick them up.
  • If I change parameters, I shouldn’t be needed to do it in multiple IDEs one by one.

It shouldn’t matter if I’m in connected mode or not. The code should control the settings. So what would be ideal:

  • Let us configure rule settings in a file that is read by everything. (This could be sonar-project.properties, even if we use the SonarScanner for Gradle plugin.) By everything I mean every scanner that matters, and SonarQube for IDE.

Thanks for considering.

I’ve noticed that Configure rule parameters in non-connected mode in VSCode’s SonarLint is asking for a similar feature, but it’s from 6 years ago, and I don’t see any change.

Hi,

The canonical answer here is to configure the rules via the UI, then use SonarQube for IDE’s Connected Mode to pull in that same rule configuration.

Nonetheless, I understand your argument; you’re not the first to argue (vehemently, sometimes) for configuration as code.

I’m going to flag this for the PMs. (But I wouldn’t hold my breath if I were you.)

 
Ann

Thanks, Ann, for your reply.

To be honest, I can perfectly understand others:

  • Configuration as Code is a core principle of DevOps, with reasons that also apply to SonarQube Cloud settings.
  • We can already disable rules in sonar properties, so customizing their parameters shouldn’t be treated differently.

I just wanted to add that.

Thanks for considering!