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
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
|
package org.mozilla.fenix.detektrules
|
||||||
|
|
||||||
import io.gitlab.arturbosch.detekt.api.ConsoleReport
|
import io.gitlab.arturbosch.detekt.api.ConsoleReport
|
||||||
import io.gitlab.arturbosch.detekt.api.Detektion
|
import io.gitlab.arturbosch.detekt.api.Detektion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reporter that custom formats violations of our custom lint rules.
|
||||||
|
*/
|
||||||
class CustomRulesetConsoleReport : ConsoleReport() {
|
class CustomRulesetConsoleReport : ConsoleReport() {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION") // locationAsString
|
||||||
override fun render(detektion: Detektion): String? {
|
override fun render(detektion: Detektion): String? {
|
||||||
return detektion.findings["mozilla-detekt-rules"]?.fold("") { output, finding ->
|
return detektion.findings["mozilla-detekt-rules"]?.fold("") { accumulator, finding ->
|
||||||
output + finding.locationAsString + ": " + finding.messageOrDescription()
|
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…
Reference in New Issue