Просмотр исходного кода

clippy: add suggested clippy lints to top-level Cargo.toml and enable
clippy linting at the workspace level for all crates

Configure all workspaces to use lints from the top-level Cargo.toml
file
Add example lints that the project could configure to improve security
and reliability.
Configure lints to warn level. Using deny level makes other binaries
fail to compile if even one of them has a failure.
No lints are added in this commit. Future changes can enable and fix
lints

foo 2 лет назад
Родитель
Сommit
4eba00236d
44 измененных файлов с 192 добавлено и 0 удалено
  1. 17 0
      Cargo.toml
  2. 4 0
      bin/darkfi-mmproxy/Cargo.toml
  3. 4 0
      bin/darkfid/Cargo.toml
  4. 4 0
      bin/darkirc/Cargo.toml
  5. 4 0
      bin/darkwallet/Cargo.toml
  6. 4 0
      bin/dhtd/dhtd/Cargo.toml
  7. 4 0
      bin/drk/Cargo.toml
  8. 4 0
      bin/fud/fu/Cargo.toml
  9. 4 0
      bin/fud/fud/Cargo.toml
  10. 4 0
      bin/genev/genev-cli/Cargo.toml
  11. 4 0
      bin/genev/genevd/Cargo.toml
  12. 4 0
      bin/lilith/Cargo.toml
  13. 4 0
      bin/minerd/Cargo.toml
  14. 4 0
      bin/tau/tau-cli/Cargo.toml
  15. 4 0
      bin/tau/taud/Cargo.toml
  16. 4 0
      bin/vanityaddr/Cargo.toml
  17. 4 0
      bin/zkas/Cargo.toml
  18. 4 0
      example/dchat/dchatd/Cargo.toml
  19. 4 0
      example/p2pdebug/Cargo.toml
  20. 4 0
      example/wasm-hello-world/Cargo.toml
  21. 7 0
      fuzz/Cargo.toml
  22. 4 0
      fuzz/honggfuzz/Cargo.toml
  23. 4 0
      script/research/blockchain-explorer/Cargo.toml
  24. 4 0
      script/research/dhtd/Cargo.toml
  25. 4 0
      script/research/gg/Cargo.toml
  26. 4 0
      script/research/last_man_standing/Cargo.toml
  27. 4 0
      script/research/pallas_constants/Cargo.toml
  28. 4 0
      script/research/pow/Cargo.toml
  29. 4 0
      script/research/pqxdh/Cargo.toml
  30. 4 0
      script/research/rln/rlnv1/Cargo.toml
  31. 4 0
      script/research/rln/rlnv2/Cargo.toml
  32. 4 0
      script/research/snowball/Cargo.toml
  33. 4 0
      script/research/sss/Cargo.toml
  34. 4 0
      script/research/tfhe/Cargo.toml
  35. 4 0
      script/research/zk/ecip-bench/Cargo.toml
  36. 4 0
      src/contract/dao/Cargo.toml
  37. 4 0
      src/contract/deployooor/Cargo.toml
  38. 4 0
      src/contract/money/Cargo.toml
  39. 4 0
      src/contract/test-harness/Cargo.toml
  40. 4 0
      src/sdk/Cargo.toml
  41. 4 0
      src/sdk/python/Cargo.toml
  42. 4 0
      src/serial/Cargo.toml
  43. 4 0
      src/serial/derive-internal/Cargo.toml
  44. 4 0
      src/serial/derive/Cargo.toml

+ 17 - 0
Cargo.toml

@@ -345,3 +345,20 @@ path = "bench/zk_from_json.rs"
 name = "sled"
 harness = false
 path = "bench/sled.rs"
+
+# Top-level lints. Enabled optionally on a crate-level in their respective Cargo.toml files.
+[workspace.lints.clippy]
+#arithmetic_side_effects = "warn"
+#eq_op = "warn"
+#float_cmp = "warn"
+# integer_division = "warn"
+#large_futures = "warn"
+#large_stack_arrays = "warn"
+#large_stack_frames = "warn"
+#lossy_float_literal = "warn"
+#manual_slice_size_calculation = "warn"
+#modulo_one = "warn"
+#out_of_bounds_indexing = "warn"
+#overflow_check_conditional = "warn"
+#recursive_format_impl = "warn"
+#unchecked_duration_subtraction = "warn"

+ 4 - 0
bin/darkfi-mmproxy/Cargo.toml

@@ -37,3 +37,7 @@ smol = "2.0.0"
 serde = {version = "1.0.203", features = ["derive"]}
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/darkfid/Cargo.toml

@@ -40,3 +40,7 @@ smol = "2.0.0"
 serde = {version = "1.0.203", features = ["derive"]}
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/darkirc/Cargo.toml

@@ -62,3 +62,7 @@ structopt-toml = "0.5.1"
 # See https://github.com/rust-mobile/android-rs-glue/issues/193
 [target.aarch64-linux-android.dependencies]
 openssl = { version = "*", features = ["vendored"] }
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/darkwallet/Cargo.toml

@@ -46,3 +46,7 @@ simplelog = "0.12.1"
 [package.metadata.android.activity_attributes]
 "android:exported" = "true"
 "android:windowSoftInputMode" = "adjustResize"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/dhtd/dhtd/Cargo.toml

@@ -19,3 +19,7 @@ rand = "0.8.5"
 simplelog = "0.12.2"
 smol = "2.0.0"
 url = "2.5.0"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/drk/Cargo.toml

@@ -40,3 +40,7 @@ smol = "2.0.0"
 serde = {version = "1.0.203", features = ["derive"]}
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/fud/fu/Cargo.toml

@@ -20,3 +20,7 @@ log = "0.4.21"
 serde_json = "1.0.117"
 simplelog = "0.12.2"
 url = "2.5.0"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/fud/fud/Cargo.toml

@@ -30,3 +30,7 @@ smol = "2.0.0"
 serde = {version = "1.0.203", features = ["derive"]}
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/genev/genev-cli/Cargo.toml

@@ -20,3 +20,7 @@ log = "0.4.21"
 simplelog = "0.12.2"
 tinyjson = "2.5.1"
 url = "2.5.0"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/genev/genevd/Cargo.toml

@@ -47,3 +47,7 @@ smol = "2.0.0"
 serde = { version = "1.0.203", features = ["derive"] }
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/lilith/Cargo.toml

@@ -31,3 +31,7 @@ smol = "2.0.0"
 serde = {version = "1.0.203", features = ["derive"]}
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/minerd/Cargo.toml

@@ -33,3 +33,7 @@ smol = "2.0.0"
 serde = {version = "1.0.203", features = ["derive"]}
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/tau/tau-cli/Cargo.toml

@@ -28,3 +28,7 @@ url = "2.5.0"
 clap = {version = "4.4.11", features = ["derive"]}
 serde = {version = "1.0.203", features = ["derive"]}
 tinyjson = "2.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/tau/taud/Cargo.toml

@@ -59,3 +59,7 @@ smol = "2.0.0"
 serde = { version = "1.0.203", features = ["derive"] }
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/vanityaddr/Cargo.toml

@@ -17,3 +17,7 @@ darkfi-sdk = {path = "../../src/sdk"}
 darkfi_money_contract = {path = "../../src/contract/money", features = ["no-entrypoint", "client"]}
 rand = "0.8.5"
 rayon = "1.10.0"
+
+[lints]
+workspace = true
+

+ 4 - 0
bin/zkas/Cargo.toml

@@ -11,3 +11,7 @@ edition = "2021"
 [dependencies]
 arg = {git = "https://github.com/parazyd/arg"}
 darkfi = {path = "../../", features = ["zkas"]}
+
+[lints]
+workspace = true
+

+ 4 - 0
example/dchat/dchatd/Cargo.toml

@@ -32,3 +32,7 @@ async-trait = "0.1.80"
 log = "0.4.21"
 url = "2.5.0"
 # ANCHOR_END: dependencies
+
+[lints]
+workspace = true
+

+ 4 - 0
example/p2pdebug/Cargo.toml

@@ -32,3 +32,7 @@ url = "2.5.0"
 
 # Encoding and parsing
 serde_json = "1.0.117"
+
+[lints]
+workspace = true
+

+ 4 - 0
example/wasm-hello-world/Cargo.toml

@@ -22,3 +22,7 @@ getrandom = { version = "0.2.8", features = ["custom"] }
 [features]
 default = []
 no-entrypoint = []
+
+[lints]
+workspace = true
+

+ 7 - 0
fuzz/Cargo.toml

@@ -7,6 +7,9 @@ edition = "2021"
 [package.metadata]
 cargo-fuzz = true
 
+[lints]
+workspace = true
+
 [dependencies]
 libfuzzer-sys = "0.4.7"
 
@@ -57,3 +60,7 @@ name = "zkas-compile"
 path = "fuzz_targets/zkas_compile.rs"
 test = false
 doc = false
+
+[lints]
+workspace = true
+

+ 4 - 0
fuzz/honggfuzz/Cargo.toml

@@ -52,3 +52,7 @@ name = "zkas-compile"
 path = "src/zkas_compile.rs"
 test = false
 doc = false
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/blockchain-explorer/Cargo.toml

@@ -20,3 +20,7 @@ sled = "0.34.7"
 [patch.crates-io]
 halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"}
 halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"}
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/dhtd/Cargo.toml

@@ -30,3 +30,7 @@ structopt = "0.3.26"
 structopt-toml = "0.5.1"
 
 [workspace]
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/gg/Cargo.toml

@@ -30,3 +30,7 @@ sled = "0.34.7"
 halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"}
 halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"}
 blake2b_simd = {git="https://github.com/parazyd/blake2_simd", branch="impl-common"}
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/last_man_standing/Cargo.toml

@@ -14,3 +14,7 @@ darkfi = {path = "../../../", features = ["blockchain"]}
 darkfi-sdk = {path = "../../../src/sdk"}
 rand = "0.8.5"
 sled = "0.34.7"
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/pallas_constants/Cargo.toml

@@ -16,3 +16,7 @@ darkfi-sdk = {path = "../../../src/sdk"}
 
 [patch.crates-io]
 halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v3"}
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/pow/Cargo.toml

@@ -18,3 +18,7 @@ lazy_static = "1.4.0"
 
 [patch.crates-io]
 blake2b_simd = {git = "https://github.com/parazyd/blake2_simd", branch = "impl-common"}
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/pqxdh/Cargo.toml

@@ -16,3 +16,7 @@ kyber-kem = "0.1.3"
 rand = "0.8.5"
 sha2 = "0.10.8"
 x25519-dalek = {version = "2.0.1", features = ["static_secrets"]}
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/rln/rlnv1/Cargo.toml

@@ -16,3 +16,7 @@ rand = "0.8.5"
 [patch.crates-io]
 halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"}
 halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"}
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/rln/rlnv2/Cargo.toml

@@ -17,3 +17,7 @@ blake3 = "1.5.1"
 [patch.crates-io]
 halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"}
 halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"}
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/snowball/Cargo.toml

@@ -14,3 +14,7 @@ darkfi-serial = {path = "../../../src/serial"}
 blake3 = "1.5.1"
 num-bigint = "0.4.5"
 rand = "0.8.5"
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/sss/Cargo.toml

@@ -10,3 +10,7 @@ edition = "2021"
 [dependencies]
 pasta_curves = "0.5.1"
 rand = "0.8.5"
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/tfhe/Cargo.toml

@@ -10,3 +10,7 @@ edition = "2021"
 [dependencies]
 tfhe = {version = "0.5.4", features = ["boolean", "shortint", "integer", "x86_64-unix", "internal-keycache"]}
 rayon = "1.10.0"
+
+[lints]
+workspace = true
+

+ 4 - 0
script/research/zk/ecip-bench/Cargo.toml

@@ -17,3 +17,7 @@ hex = "0.4.3"
 
 [patch.crates-io]
 halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v3"}
+
+[lints]
+workspace = true
+

+ 4 - 0
src/contract/dao/Cargo.toml

@@ -52,3 +52,7 @@ client = [
     "log",
     "halo2_proofs",
 ]
+
+[lints]
+workspace = true
+

+ 4 - 0
src/contract/deployooor/Cargo.toml

@@ -41,3 +41,7 @@ client = [
     "log",
     "rand",
 ]
+
+[lints]
+workspace = true
+

+ 4 - 0
src/contract/money/Cargo.toml

@@ -51,3 +51,7 @@ client = [
     "log",
     "halo2_proofs",
 ]
+
+[lints]
+workspace = true
+

+ 4 - 0
src/contract/test-harness/Cargo.toml

@@ -20,3 +20,7 @@ log = "0.4.21"
 rand = "0.8.5"
 simplelog = "0.12.2"
 sled = "0.34.7"
+
+[lints]
+workspace = true
+

+ 4 - 0
src/sdk/Cargo.toml

@@ -45,3 +45,7 @@ subtle = "2.5.0"
 halo2_proofs = {version = "0.3.0", features = ["dev-graph", "sanity-checks"]}
 halo2_gadgets = {version = "0.3.0", features = ["test-dependencies"]}
 rand = "0.8.5"
+
+[lints]
+workspace = true
+

+ 4 - 0
src/sdk/python/Cargo.toml

@@ -21,3 +21,7 @@ halo2_gadgets = "0.3.0"
 plotters = "0.3.6"
 pyo3 = {version = "0.21.2", features = ["gil-refs"]}
 rand = "0.8.5"
+
+[lints]
+workspace = true
+

+ 4 - 0
src/serial/Cargo.toml

@@ -30,3 +30,7 @@ async = ["futures-lite", "async-trait", "darkfi-derive/async"]
 collections = []
 crypto = ["collections", "hash", "bridgetree", "pasta_curves"]
 hash = ["blake3"]
+
+[lints]
+workspace = true
+

+ 4 - 0
src/serial/derive-internal/Cargo.toml

@@ -16,3 +16,7 @@ syn = {version = "2.0.66", features = ["full", "fold"]}
 [features]
 default = []
 async = []
+
+[lints]
+workspace = true
+

+ 4 - 0
src/serial/derive/Cargo.toml

@@ -22,3 +22,7 @@ darkfi-derive-internal = {version = "0.4.1", path = "../derive-internal"}
 [features]
 default = []
 async = ["darkfi-derive-internal/async"]
+
+[lints]
+workspace = true
+