Danger Kotlin - Android Lint Plugin

A plugin for Danger Kotlin for Android Lint

License

License

Categories

Categories

Kotlin Languages
GroupId

GroupId

com.gianluz
ArtifactId

ArtifactId

danger-kotlin-android-lint-plugin
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Danger Kotlin - Android Lint Plugin
A plugin for Danger Kotlin for Android Lint
Project URL

Project URL

https://github.com/gianluz/danger-kotlin-android-lint-plugin
Source Code Management

Source Code Management

https://github.com/gianluz/danger-kotlin-android-lint-plugin

Download danger-kotlin-android-lint-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/com.gianluz/danger-kotlin-android-lint-plugin/ -->
<dependency>
    <groupId>com.gianluz</groupId>
    <artifactId>danger-kotlin-android-lint-plugin</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.gianluz/danger-kotlin-android-lint-plugin/
implementation 'com.gianluz:danger-kotlin-android-lint-plugin:0.1.0'
// https://jarcasting.com/artifacts/com.gianluz/danger-kotlin-android-lint-plugin/
implementation ("com.gianluz:danger-kotlin-android-lint-plugin:0.1.0")
'com.gianluz:danger-kotlin-android-lint-plugin:jar:0.1.0'
<dependency org="com.gianluz" name="danger-kotlin-android-lint-plugin" rev="0.1.0">
  <artifact name="danger-kotlin-android-lint-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gianluz', module='danger-kotlin-android-lint-plugin', version='0.1.0')
)
libraryDependencies += "com.gianluz" % "danger-kotlin-android-lint-plugin" % "0.1.0"
[com.gianluz/danger-kotlin-android-lint-plugin "0.1.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.70
systems.danger : danger-kotlin-sdk jar 1.0
commons-io : commons-io jar 2.6
org.snakeyaml : snakeyaml-engine jar 2.1

Project Modules

There are no modules declared in this project.

Maven Central Build Status

danger-kotlin-android-lint-plugin

Show the Android lint errors on your PR with Danger Kotlin

Setup

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)
                )
        }
    }

Configuration for the default report

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

Accepted values are:

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: 3
errors: 1
fatals: 1
warnings: Int
errors: Int
fatals: Int
total: Int

Versions

Version
0.1.0
0.0.3
0.0.1