For #13959: improve custom detekt violation output.

Before it used to output the violations all one one line. Now it looks
like:
```
MozillaStrictModeSuppression:
    'import mozilla.components.support.ktx.android.os.resetAfter' at
(17,1) in /StrictModeManager.kt
    Please use `components.strictMode.resetAfter` instead because it has
performance improvements and additional code to monitor for performance
regressions.

MozillaStrictModeSuppression:
    'setThreadPolicy(threadPolicy.build())' at (56,24) in
/StrictModeManager.kt
    Please use `components.strictMode.resetAfter` instead because it has
performance improvements and additional code to monitor for performance
regressions.

MozillaStrictModeSuppression:
    'setVmPolicy(builder.build())' at (71,24) in /StrictModeManager.kt
    NOT YET IMPLEMENTED: please consult the perf team about
implementing`StrictModeManager.resetAfter`: we want to understand the
performance implications of suppressing setVmPolicy before allowing it.
```
pull/216/head
Michael Comella 4 years ago committed by Michael Comella
parent b222376cb0
commit 66f220c22a

@ -1,13 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.detektrules
import io.gitlab.arturbosch.detekt.api.ConsoleReport
import io.gitlab.arturbosch.detekt.api.Detektion
/**
* A reporter that custom formats violations of our custom lint rules.
*/
class CustomRulesetConsoleReport : ConsoleReport() {
@Suppress("DEPRECATION")
@Suppress("DEPRECATION") // locationAsString
override fun render(detektion: Detektion): String? {
return detektion.findings["mozilla-detekt-rules"]?.fold("") { output, finding ->
output + finding.locationAsString + ": " + finding.messageOrDescription()
return detektion.findings["mozilla-detekt-rules"]?.fold("") { accumulator, finding ->
accumulator + "${finding.id}:\n ${finding.locationAsString}\n ${finding.messageOrDescription()}\n\n"
// This creates an extra newline at the very end but it's not worth fixing.
}
}
}
Loading…
Cancel
Save