@@ -81,18 +81,24 @@ fix: incorporate unlocks in mempool admitter, #3623
81
81
82
82
### Recommended githooks
83
83
84
- It is helpful to set up the pre-commit git hook set up, so that Rust formatting issues are caught before
84
+ It is helpful to set up the pre-commit git hook set up, so that Rust formatting issues and clippy warnings are caught before
85
85
you push your code. Follow these instruction to set it up:
86
86
87
87
1 . Rename ` .git/hooks/pre-commit.sample ` to ` .git/hooks/pre-commit `
88
88
2 . Change the content of ` .git/hooks/pre-commit ` to be the following
89
89
90
90
``` sh
91
91
#! /bin/sh
92
+ # Format staged Rust files
92
93
git diff --name-only --staged | grep ' \.rs$' | xargs -P 8 -I {} rustfmt {} --edition 2021 --check --config group_imports=StdExternalCrate,imports_granularity=Module || (
93
94
echo ' rustfmt failed: run "cargo fmt-stacks"' ;
94
95
exit 1
95
96
)
97
+ # Run cargo clippy-stacks and fail the commit if there are any warnings
98
+ if ! cargo clippy-stacks; then
99
+ echo ' cargo clippy-stacks failed: fix the warnings and try again.' ;
100
+ exit 1
101
+ fi
96
102
```
97
103
98
104
3 . Make it executable by running ` chmod +x .git/hooks/pre-commit `
@@ -387,6 +393,18 @@ You can automatically reformat your commit via:
387
393
cargo fmt-stacks
388
394
```
389
395
396
+ ## Clippy Warnings
397
+
398
+ PRs will be checked against ` clippy ` and will _ fail_ if any clippy warnings are generated.
399
+ Unfortunately, not all existing clippy warnings have been addressed throughout stacks-core, so arguments must be passed via the command line.
400
+ Therefore, we handle ` clippy ` configurations using a Cargo alias: ` cargo clippy-stacks `
401
+
402
+ You can check what warnings need to be addressed locally via:
403
+
404
+ ``` bash
405
+ cargo clippy-stacks
406
+ ```
407
+
390
408
## Comments
391
409
392
410
Comments are very important for the readability and correctness of the codebase. The purpose of comments is:
0 commit comments