#git-diff #clippy #git #diagnostics #cargo #cargo-clippy

bin+lib cargo-diff-tools

A tool to hide warning messages reported on source code lines that are not part of a git diff

3 releases

0.1.2 May 4, 2021
0.1.1 May 3, 2021
0.1.0 May 3, 2021

#24 in #clippy

Download history 263/week @ 2024-09-02 538/week @ 2024-09-09 439/week @ 2024-09-16 408/week @ 2024-09-23 116/week @ 2024-09-30 319/week @ 2024-10-07 324/week @ 2024-10-14 459/week @ 2024-10-21 515/week @ 2024-10-28 858/week @ 2024-11-04 740/week @ 2024-11-11 737/week @ 2024-11-18 448/week @ 2024-11-25 906/week @ 2024-12-02 946/week @ 2024-12-09 620/week @ 2024-12-16

2,930 downloads per month

MIT/Apache

18KB
363 lines

Cargo diff-tools

Run cargo check and cargo clippy hiding the warning messages whose primary line is not included in a git diff. Useful in large projects to hide warning messages that are probably not related to the changes made by a pull request.

Inspired by Patryk27/clippy-dirty.

Examples

Run cargo clippy hiding the warning messages whose primary line is not included in a git origin/master HEAD:

cargo-clippy-diff origin/master HEAD

The same, for cargo check:

cargo-check-diff origin/master HEAD

Various git diff arguments are supported:

cargo-clippy-diff HEAD      # internally calls `git diff HEAD`
cargo-clippy-diff --staged  # internally calls `git diff --staged`
cargo-clippy-diff first-branch...second-branch origin/master  # and so on

Place cargo check arguments after a --:

cargo-check-diff HEAD -- --all-features

Place cargo clippy arguments after a -- (note that the second -- is one of clippy's arguments):

cargo-clippy-diff HEAD -- --all-features -- -D clippy::lint_name

To display diagnostics as JSON objects, use --output=json:

cargo-clippy-diff --output=json origin/master HEAD

To display diagnostics as workflow commands in GitHub Actions (useful to automatically add comments to pull requests), use --output=github:

git fetch origin $GITHUB_BASE_REF --depth=1
cargo-clippy-diff --output=github $(git merge-base origin/$GITHUB_BASE_REF $GITHUB_SHA) $GITHUB_SHA
# Example output "::warning file=lib.rs,line=4,col=2::Missing semicolon"

For other cargo commands, filter-by-diff can be used to filter any stream of JSON diagnostics:

cargo build --message-format=json-diagnostic-rendered-ansi \
    | filter-by-diff --output=rendered origin/master HEAD

Dependencies

~4.5–6.5MB
~114K SLoC