All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gitlab.arturbosch.detekt.extensions.DetektReports.kt Maven / Gradle / Ivy

package io.gitlab.arturbosch.detekt.extensions

import io.gitlab.arturbosch.detekt.extensions.DetektReportType.HTML
import io.gitlab.arturbosch.detekt.extensions.DetektReportType.SARIF
import io.gitlab.arturbosch.detekt.extensions.DetektReportType.TXT
import io.gitlab.arturbosch.detekt.extensions.DetektReportType.XML
import org.gradle.api.Action
import org.gradle.api.model.ObjectFactory
import javax.inject.Inject

@Suppress("TooManyFunctions")
open class DetektReports @Inject constructor(val objects: ObjectFactory) {

    val xml: DetektReport = objects.newInstance(DetektReport::class.java, XML)

    val html: DetektReport = objects.newInstance(DetektReport::class.java, HTML)

    val txt: DetektReport = objects.newInstance(DetektReport::class.java, TXT)

    val sarif: DetektReport = objects.newInstance(DetektReport::class.java, SARIF)

    val custom = mutableListOf()

    fun xml(action: Action): Unit = action.execute(xml)

    fun html(action: Action): Unit = action.execute(html)

    fun txt(action: Action): Unit = action.execute(txt)

    fun sarif(action: Action): Unit = action.execute(sarif)

    fun custom(action: Action): Unit = action.execute(createAndAddCustomReport())

    private fun createAndAddCustomReport() =
        objects.newInstance(CustomDetektReport::class.java).apply { custom.add(this) }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy