All Projects → btkelly → Gnag

btkelly / Gnag

Licence: other
A Gradle plugin that helps facilitate GitHub PR checking and automatic commenting of violations.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Gnag

Gradle Static Analysis Plugin
Easy setup of static analysis tools for Android and Java projects.
Stars: ✭ 398 (+231.67%)
Mutual labels:  gradle, checkstyle, findbugs, pmd
static-code-analysis-plugin
A plugin to simplify Static Code Analysis on Gradle. Not restricted to, but specially useful, in Android projects, by making sure all analysis can access the SDK classes.
Stars: ✭ 36 (-70%)
Mutual labels:  gradle, findbugs, pmd, checkstyle
Gradle Code Quality Tools Plugin
Gradle plugin that generates ErrorProne, Findbugs, Checkstyle, PMD, CPD, Lint, Detekt & Ktlint Tasks for every subproject.
Stars: ✭ 282 (+135%)
Mutual labels:  gradle, checkstyle, findbugs, pmd
Quality Checks
Gradle plugin which includes Checkstyle, FindBugs, and PMD basic configuration.
Stars: ✭ 38 (-68.33%)
Mutual labels:  gradle, checkstyle, findbugs, pmd
Gradle Quality Plugin
Gradle quality plugin for Java and Groovy
Stars: ✭ 97 (-19.17%)
Mutual labels:  gradle, checkstyle, findbugs, pmd
Debt-Manager
A personal app to store people that owe you money or you owe money to. "Mo Money Mo Problems" 🎵 - The Notorious B.I.G. 😎
Stars: ✭ 22 (-81.67%)
Mutual labels:  findbugs, pmd, checkstyle
Okcheck
Incremental scan,integrate Lint、KtLint、UnitTest、Checkstyle、Findbugs、Pmd, powerful and easy to use
Stars: ✭ 285 (+137.5%)
Mutual labels:  checkstyle, findbugs, pmd
Warnings Ng Plugin
Jenkins Warnings Plugin - Next Generation
Stars: ✭ 248 (+106.67%)
Mutual labels:  checkstyle, findbugs, pmd
java-quality-checks
No description or website provided.
Stars: ✭ 33 (-72.5%)
Mutual labels:  findbugs, pmd, checkstyle
Kotlin Android Starter
[Kotlin Android] Kotlin Android starter based MVP/Dagger2/RxJava2/Robolectric/Espresso/Mockito. It provides a generator to fast create a Kotlin Android project.
Stars: ✭ 589 (+390.83%)
Mutual labels:  checkstyle, findbugs, pmd
Android Starter
[Android Architecture] Android starter based on MVP/Dagger2/RxJava2/Robolectric/Espresso/Mockito. It provides a generator to fast create a Android template project.
Stars: ✭ 522 (+335%)
Mutual labels:  checkstyle, findbugs, pmd
Codeanalysis
Android静态代码分析
Stars: ✭ 31 (-74.17%)
Mutual labels:  checkstyle, findbugs, pmd
analysis-model
A library to read static analysis reports into a Java object model
Stars: ✭ 74 (-38.33%)
Mutual labels:  pmd, checkstyle
ForgeModdingSkeleton
Skeletons for building Forge mods
Stars: ✭ 21 (-82.5%)
Mutual labels:  pmd, checkstyle
spring-boot-java-swing-reservations
The project aims to present how to connect Spring Boot 2 and Java Swing GUI widget toolkit. All application dependencies are provided by Docker Compose. There are also static code analysis tools like FindBugs and Checkstyle.
Stars: ✭ 86 (-28.33%)
Mutual labels:  findbugs, checkstyle
advanced-spring-scaffold
This project provides an advanced baseline to help you kick start a Spring project.
Stars: ✭ 21 (-82.5%)
Mutual labels:  pmd, checkstyle
JSR305CheckstylePlugin
a plugin which ensures nullness annotations on methods and constructors
Stars: ✭ 19 (-84.17%)
Mutual labels:  findbugs, checkstyle
gradle-circle-style
🚀🚀🚀MOVED TO Baseline
Stars: ✭ 28 (-76.67%)
Mutual labels:  findbugs, checkstyle
qulice
Quality Police for Java projects: aggregator of Checkstyle, PMD, and SpotBugs
Stars: ✭ 286 (+138.33%)
Mutual labels:  pmd, checkstyle
diff-check
Incremental code analysis tools based on checkstyle, pmd and jacoco
Stars: ✭ 48 (-60%)
Mutual labels:  pmd, checkstyle

Gnag Coverage Status Android Arsenal

Gnag is a Gradle plugin that helps facilitate GitHub PR checking and automatic commenting of violations for Android projects.

It can be used in Java-only, Kotlin-only, and mixed Java/Kotlin codebases.

The name is a portmanteau of the words "Gradle" and "nag". The first "g" is silent!

Example Output

Below are examples of output posted to a GitHub PR on a project using Gnag to enforce quality checks.

Violations associated with a specific line in your PR will be posted as comments on that line:

Violations that are not associated with a specific line in your PR will be aggregated and posted in a single top-level PR comment:

Usage

Requires JDK 8

Gnag is meant to be simple to use and easy to drop in to any Android project. Shown below is the simplest Gnag setup that will report violations to GitHub. By default this config will report PMD, Findbugs, Checkstyle and Android Lint to GitHub.

build.gradle (Groovy)
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.btkelly:gnag:{current version}'
    }
}

apply plugin: 'gnag'

gnag {
    github {
        repoName 'btkelly/repo'
        authToken '0000000000000'
        issueNumber '1'
    }
}
build.gradle.kts (Kotlin)
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath("com.btkelly:gnag:{current version}")
    }
}

plugins {
    id("gnag")
}

gnag {
    github {
        repoName("btkelly/repo")
        authToken("0000000000000")
        issueNumber("1")
    }
}

This is the simplest way to add automatic PR checking and commenting to your project. The options defined in the github closure can be overridden by passing command line parameters with the same name to your build. This is helpful when using in conjunction with a CI system to allow automated builds.

Tasks

You can use the gnagCheck gradle task to run Gnag locally and generate an HTML report in the build directory.

./gradlew clean gnagCheck

You can use the gnagReport task which will first run gnagCheck and then report detected violations to the GitHub issue specified. In this example the issue number and authtoken for the comment user are passed as commandline arguments.

./gradlew clean gnagReport -PissueNumber=11 -PauthToken=iu2n3iu2nfjknfjk23nfkj23nk

Customization

build.gradle (Groovy)
gnag {
    enabled true
    failOnError true

    checkstyle {
        enabled true
        reporterConfig project.file('config/checkstyle.xml')
    }

    pmd {
        enabled true
        reporterConfig project.file('config/pmd.xml')
    }

    findbugs {
        enabled true
        reporterConfig project.file('config/findbugs.xml')
    }

    ktlint {
        enabled true
        toolVersion "0.35.0"
    }

    detekt {
        enabled true
        reporterConfig project.file('config/detekt.yml')
        toolVersion "1.0.1"
    }

    androidLint {
        enabled true
        severity 'Error'
    }

    github {
        rootUrl 'https://my.githubinstall.com/repos/'
        repoName 'btkelly/repo'
        authToken '0000000000000'
        issueNumber '1'
        setCommentInline true
        setCommentOnSuccess true
        useGitHubStatuses true
    }
}
build.gradle.kts (Kotlin)
gnag {
    isEnabled = true
    setFailOnError(true)

    checkstyle {
        isEnabled = true
        reporterConfig(project.file("config/checkstyle.xml"))
    }

    pmd {
        isEnabled = true
        reporterConfig(project.file("config/pmd.xml"))
    }

    findbugs {
        isEnabled = true
        reporterConfig(project.file("config/findbugs.xml"))
    }

    ktlint {
        isEnabled = true
        toolVersion("0.35.0")
    }

    detekt {
        isEnabled = true
        reporterConfig(project.file("config/detekt.yml"))
    }

    androidLint {
        isEnabled = true
        severity("Error")
    }

    github {
        rootUrl("https://my.githubinstall.com/repos/")
        repoName("btkelly/repo")
        authToken("0000000000000")
        issueNumber("1")
        setCommentInline(true)
        setCommentOnSuccess(true)
        useGitHubStatuses(true)
    }
}

NOTE: All reporters are enabled by default

  • enabled - easily disable Gnag in specific situations

  • failOnError - should violations cause the build to fail or just generate a report; if set to false, you may need to add the following to prevent your build still failing from Android Lint errors:

    build.gradle (Groovy)
    android {
        lintOptions {
            abortOnError false
        }
    }
    
    build.gradle.kts (Kotlin)
    android {
        lintOptions {
            abortOnError(false)
        }
    }
    
  • checkstyle - block to customize the checkstyle reporter

    • enabled - set if checkstyle should execute
    • reporterConfig - provide a custom checkstyle config (see the default config here)
  • pmd - block to customize the PMD reporter

    • enabled - set if PMD should execute
    • reporterConfig - provide a custom PMD config (see the default config here)
  • findbugs - block to customize the findbugs reporter

    • enabled - set if findbugs should execute
    • reporterConfig - provide a custom findbugs config
  • ktlint - block to customize the ktlint reporter

    • enabled - set if ktlint should execute
    • toolVersion - override the ktlint version compiled into Gnag
  • detekt - block to customize the detekt reporter

    • enabled - set if detekt should execute
    • reporterConfig - provide a custom detekt config
    • toolVersion - override the detekt version compiled into Gnag
  • androidLint - block to customize the android lint reporter

    • enabled - set if the android lint reporter should look for a lint report
    • severity - can be 'Error' or 'Warning' (case insensitive) depending on which severity you want Gnag to check
  • github - block to customize GitHub reporting (only used during the gnagReport task

    • rootUrl - root URL to use when communicating with the GitHub API (must include trailing slash), if not provided will default to "https://api.github.com/repos/"
    • repoName - account and repo name to report violations to
    • authToken - a GitHub token for a user that has access to comment on issues to the specified repo
    • issueNumber - the issue or PR number currently being built
    • setCommentInline - whether or not comments posted to GitHub should be placed inline where possible
    • setCommentOnSuccess - whether or not a comment should be posted to GitHub when no violations exist
    • useGitHubStatuses - should report GitHub status on each module in the PR or just fail if failOnError enabled

Multi-Module Projects

To enforce the same quality checks across multiple Gradle modules, apply and configure Gnag in your root build.gradle file as follows (you can remove the equivalent code from submobule build.gradle files):

build.gradle (Groovy)
buildscript {
    repositories {
        // ...
        jcenter()
    }

    dependencies {
        // ...
        classpath 'com.btkelly:gnag:2.4.1'
    }
}

subprojects {
    apply plugin: 'gnag'

    gnag {
        // Standard Gnag configuration goes here.
        //
        // Reference tool configuration files using the rootProject:
        //   reporterConfig rootProject.file('config/toolrules.xml')
    }
}
build.gradle.kts (Kotlin)
buildscript {
    repositories {
        // ...
        jcenter()
    }

    dependencies {
        // ...
        classpath("com.btkelly:gnag:2.4.1")
    }
}

subprojects {
    apply(plugin = "gnag")

    configure<com.btkelly.gnag.extensions.GnagPluginExtension> {
        // Standard Gnag configuration goes here.
        //
        // Reference tool configuration files using the rootProject:
        //   reporterConfig(rootProject.file("config/toolrules.xml"))
    }
}

You may need to keep the Android lint portions of your configuration in submodule build.gradle files if your project includes non-Android submodules. In this case, you should also use the rootProject to reference any shared lint configuration file.

Example Travis CI Usage

Travis is a continuous integration service and is free for open source projects. Below is an example of how to configure Gnag to run on Travis.

You must set an environment variable on your Travis instance for the PR_BOT_AUTH_TOKEN used to post comments back to GitHub.

.travis.yml

language: android
android:
  components:
  - platform-tools
  - tools
  - build-tools-25.0.3
  - android-25
jdk:
  - openjdk8
branches:
  only:
  - master
script: "./travis-build.sh"

travis-build.sh

#!/bin/bash
set -ev

if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
	./gradlew clean gnagCheck
else
	./gradlew clean gnagReport -PauthToken="${PR_BOT_AUTH_TOKEN}" -PissueNumber="${TRAVIS_PULL_REQUEST}"
fi

License

Copyright 2016 Bryan Kelly

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].