Git Product home page Git Product logo

pre-commit-java's Introduction

pre-commit-java

pre-commit

A collection of git hooks for Java to be used with the pre-commit framework.

Requirements

pre-commit-java requires the following to run:

Install

  1. create .pre-commit-config.yaml in you git project
  2. pre-commit install
  3. enjoy :)

example .pre-commit-config.yaml:

- repo: https://github.com/gherynos/pre-commit-java
  rev: v0.2.0  # Use the ref you want to point at
  hooks:
    - id: pmd
      exclude: /test/
    - id: cpd
      exclude: /test/
    - id: checkstyle
      exclude: /test/
    # ...

Available Hooks

Hook name Description
pmd Runs the PMD static code analyzer.
cpd Runs the Copy/Paste Detector (CPD).
checkstyle Runs the Checkstyle static code analysis tool.

Notes about the pmd hook

The default ruleset used is ruleset.xml, which runs all the Java rules with the exception of LoosePackageCoupling.

To specify a custom ruleset, simply pass the argument to the hook:

    - id: pmd
      args: ["-R", "my_ruleset.xml"]

Other CLI arguments are also supported, like -cache for incremental analysis.

Notes about the cpd hook

The default minimum token length is 100.

To change it, simply pass the argument to the hook:

    - id: cpd
      args: ['--minimum-tokens', '50']

Other CLI arguments are also supported.

Notes about the checkstyle hook

The default configuration used is sun_checks.xml.

To specify a custom one, simply pass the argument to the hook:

    - id: checkstyle
      args: ['-c', 'my_checks.xml']

Other CLI arguments are also supported.

Author

GitHub @gherynos

License

pre-commit-java is licensed under the GPLv3 license.

pre-commit-java's People

Contributors

gherynos avatar cunglam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.