-
-
Notifications
You must be signed in to change notification settings - Fork 757
/
DetektReports.kt
41 lines (26 loc) · 1.62 KB
/
DetektReports.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package io.gitlab.arturbosch.detekt.extensions
import io.gitlab.arturbosch.detekt.extensions.DetektReportType.HTML
import io.gitlab.arturbosch.detekt.extensions.DetektReportType.MD
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 md: DetektReport = objects.newInstance(DetektReport::class.java, MD)
val custom = mutableListOf<CustomDetektReport>()
fun xml(action: Action<in DetektReport>): Unit = action.execute(xml)
fun html(action: Action<in DetektReport>): Unit = action.execute(html)
fun txt(action: Action<in DetektReport>): Unit = action.execute(txt)
fun sarif(action: Action<in DetektReport>): Unit = action.execute(sarif)
fun md(action: Action<in DetektReport>): Unit = action.execute(md)
fun custom(action: Action<in CustomDetektReport>): Unit = action.execute(createAndAddCustomReport())
private fun createAndAddCustomReport() =
objects.newInstance(CustomDetektReport::class.java).apply { custom.add(this) }
}