![JAR search and dependency download from the Maven repository](/logo.png)
io.github.detekt.report.xml.XmlOutputReport.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of detekt-report-xml Show documentation
Show all versions of detekt-report-xml Show documentation
Static code analysis for Kotlin
The newest version!
package io.github.detekt.report.xml
import io.gitlab.arturbosch.detekt.api.Detektion
import io.gitlab.arturbosch.detekt.api.Finding
import io.gitlab.arturbosch.detekt.api.OutputReport
import java.util.Locale
import kotlin.io.path.invariantSeparatorsPathString
/**
* Contains rule violations in an XML format. The report follows the structure of a Checkstyle report.
* See: https://detekt.dev/configurations.html#output-reports
*/
class XmlOutputReport : OutputReport() {
override val ending = "xml"
override val name = "Checkstyle XML report"
private val Finding.severityLabel: String
get() = severity.name.lowercase(Locale.US)
override fun render(detektion: Detektion): String {
val smells = detektion.findings.flatMap { it.value }
val lines = ArrayList()
lines += ""
lines += ""
smells.groupBy { it.location.filePath.relativePath ?: it.location.filePath.absolutePath }
.forEach { (filePath, findings) ->
lines += ""
findings.forEach {
lines += arrayOf(
"\t "
).joinToString(separator = " ")
}
lines += " "
}
lines += " "
return lines.joinToString(separator = "\n")
}
private fun Any.toXmlString() = XmlEscape.escapeXml(toString().trim())
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy