Skip to content

Hide cargo/clippy warnings that are not in a `git diff`

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

fpoli/cargo-diff-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Install

cargo install cargo-diff-tools

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:

cargo-clippy-diff --output=github $(git merge-base $PR_BASE_SHA $PR_HEAD_SHA) $PR_HEAD_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

About

Hide cargo/clippy warnings that are not in a `git diff`

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Languages