diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dcd5231e..2f1f4378 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,6 +88,16 @@ jobs: - name: Build and run tests (+ GUI) run: cargo test --locked --target x86_64-unknown-linux-gnu --test gui + # Ensure there are no clippy warnings + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Rust + run: bash ci/install-rust.sh stable x86_64-unknown-linux-gnu + - run: rustup component add clippy + - run: cargo clippy --workspace --all-targets --no-deps -- -D warnings + # The success job is here to consolidate the total success/failure state of # all other jobs. This job is then included in the GitHub branch protection # rule which prevents merges unless all other jobs are passing. This makes @@ -101,6 +111,7 @@ jobs: - rustfmt - aarch64-cross-builds - gui + - clippy runs-on: ubuntu-latest steps: - run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' diff --git a/Cargo.toml b/Cargo.toml index 5d38a8f1..4c43d0eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,12 @@ [workspace] members = [".", "examples/remove-emphasis/mdbook-remove-emphasis"] +[workspace.lints.clippy] +all = { level = "allow", priority = -2 } +correctness = { level = "warn", priority = -1 } +complexity = { level = "warn", priority = -1 } +needless-lifetimes = "allow" # Remove once 1.87 is stable, https://github.com/rust-lang/rust-clippy/issues/13514 + [package] name = "mdbook" version = "0.4.48" @@ -91,3 +97,6 @@ test = false name = "gui" path = "tests/gui/runner.rs" crate-type = ["bin"] + +[lints] +workspace = true diff --git a/src/book/mod.rs b/src/book/mod.rs index c5d20130..7ca13116 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -5,7 +5,6 @@ //! //! [1]: ../index.html -#[allow(clippy::module_inception)] mod book; mod init; mod summary; diff --git a/src/preprocess/links.rs b/src/preprocess/links.rs index 87ae3af3..1f55425d 100644 --- a/src/preprocess/links.rs +++ b/src/preprocess/links.rs @@ -148,7 +148,6 @@ enum RangeOrAnchor { } // A range of lines specified with some include directive. -#[allow(clippy::enum_variant_names)] // The prefix can't be removed, and is meant to mirror the contained type #[derive(PartialEq, Debug, Clone)] enum LineRange { Range(Range), diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 365696b7..5cd6fcaf 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -207,7 +207,6 @@ impl HtmlHandlebars { Ok(()) } - #[allow(clippy::let_and_return)] fn post_process( &self, rendered: String, diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index ab69a359..df1750ee 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -780,7 +780,6 @@ mod search { } #[test] - #[allow(clippy::float_cmp)] fn book_creates_reasonable_search_index() { let temp = DummyBook::new().build().unwrap(); let md = MDBook::load(temp.path()).unwrap();