This is a small Cargo subcommand, cargo tidy
, which allows you to configure
various code style checks to be executed. You can then put it in CI to make sure
that all PRs adhere to the rules.
An example configuration can be found in tidy-config.toml.
For example, tidy
allows you to check:
\n
as line endingsTidy can be installed like any other crate:
cargo install cargo-tidy
The cargo tidy
project itself uses cargo tidy
to check its own code style!
Take a look at the .travis.yml to see how to run it for your own project.
When working on a large-scale project which combines multiple programming
languages, you might want to run multiple sets of style checks. Or maybe you
just want different rules for .md
files than for .rs
files.
Since cargo tidy
allows specifying custom file globs, you can write multiple
configuration files for different file types (or folders).