From 30f7135f32ba298da913e42eecd248349331006c Mon Sep 17 00:00:00 2001 From: dullbananas Date: Tue, 21 Nov 2023 06:51:22 -0700 Subject: [PATCH] Use rust 1.74.0 in CI and move clippy lints to Cargo.toml (#4170) * ci rust 1.74.0 * do it * Update .woodpecker.yml * Update Cargo.toml * Update lint.sh * Update lib.rs --------- Co-authored-by: Dessalines --- .woodpecker.yml | 18 ++---------------- Cargo.toml | 25 +++++++++++++++++++++++++ crates/api/Cargo.toml | 3 +++ crates/api_common/Cargo.toml | 3 +++ crates/api_crud/Cargo.toml | 3 +++ crates/apub/Cargo.toml | 3 +++ crates/db_schema/Cargo.toml | 3 +++ crates/db_views/Cargo.toml | 3 +++ crates/db_views_actor/Cargo.toml | 3 +++ crates/db_views_moderator/Cargo.toml | 3 +++ crates/federate/Cargo.toml | 3 +++ crates/routes/Cargo.toml | 3 +++ crates/utils/Cargo.toml | 3 +++ scripts/lint.sh | 16 +--------------- 14 files changed, 61 insertions(+), 31 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 57b085bb4..29e5939b5 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -2,7 +2,7 @@ # See https://github.com/woodpecker-ci/woodpecker/issues/1677 variables: - - &rust_image "rust:1.72.1" + - &rust_image "rust:1.74.0" - &slow_check_paths - path: # rust source code @@ -163,21 +163,7 @@ steps: commands: # when adding new clippy lints, make sure to also add them in scripts/lint.sh - rustup component add clippy - - cargo clippy --workspace --tests --all-targets --features console -- - -D warnings -D deprecated -D clippy::perf -D clippy::complexity - -D clippy::style -D clippy::correctness -D clippy::suspicious - -D clippy::dbg_macro -D clippy::inefficient_to_string - -D clippy::items-after-statements -D clippy::implicit_clone - -D clippy::cast_lossless -D clippy::manual_string_new - -D clippy::redundant_closure_for_method_calls - -D clippy::unused_self - -A clippy::uninlined_format_args - -D clippy::get_first - -D clippy::explicit_into_iter_loop - -D clippy::explicit_iter_loop - -D clippy::needless_collect - -D clippy::unwrap_used - -D clippy::indexing_slicing + - cargo clippy --workspace --tests --all-targets --features console -- -D warnings when: *slow_check_paths cargo_build: diff --git a/Cargo.toml b/Cargo.toml index f51c07bad..9e0847c93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,9 @@ repository.workspace = true [lib] doctest = false +[lints] +workspace = true + [profile.release] debug = 0 lto = "thin" @@ -58,6 +61,28 @@ members = [ "crates/federate", ] +[workspace.lints.clippy] +cast_lossless = "deny" +complexity = "deny" +correctness = "deny" +dbg_macro = "deny" +explicit_into_iter_loop = "deny" +explicit_iter_loop = "deny" +get_first = "deny" +implicit_clone = "deny" +indexing_slicing = "deny" +inefficient_to_string = "deny" +items-after-statements = "deny" +manual_string_new = "deny" +needless_collect = "deny" +perf = "deny" +redundant_closure_for_method_calls = "deny" +style = "deny" +suspicious = "deny" +uninlined_format_args = "allow" +unused_self = "deny" +unwrap_used = "deny" + [workspace.dependencies] lemmy_api = { version = "=0.19.0-rc.5", path = "./crates/api" } lemmy_api_crud = { version = "=0.19.0-rc.5", path = "./crates/api_crud" } diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index bb36bb7e3..6327e45fd 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -13,6 +13,9 @@ name = "lemmy_api" path = "src/lib.rs" doctest = false +[lints] +workspace = true + [dependencies] lemmy_utils = { workspace = true } lemmy_db_schema = { workspace = true, features = ["full"] } diff --git a/crates/api_common/Cargo.toml b/crates/api_common/Cargo.toml index dacd8f7df..a45d2f65a 100644 --- a/crates/api_common/Cargo.toml +++ b/crates/api_common/Cargo.toml @@ -13,6 +13,9 @@ name = "lemmy_api_common" path = "src/lib.rs" doctest = false +[lints] +workspace = true + [features] full = [ "tracing", diff --git a/crates/api_crud/Cargo.toml b/crates/api_crud/Cargo.toml index 0799332cf..867c3f215 100644 --- a/crates/api_crud/Cargo.toml +++ b/crates/api_crud/Cargo.toml @@ -8,6 +8,9 @@ homepage.workspace = true documentation.workspace = true repository.workspace = true +[lints] +workspace = true + [dependencies] lemmy_utils = { workspace = true } lemmy_db_schema = { workspace = true, features = ["full"] } diff --git a/crates/apub/Cargo.toml b/crates/apub/Cargo.toml index 748fe3335..5246c2a43 100644 --- a/crates/apub/Cargo.toml +++ b/crates/apub/Cargo.toml @@ -13,6 +13,9 @@ name = "lemmy_apub" path = "src/lib.rs" doctest = false +[lints] +workspace = true + [dependencies] lemmy_utils = { workspace = true } lemmy_db_schema = { workspace = true, features = ["full"] } diff --git a/crates/db_schema/Cargo.toml b/crates/db_schema/Cargo.toml index bf1fc0ef2..9bc5b25a6 100644 --- a/crates/db_schema/Cargo.toml +++ b/crates/db_schema/Cargo.toml @@ -13,6 +13,9 @@ name = "lemmy_db_schema" path = "src/lib.rs" doctest = false +[lints] +workspace = true + [features] full = [ "diesel", diff --git a/crates/db_views/Cargo.toml b/crates/db_views/Cargo.toml index 69fa24403..5c57888b7 100644 --- a/crates/db_views/Cargo.toml +++ b/crates/db_views/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true [lib] doctest = false +[lints] +workspace = true + [features] full = [ "lemmy_utils", diff --git a/crates/db_views_actor/Cargo.toml b/crates/db_views_actor/Cargo.toml index fc3573d46..347b25671 100644 --- a/crates/db_views_actor/Cargo.toml +++ b/crates/db_views_actor/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true [lib] doctest = false +[lints] +workspace = true + [features] full = ["lemmy_db_schema/full", "diesel", "diesel-async", "ts-rs"] diff --git a/crates/db_views_moderator/Cargo.toml b/crates/db_views_moderator/Cargo.toml index 7efa922e6..df8ec1ea2 100644 --- a/crates/db_views_moderator/Cargo.toml +++ b/crates/db_views_moderator/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true [lib] doctest = false +[lints] +workspace = true + [features] full = ["lemmy_db_schema/full", "diesel", "diesel-async", "ts-rs"] diff --git a/crates/federate/Cargo.toml b/crates/federate/Cargo.toml index e573ffe6c..85c781a40 100644 --- a/crates/federate/Cargo.toml +++ b/crates/federate/Cargo.toml @@ -10,6 +10,9 @@ repository.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints] +workspace = true + [dependencies] lemmy_api_common.workspace = true lemmy_apub.workspace = true diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index 12ec75c65..40fa2ab01 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -11,6 +11,9 @@ repository.workspace = true [lib] doctest = false +[lints] +workspace = true + [dependencies] lemmy_utils = { workspace = true } lemmy_db_views = { workspace = true } diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 1e99660c8..1c2aa5433 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -13,6 +13,9 @@ name = "lemmy_utils" path = "src/lib.rs" doctest = false +[lints] +workspace = true + [features] full = ["ts-rs"] diff --git a/scripts/lint.sh b/scripts/lint.sh index b06c5541f..924fba390 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -5,21 +5,7 @@ CWD="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" cd $CWD/../ -cargo clippy --workspace --fix --allow-staged --allow-dirty --tests --all-targets --all-features -- \ - -D warnings -D deprecated -D clippy::perf -D clippy::complexity \ - -D clippy::style -D clippy::correctness -D clippy::suspicious \ - -D clippy::dbg_macro -D clippy::inefficient_to_string \ - -D clippy::items-after-statements -D clippy::implicit_clone \ - -D clippy::wildcard_imports -D clippy::cast_lossless \ - -D clippy::manual_string_new -D clippy::redundant_closure_for_method_calls \ - -D clippy::unused_self \ - -A clippy::uninlined_format_args \ - -D clippy::get_first \ - -D clippy::explicit_into_iter_loop \ - -D clippy::explicit_iter_loop \ - -D clippy::needless_collect \ - -D clippy::unwrap_used \ - -D clippy::indexing_slicing +cargo clippy --workspace --fix --allow-staged --allow-dirty --tests --all-targets --all-features -- -D warnings # Format rust files cargo +nightly fmt