intellij-ideakotlincode-inspectionintellij-inspections

Suppressing warnings about an unused Kotlin property in IDEA


Consider I have a parameterized TestNG test:

val parameters: Array<Array<Any>>
    @DataProvider
    get() {
        val parameters = arrayListOf<Array<Any>>()
        // ...
        return parameters.toTypedArray()
    }

@Test(dataProvider = "getParameters")
fun test(p1: Any, pN: Any) {
    // ...
}

How do I stop IDEA from complaining that the data provider property (parameters in our case) is unused? Annotating the property with @get:SuppressWarnings("unused") is not helpful.


Solution

  • There turned out to be a workaround. Rewriting the annotation like this:

    @get:DataProvider
    val parameters: Array<Array<Any>>
    

    makes IDEA treat the property as an entry point.

    The corresponding ticket is KT-28031.