SonarCloud - how to change code coverage ratio from default of 80%?

Hello,

I have an issue related to code coverage ratio. Our project is on kotling with gradle. We are using sonar cloud with GitHub actions, also the jacoco code coverage plugin configured with gradle. We configured jacoco with minimum code coverage less than 80%, but apparently sonar has its own ratio and cannot be overridden with that one that is using by jacoco.
Other thing is that we configured sonar to scan code per module, as we have a multi-module project.

My question is → Is there a way to configure sonar code coverage minimum percentage? Maybe there is some properties for sonar-properties, or in the github/workflow yml. config file.
So far I didn’t find anything after some researches, just that there some ways to configure Quality Gates from Sonar cloud.

sonar.host.url=https://sonarcloud.io
sonar.organization=****(masked)
sonar.projectKey=****(masked)
sonar.projectName=****(masked)
sonar.cpd.exclusions=/**/*.spec.*,/**/**/*.spec.*,**/__mocks__/*.*,**/__test__/*,**/localDev/**/*,**/test/*
sonar.coverage.exclusions=/**/*.spec.*,/**/**/*.spec.*,**/__mocks__/*.*,**/__test__/*,**/localDev/**/*,**/test/*
sonar.javascript.lcov.reportPaths=apps/gp-portal/build/reports/coverage/lcov.info, apps/****(masked)/build/reports/coverage/lcov.info, packages/****(masked)/build/reports/coverage/lcov.info, apps/admin/build/reports/coverage/lcov.info
sonar.exclusions=*/gradle,**/*.sql
sonar.coverage.jacoco.xmlReportPaths=jacoco/****(masked)/jacocoTestReport.xml,jacoco/****(masked)/jacocoTestReport.xml,jacoco/****(masked)/jacocoTestReport.xml,jacoco/****(masked)/jacocoTestReport.xml,jacoco/****(masked)/jacocoTestReport.xml

Here are the sonar-properties

Hey there.

I’m not sure what you mean by this – is there something in JaCoCo that allows you to set a code coverage threshold?

If you need to adjust your Quality Gate (to adjust the threshold, which cannot be set any other way), you should check the documentation on Managing Quality Gates.

Yes, there is a way to configure jacoco code coverage rules, here is what I meant:

tasks.withType<JacocoCoverageVerification>{
		violationRules {
			rule {
				element = "BUNDLE"
				limit {
					counter = "INSTRUCTION"
					value = "COVEREDRATIO"
					minimum = "0.5".toBigDecimal()
				}
			}
		}

As you can see the minimum code coverage is set to 50%, even so, sonar is using its own code coverage threshold. Thanks a lot for your answer.