From f0269fc499907e769901a698bd98d6fd7f87a53a Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Mon, 27 Jan 2025 16:09:30 +0000 Subject: [PATCH 1/4] pre-commit: Disable auto-fix for clippy Fixes #206. --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dec6bfe5..228d47fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,8 +26,6 @@ repos: rev: v1.0 hooks: - id: clippy - # Warnings can be suppressed by adding "-A clippy::some_warning" to args - args: [--fix, --allow-dirty, --allow-staged, --, -D, clippy::all, -A, clippy::precedence] - repo: https://github.com/codespell-project/codespell rev: v2.2.6 hooks: From fe74630d6ca54d7f829eabd578a788902302bdd0 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Mon, 27 Jan 2025 16:10:22 +0000 Subject: [PATCH 2/4] Add cargo alias for autofixing clippy warnings --- .cargo/config.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..e72c13a9 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[alias] +# Automatically fix clippy warnings (where possible) +clipfix = "clippy --fix --allow-dirty --allow-staged" From cdf45acb237d8c9a9f7552b052fdc699965b8ae0 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Mon, 27 Jan 2025 16:14:54 +0000 Subject: [PATCH 3/4] docs: Add note about `cargo clipfix` --- docs/developer_guide.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/developer_guide.md b/docs/developer_guide.md index 1f271660..dbc1bdd8 100644 --- a/docs/developer_guide.md +++ b/docs/developer_guide.md @@ -108,3 +108,10 @@ pre-commit install Thereafter, a series of checks should be run every time you commit with Git. In addition, the `pre-commit` hooks are also run as part of the CI pipeline. + +Note: you may get errors due to the [`clippy`] hook failing. In this case, you may be able to +automatically fix them by running `cargo clipfix` (which we have defined as an alias in +[`.cargo/config.toml`]). + +[`clippy`]: https://doc.rust-lang.org/clippy +[`.cargo/config.toml`]: https://github.com/EnergySystemsModellingLab/MUSE_2.0/blob/main/.cargo/config.toml From 01f745284f0d72d352ce06560657087dc825bf5c Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 4 Feb 2025 12:10:20 +0000 Subject: [PATCH 4/4] Fix clippy warning: Redundant #[must_use] --- src/input/region.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/input/region.rs b/src/input/region.rs index 795b05ec..3693ceb9 100644 --- a/src/input/region.rs +++ b/src/input/region.rs @@ -88,7 +88,6 @@ where } /// Try to insert a region ID into the specified map -#[must_use] fn try_insert_region( entity_id: Rc, region_id: &str,