From 4f067d806eba2b6c9c2134d45dc397bec87fcdb3 Mon Sep 17 00:00:00 2001 From: Simon Brugman Date: Sat, 28 Jan 2023 00:53:44 +0100 Subject: [PATCH] add clippy and rust_dev to pre-commit (#2256) I presume the reasoning for not including clippy in `pre-commit` was that it passes all files. This can be turned off with `pass_filenames`, in which case it only runs once. `cargo +nightly dev generate-all` is also added (when excluding `target` is does not give false positives). (The overhead of these commands is not much when the build is there. People can always choose to run only certain hooks with `pre-commit run [hook] --all-files`) --- .pre-commit-config.yaml | 11 +++++++++++ CONTRIBUTING.md | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 06ebbc31f6..0acc3eb319 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,3 +18,14 @@ repos: entry: cargo fmt -- language: rust types: [rust] + - id: clippy + name: clippy + entry: cargo clippy --workspace --all-targets --all-features + language: rust + pass_filenames: false + - id: dev-generate-all + name: dev-generate-all + entry: cargo dev generate-all + language: rust + pass_filenames: false + exclude: target diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ffc8662f3..adc5c7bb4a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,6 +50,13 @@ cargo test --all # Testing... These checks will run on GitHub Actions when you open your Pull Request, but running them locally will save you time and expedite the merge process. +If you have `pre-commit` [installed](https://pre-commit.com/#installation) then you can use it to +assist with formatting and linting. The following command will run the `pre-commit` hooks: + +```shell +pre-commit run --all-files +``` + Your Pull Request will be reviewed by a maintainer, which may involve a few rounds of iteration prior to merging.