From f6fd702d41e0456d78abd66055b75684e612c9bb Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Wed, 25 Jan 2023 06:17:38 +0100 Subject: [PATCH] Add #![warn(clippy::pedantic)] to lib.rs and main.rs files We already enforced pedantic clippy lints via the following command in .github/workflows/ci.yaml: cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic Additionally adding #![warn(clippy::pedantic)] to all main.rs and lib.rs has the benefit that violations of pedantic clippy lints are also reported when just running `cargo clippy` without any arguments and are thereby also picked up by LSP[1] servers such as rust-analyzer[2]. However for rust-analyzer to run clippy you'll have to configure: "rust-analyzer.check.command": "clippy", in your editor.[3] [1]: https://microsoft.github.io/language-server-protocol/ [2]: https://rust-analyzer.github.io/ [3]: https://rust-analyzer.github.io/manual.html#configuration --- CONTRIBUTING.md | 2 +- flake8_to_ruff/src/main.rs | 1 + ruff_cli/src/lib.rs | 1 + ruff_cli/src/main.rs | 1 + ruff_dev/src/main.rs | 1 + ruff_macros/src/lib.rs | 1 + src/lib.rs | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ff8babdee..8533cc278f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ For rustfmt and Clippy, we use [nightly Rust][nightly], as it is stricter than s ```shell cargo +nightly fmt --all # Auto-formatting... -cargo +nightly clippy --fix --workspace --all-targets --all-features -- -W clippy::pedantic # Linting... +cargo +nightly clippy --fix --workspace --all-targets --all-features # Linting... cargo test --all # Testing... ``` diff --git a/flake8_to_ruff/src/main.rs b/flake8_to_ruff/src/main.rs index e5dbcf2662..3aff2f3398 100644 --- a/flake8_to_ruff/src/main.rs +++ b/flake8_to_ruff/src/main.rs @@ -1,5 +1,6 @@ //! Utility to generate Ruff's `pyproject.toml` section from a Flake8 INI file. #![forbid(unsafe_code)] +#![warn(clippy::pedantic)] #![allow( clippy::collapsible_else_if, clippy::collapsible_if, diff --git a/ruff_cli/src/lib.rs b/ruff_cli/src/lib.rs index 4b2cfffb36..cb0214e325 100644 --- a/ruff_cli/src/lib.rs +++ b/ruff_cli/src/lib.rs @@ -3,6 +3,7 @@ //! //! For the actual Ruff library, see [`ruff`]. #![forbid(unsafe_code)] +#![warn(clippy::pedantic)] #![allow(clippy::must_use_candidate, dead_code)] mod cli; diff --git a/ruff_cli/src/main.rs b/ruff_cli/src/main.rs index 5fa29feed1..b32bf86dab 100644 --- a/ruff_cli/src/main.rs +++ b/ruff_cli/src/main.rs @@ -1,4 +1,5 @@ #![forbid(unsafe_code)] +#![warn(clippy::pedantic)] #![allow( clippy::match_same_arms, clippy::missing_errors_doc, diff --git a/ruff_dev/src/main.rs b/ruff_dev/src/main.rs index 5453ef693b..1c77096f46 100644 --- a/ruff_dev/src/main.rs +++ b/ruff_dev/src/main.rs @@ -2,6 +2,7 @@ //! //! Within the ruff repository you can run it with `cargo dev`. #![forbid(unsafe_code)] +#![warn(clippy::pedantic)] #![allow( clippy::collapsible_else_if, clippy::collapsible_if, diff --git a/ruff_macros/src/lib.rs b/ruff_macros/src/lib.rs index 8b62ac464f..3fe7106f82 100644 --- a/ruff_macros/src/lib.rs +++ b/ruff_macros/src/lib.rs @@ -1,5 +1,6 @@ //! This crate implements internal macros for the `ruff` library. #![forbid(unsafe_code)] +#![warn(clippy::pedantic)] #![allow( clippy::collapsible_else_if, clippy::collapsible_if, diff --git a/src/lib.rs b/src/lib.rs index 494e96aad9..547605ba57 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ //! //! [Ruff]: https://github.com/charliermarsh/ruff #![forbid(unsafe_code)] +#![warn(clippy::pedantic)] #![allow( clippy::collapsible_else_if, clippy::collapsible_if,