How to set sonar.issue.ignore.block in sonar-project.properties

Hello, I’m wondering how I might set the setting sonar.issue.ignore.block in the sonar-project.properties file?

I see from the SonarCloud UI the web form has the name for the block begin and end regex patterns as settings[sonar.issue.ignore.block][beginBlockRegexp] and settings[sonar.issue.ignore.block][endBlockRegexp], but this does not help me understand how to set this value in a .properties file.

Thanks

1 Like

Interesting…

And then there is this

So. I am assuming the docs over here ( Narrowing the focus with an analysis scope ) are just not accurate.

Hi @dschnare,

We recommend users to use the UI to configure this, for best experience. Consider the configuration via sonar-project.properties as an undocumented hack, not official supported that may or may not work reliably, use at your own risk.

Cheers,
Janos

Well that’s entirely misleading. The documentation clearly shows properties that can be set in a project analysis configuration file. Shouldn’t the documentation for SonarCloud reflect that the project configuration files are a hack or not even mention them then?

Is the sonar-project.properties file being deprecated for SonarCloud projects?

https://sonarcloud.io/documentation/analysis/analysis-parameters/

For anyone using project configuration files:

sonar.issue.ignore.allfile=e1
sonar.issue.ignore.allfile.e1.fileRegexp=@sonar-disable
sonar.issue.ignore.block=e2
sonar.issue.ignore.block.e2.beginBlockRegexp=@sonar-ignore
sonar.issue.ignore.block.e2.endBlockRegexp=@end

Are examples of how to set sonar.issue.ignore.allfile and sonar.issue.ignore.block.

You linked to the Analysis Parameters page, which doesn’t mention the sonar.issue.ignore.* properties, because this is not something we want to support. Consistent with that, the Narrowing the Focus page clearly says that the multi-value properties can only be set by the web interface. And again, it doesn’t mention the sonar.issue.ignore.* property names.

So I don’t see what is misleading here. The bottom line seems simple:

Do let me know what I’m missing.

Not for the moment.

1 Like

Ah fair enough. Too bad the sonar-project.properties file doesn’t have parity with what can be set in the UI, it would have made it a great option to configure your project settings.

4 Likes

Fully agree, the setup/project config must be possible to be automated and having any UI option isn’t really helpful when working with hundreds of projects and pipelines …

2 Likes

I concur, @janos can you create an internal ticket for adding it to the official documentation?

This works perfectly fine via sonar-project.properties files and this should be the way to configure rule exclusions in the spirit of “configuration as code approach”.

There are use cases in which there is a multi-repository project that is e.g. Typescript based and we need to disable a rule for all repositories in that project (i.e. portfolio, not SQ project).
Disabling it via UI is impossible for directory layout reasons and also because the SQ (hosted) instance is multi-tenant - we want the projects to be self-responsible for their configuration and manage it exactly via the properties file :slight_smile:

1 Like

Where in the UI do we specify the “block expressions”? I’ve tried to going to Analysis Scope, but I dont see the screen. And I’m set as ADMIN.

This is the documentation I am following: Analysis Scope | SonarCloud Docs

I’m late to this, but I cant find the UI so set this information. I also tried setting the properties file, and it didn’t work either. We are using Typescript, and the properties file is name “.sonarcloud.properties” … does that make a difference? I tried creating a properties file with several different names: “sonar-cloud.prproperties” , “sonar-project.properties” … none worked or had any effect.