Git Product home page Git Product logo

clippy-reviewdog-filter's Introduction

A filter for integrating Clippy with Reviewdog

screenshot

What's this?

Reviewdog is an automated review tool. It extracts relevant parts for the patch from an output of an external linter, and reports the result in several formats, including GitHub Checks and GitHub comments.

clippy-reviewdog-filter is a simple filter for feeding Reviewdog an output of Clippy, the official linter for Rust.

How to try this locally

No more interesting than simply running Clippy if you run this locally, but if you want to try this out before putting this into a CI:

Install reviewdog: get the binary release or

$ go get -u github.com/haya14busa/reviewdog/cmd/reviewdog

Install clippy-reviewdog-filter: get the binary release or

$ cargo install --git https://github.com/qnighy/clippy-reviewdog-filter.git
cargo clippy --message-format json 2>&1 | clippy-reviewdog-filter | reviewdog -f=checkstyle -diff="git diff master"

Configuration example

Configuration taken from a sample repository:

travis.yml:

language: rust
env:
  global:
    # See the reviewdog manual for how to obtain the token.
    # Beware that, encrypted environment variables cannnot be seen in
    # builds for pull requests from fork repositories.
  - REVIEWDOG_GITHUB_API_TOKEN=0123456789abcdef0123456789abcdef0123456789abcdef
install:
- mkdir -p ~/bin
- export PATH="$HOME/bin/:$PATH"
- curl -fSL https://github.com/haya14busa/reviewdog/releases/download/0.9.11/reviewdog_linux_amd64 -o ~/bin/reviewdog
- curl -fSL https://github.com/qnighy/clippy-reviewdog-filter/releases/download/v0.1.1/clippy-reviewdog-filter-x86_64-unknown-linux-musl -o ~/bin/clippy-reviewdog-filter
- chmod +x ~/bin/reviewdog ~/bin/clippy-reviewdog-filter
- rustup component add clippy-preview
script:
- reviewdog -reporter=github-pr-review

.reviewdog.yml:

runner:
  clippy:
    cmd: 'find . -type f -name \*.rs -exec touch {} \;; cargo clippy --message-format json 2>&1 | clippy-reviewdog-filter'
    format: checkstyle

Note on security

If you want to use the github-pr-review reporter in .travis.yml, you're essentially going to publish your API Token to the submitters of pull requests, as they're free to run modified versions of .travis.yml on your Travis CI repo.

For better security, you may want to use the github-pr-check reporter instead or run reviewdog -reporter=github-pr-review in a more isolated environment, like in a dedicated GitHub Webhook server.

Of course, there's no problem with using github-pr-review in a private repository with no forks. In that case, you can just encrypt the github token using the travis encrypt command.

clippy-reviewdog-filter's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar kahirokunn avatar qnighy avatar sksat avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kahirokunn sksat

clippy-reviewdog-filter's Issues

Broken deserialize package_id in Rust 1.77.0 project

In Rust 1.77.0 project, cargo clippy --message-format json | clippy-reviewdog-filter panicked by I/O error when reading input: Custom { kind: InvalidData, error: Error("missing field version", line: 0, column: 0) }.

.package_id format changed like below.
Rust 1.76.0: "package_id": "registry+https://github.com/rust-lang/crates.io-index#[email protected]",
Rust 1.77.0: "package_id": "libc 0.2.150 (registry+https://github.com/rust-lang/crates.io-index)",

It comes from Package Id Spec stabilization (ref: https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md#cargo-177-2024-03-21).

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.