#diff #git-diff #lint #clippy #pedantic

cargo-scout-lib

Lib that powers cargo-scout, and allows you to run / implement your own linters

1 unstable release

0.6.0 Jan 12, 2020

#2211 in Development tools


Used in cargo-scout

MIT/Apache

52KB
1.5K SLoC

cargo-scout

Contributor Covenant Travis Build Status MPL 2.0 License MIT License

Leave this world a little better than you found it

A cargo subcommand to get clippy::pedantic lints or rustfmt lints for the changes you have made in a codebase.

Commands and their bash pseudocode would probably look like this:

# run clippy pedantic on a diff
$ cargo-scout lint # git diff | cargo clippy -- -D clippy::pedantic

# run rustfmt on a diff
$ cargo-scout fmt # git diff | cargo fmt --check

There's more to it (the commented code wouldn't work), such as workspace management and quite a lot of flags that will hopefully match your usecase. You can find them by running the commands with -h or --help.

If cargo-scout is missing a feature for you to use it, consider filing an issue!

$ cargo-scout -h
$ cargo-scout lint -h
$ cargo-scout fmt -h

Current Status

cargo-scout is experimental and in a very rough draft for now.

The current minimum Rust version supported is 1.37 stable.

Prerequisites

Git: In order to compute a set of changes, it requires a project running git.

The linter uses clippy and the formatter uses rustfmt. Head over to the respective links to figure out how to install it.

Rust nightly: Some commands require a nightly edition of rust, because the features we use aren't available in stable yet (rustfmt --emit json and some cargo clippy features in a workspace setting).

We try to keep a close eye to the relevant tracking issues and hope we can switch it to stable soon. If the issues evolved and we didn't notice, please file an issue and let us know!

How to install

$ cargo install cargo-scout

How to run it

Open a shell, go to the project you would like to run the command in, and run cargo-scout, with an optional target branch:

$ cargo-scout lint # clippy::pedantic lints on a diff with HEAD
$ cargo-scout fmt # rustfmt lints on a diff with HEAD

Each command and subcommand supports -h and --help:

A git diff will be queried and clippy will be run as well, searching for lints that may apply to your diff.

If some lints can apply, the command execution will error out. This design decision has been made so you can put it in your CI pipeline at some point (but please wait for 1.0 release ^^').

Code of Conduct

We have a Code of Conduct so as to create a more enjoyable community and work environment. Please see the CODE_OF_CONDUCT file for more details.

License

Licensed under either of

at your option.

Dual MIT/Apache2 is strictly more permissive

Dependencies

~12MB
~268K SLoC