Show the Android lint errors on your PR with Danger Kotlin
Install and run Danger Kotlin as normal and in your Dangerfile.df.kts add the following dependency:
@file:DependsOn("com.gianluz:danger-kotlin-android-lint-plugin:0.1.0")Then register your plugin before the danger initialisation and use the plugin:
register plugin AndroidLint val danger = Danger(args) // Default report AndroidLint.report("/path/to/the/androidlint/result/file.xml")You can report more than one lint file.
You can also keep tidy your DangerFile.df.kts using the following block:
androidLint { [...] }Or make your own custom report by manipulating all the issues found, for example failing the build at the first Fatal found in a specific module.
androidLint { // Fail for each Fatal in a single module val moduleLintFilePaths = find( moduleDir, "lint-results-debug.xml", "lint-results-release.xml" ).toTypedArray() parseAllDistinct(*moduleLintFilePaths).forEach { if(it.severity == "Fatal") fail( "Danger lint check failed: ${it.message}", it.location.file.replace(System.getProperty("user.dir"), ""), Integer.parseInt(it.location.line) ) } }You can customise the aspect of your default reports defining the configuration file androidlint.dangerplugin.yml
logLevel: WARNING format: "{severity}: {message}" failIf: warnings: 3 errors: 1 fatals: 1 total: 3| SETTING | DESCRIPTION | DEFAULT | ACCEPTED VALUES |
|---|---|---|---|
logLevel | Report all the lints with severity >= logLevel | WARNING | WARNING, ERROR, FATAL |
format | Define a custom message for your lints | "{severity}: {message}" | {id}, {severity}, {message}, {category},{priority}, {summary}, {explanation}, {url},{urls}, {errorLine1}, {errorLine2} |
failIf | Fail your PR if the condition is satisfied: for example in this case will fail if there are at least: 3 warnings or 1 error or 1 fatal. | warnings: 3errors: 1fatals: 1 | warnings: Interrors: Intfatals: Inttotal: Int |