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

io.gitlab.arturbosch.detekt.cli.console.ReportFormatting.kt Maven / Gradle / Ivy

There is a newer version: 1.23.7
Show newest version
package io.gitlab.arturbosch.detekt.cli.console

import io.gitlab.arturbosch.detekt.api.Debt
import io.gitlab.arturbosch.detekt.api.Finding

internal const val PREFIX = "\t- "

internal fun Any.format(prefix: String = "", suffix: String = "\n") = "$prefix$this$suffix"

internal fun printFindings(findings: Map>): String? {
    return with(StringBuilder()) {
        val debtList = mutableListOf()
        findings.forEach { (key, issues) ->
            val debt = issues
                .map { it.issue.debt }
                .reduce { acc, d -> acc + d }
            debtList.add(debt)
            append("$key - $debt debt".format())
            val issuesString = issues.joinToString("") {
                it.compact().format("\t")
            }
            append(issuesString.yellow())
        }
        val overallDebt = debtList.reduce { acc, d -> acc + d }
        append("Overall debt: $overallDebt".format("\n"))
        toString()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy