/check_diff

WIP

Primary LanguageGoMIT LicenseMIT

check_diff (wip)

Coverage Status

check_diff is a command-line tool targeted to apply static checks on changed files and lines.

Install

go install

go install github.com/iarkhanhelsky/check_diff@latest

manually

Download the pre-compiled binaries from the releases page and copy them to the desired location.

Setup

Local

  1. Create empty check_diff.yaml file in your project root directory.
  2. Specify your linters configuration in check_diff.yaml
  3. Change any of your source files introducing lint errors
  4. Run the following command to check your changes
    $ git diff | check_diff 
    

git hooks

Create simple git hook to check each commit you made: .git/hook/pre-commit

#!/bin/bash
git diff | bin/check_diff

CI

Gitlab

See Gitlab docs for more information

Example step configuration

check-diff:
  stage: test
  script:
    # Find merge base and make a diff. We don't need changes that appeared in
    # upstream after feature branch was created
    - git diff -r $(git merge-base $CI_MERGE_REQUEST_DIFF_BASE_SHA HEAD) | ./bin/check_diff --format gitlab -o .gitlab-lint
  artifacts:
    reports:
      codequality: .gitlab-lint

Builtin linter bindings

Language Linter Bundled Version Tested With
Go golangci-lint 1.46.0 -//-
Java Checkstyle 9.3 -//-
K8S kube-linter 0.2.5 -//-
Ruby rubocop 1.25.1
Script&Regexp

Output formats

  • STDOUT - print lint issues in human-readable format
  • Phabricator
  • Codeclimate