Skip to content

Commit

Permalink
Enable all Clippy warnings in Cargo.toml. (#299)
Browse files Browse the repository at this point in the history
### What

Enabling the warnings in _Cargo.toml_ means tooling (e.g. `cargo clippy`
and `rust-analyzer`) will share the same list of warnings.

### How

Rust v1.74 added support for [a `[lints]` section in Cargo.toml
files](https://doc.rust-lang.org/stable/cargo/reference/manifest.html#the-lints-section).

I have also added `--deny=clippy::all` to the Justfile so it fails if
there are any warnings, just like CI does. This won't scale if we add
more warnings though; not sure how to fix that yet.
  • Loading branch information
SamirTalwar authored Feb 16, 2024
1 parent 45c4a50 commit 9373d4d
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ members = [
"crates/query-engine/*",
"crates/tests/*",
]

[workspace.lints.clippy]
all = "warn"
3 changes: 3 additions & 0 deletions crates/configuration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "ndc-postgres-configuration"
version = "0.1.0"
edition = "2021"

[lints]
workspace = true

[dependencies]
query-engine-metadata = { path = "../query-engine/metadata" }

Expand Down
3 changes: 3 additions & 0 deletions crates/connectors/ndc-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ license = "Apache-2.0"

default-run = "ndc-postgres"

[lints]
workspace = true

[lib]
name = "ndc_postgres"
path = "src/lib.rs"
Expand Down
3 changes: 2 additions & 1 deletion crates/documentation/openapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

default-run = "openapi-generator"
[lints]
workspace = true

[lib]
name = "openapi_generator"
Expand Down
3 changes: 3 additions & 0 deletions crates/query-engine/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[lints]
workspace = true

[dependencies]
query-engine-sql = { path = "../sql" }

Expand Down
3 changes: 3 additions & 0 deletions crates/query-engine/metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[lints]
workspace = true

[dependencies]
schemars = { version = "0.8.16", features = ["smol_str"] }
serde = { version = "1.0.196", features = ["derive"] }
3 changes: 3 additions & 0 deletions crates/query-engine/sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[lints]
workspace = true

[dependencies]
schemars = { version = "0.8.16", features = ["smol_str", "preserve_order"] }
serde = "1.0.196"
Expand Down
3 changes: 3 additions & 0 deletions crates/query-engine/translation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[lints]
workspace = true

[dependencies]
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "02d26c1" }
query-engine-metadata = { path = "../metadata" }
Expand Down
3 changes: 3 additions & 0 deletions crates/tests/databases-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[lints]
workspace = true

[features]
# We only run the AWS Aurora tests if this feature is enabled.
# This is handled by the `just test` command, which enables the feature if the
Expand Down
3 changes: 3 additions & 0 deletions crates/tests/tests-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
edition = "2021"
license = "Apache-2.0"

[lints]
workspace = true

[lib]
name = "tests_common"
path = "src/lib.rs"
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ repl-yugabyte:

# run `clippy` linter
lint *FLAGS:
cargo clippy {{FLAGS}}
cargo clippy -- --deny=clippy::all {{FLAGS}}

lint-apply *FLAGS:
cargo clippy --fix {{FLAGS}}
cargo clippy --fix -- --deny=clippy::all {{FLAGS}}

# reformat everything
format:
Expand Down

0 comments on commit 9373d4d

Please sign in to comment.