All Projects → tomasbjerre → violation-comments-to-github-lib

tomasbjerre / violation-comments-to-github-lib

Licence: Apache-2.0 License
A library for commenting GitHub with violations from static code analyzer reports.

Programming Languages

java
68154 projects - #9 most used programming language

Violation Comments to GitHub Lib Build Status Maven Central Bintray

This is a library that adds violation comments from static code analysis to GitHub.

It uses Violation Comments Lib and supports the same formats as Violations Lib.

Very easy to use with a nice builder pattern

  violationsToGitHubApi() //
    .withViolations(".*/findbugs/.*\\.xml$", FINDBUGS, rootFolder) //
    .withViolations(".*/checkstyle/.*\\.xml$", CHECKSTYLE, rootFolder) //
    .withUsername("username") // This is Optional!
    .withPassword("password") // This is Optional!
    .usingOAuth2Token("token") // This is Optional!
    .withRepositoryOwner("repositoryOwner")
    .withRepositoryName("repositoryName")
    .withPullRequestId("pullRequestId")
    .toPullRequest();

Authentication can be done by supplying username/password or OAuth2Token in the builder.

Usage

This software can be used:

You may also checkout this blog post that explains how to set it up with Travis.

Travis

To set this up in Travis, you will need to create a GitHub OAuth2 token.

curl -u 'yourgithubuser' -d '{"note":"Violation comments"}' https://api.github.com/authorizations

The token needs to be encrypted before added to your .travis.yml.

sudo apt-get install ruby-dev
gem install travis
travis encrypt export GITHUB_OAUTH2TOKEN=YOUR TOKEN HERE

Now add it to .travis.yml like this.

sudo: false  
language: java  
env:  
  - secure: "YOUR ENCRYPTED TOKEN HERE"
jdk:  
  - oraclejdk7
script:  
  - ./gradlew build violationCommentsToGitHub -DGITHUB_PULLREQUESTID=$TRAVIS_PULL_REQUEST -DGITHUB_OAUTH2TOKEN=$GITHUB_OAUTH2TOKEN -i --stacktrace
notifications:  
  email: false

Here I used Gradle plugin but you can do the same thing with Maven plugin.

Developer instructions

To build the code, have a look at .travis.yml.

To do a release you need to do ./gradlew release and release the artifact from staging. More information here.

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].