sonar-scanner-gradle icon indicating copy to clipboard operation
sonar-scanner-gradle copied to clipboard

Make value of SonarProperties#property nullable

Open Vampire opened this issue 5 months ago • 3 comments

I'm porting a Groovy DSL build to Kotlin DSL.

Before I did things like

property('foo', [...] ?: null)

to override foo and either set it to some value or unset it otherwise.

In Kotlin DSL you cannot do

property("foo", listOf(...).takeIf { it.isNotEmpty() })

currently due to the @ParametersAreNonnullByDefault in the package-info.java and Kotlin respecting that, so having the value parameter non-nullable. Work-around is to use

properties["foo"] = listOf(...).takeIf { it.isNotEmpty() }

or

listOf(...).also { if (it.isNotEmpty()) property("foo", it) else properties.remove("foo") }

This PR makes the value parameter nullable, so you can also use the first Kotlin snippet above.

Vampire avatar Sep 10 '24 01:09 Vampire