Skip to content

Commit 9a09c9d

Browse files
committed
Add usage instructions of cargo clippy build
1 parent 53dfc4f commit 9a09c9d

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ Now you can run Clippy by invoking the following command:
8888
cargo clippy
8989
```
9090

91+
You can also test or build your project with Clippy lints as add-on with this command:
92+
93+
```terminal
94+
cargo clippy build
95+
cargo clippy test
96+
```
97+
9198
#### Automatically applying Clippy suggestions
9299

93100
Clippy can automatically apply some lint suggestions, just like the compiler. Note that `--fix` implies

book/src/continuous_integration/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ your crate for maximum compatibility. E.g. if your crate is compiled with the
1616
1717
This chapter will give an overview on how to use Clippy on different popular CI
1818
providers.
19+
20+
## CI Time optimization
21+
22+
You can optimize time in your CI by running `cargo clippy test`, this will test your application at the same time as
23+
it's linted. If Clippy doesn't report anything (or only has warnings), you will be saving precious CI time, as
24+
there's no need to rebuild your application.
25+
26+
So, compilation time is halved compared to running `cargo clippy` and THEN `cargo test`.

book/src/usage.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ just run
1616
cargo clippy
1717
```
1818

19+
## Running build/test at the same time as Clippy
20+
21+
You can also emit binaries and test your project with Clippy enabled! Reducing your compilation times as there's no need to recompile.
22+
23+
```bash
24+
cargo clippy test
25+
cargo clippy build
26+
```
27+
1928
### Lint configuration
2029

2130
The above command will run the default set of lints, which are included in the

src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ impl ClippyCmd {
7777
},
7878
"--fix" => {
7979
if cargo_subcommand != "check" {
80-
eprintln!(
81-
"Running `cargo clippy {}` is not available with the --fix flag",
82-
cargo_subcommand
83-
);
80+
eprintln!("Running `cargo clippy {cargo_subcommand}` is not available with the --fix flag");
8481
process::exit(1) // Same code as `--explain` encountering an unknown lint
8582
}
8683
cargo_subcommand = "fix";

0 commit comments

Comments
 (0)