From 9f77e553d15bdfc5b0131c28ae9c1a559911f36a Mon Sep 17 00:00:00 2001 From: Nikita Strygin Date: Wed, 20 Sep 2023 15:25:08 +0300 Subject: [PATCH] [ci] #3622: Use cargo manifest lints instead of unmaintained cargo-lints Since the implementation of rust-lang/rfcs#3389, it is now possible to specify workspace-level lints for rustc and clippy. This PR updates the cargo configuration and CI to use this new feature instead of cargo-lints. Note that it was only stabilized in `nightly-2023-09-10`. Using it with out current toolchain requires either a -Zlints flag or a modification to `.cargo/config.toml`: ``` [unstable] lints = true ``` Note that unlike the original suggestion in #3622, this doesn't make the lints crate level, but merely replaces a clunky unmaintained tool with a standard solution for configuring lints. In particular this PR: - Removes old lints.toml configuration files for cargo-lints - Adds [lint] tables to Cargo.toml of the root and wasm workspaces. The lints are duplicated between the two - Replaces `cargo lints clippy` invocations with `cargo clippy -Zlints` in CI scripts - Silences/fixes some new lints that popped up due to differences in how between `cargo lints` and workspaces - Does a drive-by fix to iroha_genesis: it now too shares cargo metadata as do other crates Signed-off-by: Nikita Strygin --- .github/workflows/iroha2-dev-pr-static.yml | 4 +- .github/workflows/iroha2-dev-pr-wasm.yaml | 2 +- Cargo.toml | 152 +++++++++++++++++++ Dockerfile.build | 1 - Dockerfile.build.glibc | 1 - cli/Cargo.toml | 3 + cli/derive/Cargo.toml | 3 + client/Cargo.toml | 3 + client_cli/Cargo.toml | 3 + config/Cargo.toml | 3 + config/base/Cargo.toml | 3 + config/base/derive/Cargo.toml | 3 + core/Cargo.toml | 3 + crypto/Cargo.toml | 3 + crypto/src/lib.rs | 2 + data_model/Cargo.toml | 3 + data_model/derive/Cargo.toml | 3 + data_model/src/lib.rs | 2 + dsl/Cargo.toml | 12 +- dsl/src/lib.rs | 3 + ffi/Cargo.toml | 3 + ffi/derive/Cargo.toml | 3 + futures/Cargo.toml | 3 + futures/derive/Cargo.toml | 3 + genesis/Cargo.toml | 12 +- lints.toml | 167 --------------------- logger/Cargo.toml | 3 + macro/Cargo.toml | 3 + macro/derive/Cargo.toml | 3 + p2p/Cargo.toml | 3 + primitives/Cargo.toml | 4 +- schema/Cargo.toml | 3 + schema/derive/Cargo.toml | 3 + schema/gen/Cargo.toml | 3 + substrate/Cargo.toml | 3 + telemetry/Cargo.toml | 3 + telemetry/derive/Cargo.toml | 3 + tools/kagami/Cargo.toml | 3 + tools/kagami/src/main.rs | 3 +- tools/kura_inspector/Cargo.toml | 3 + tools/parity_scale_decoder/Cargo.toml | 3 + tools/swarm/Cargo.toml | 3 + tools/swarm/src/main.rs | 2 + tools/wasm_builder_cli/Cargo.toml | 2 + tools/wasm_builder_cli/src/main.rs | 2 + version/Cargo.toml | 3 + version/derive/Cargo.toml | 3 + wasm/Cargo.toml | 152 +++++++++++++++++++ wasm/derive/Cargo.toml | 3 + wasm/lints.toml | 1 - wasm/trigger/Cargo.toml | 3 + wasm/trigger/derive/Cargo.toml | 3 + wasm/validator/Cargo.toml | 3 + wasm/validator/derive/Cargo.toml | 3 + wasm/validator/src/permission.rs | 4 + wasm_builder/Cargo.toml | 3 + wasm_codec/Cargo.toml | 2 + wasm_codec/derive/Cargo.toml | 3 + 58 files changed, 463 insertions(+), 181 deletions(-) delete mode 100644 lints.toml delete mode 120000 wasm/lints.toml diff --git a/.github/workflows/iroha2-dev-pr-static.yml b/.github/workflows/iroha2-dev-pr-static.yml index 4c84fedb4f6..88b71c134c7 100644 --- a/.github/workflows/iroha2-dev-pr-static.yml +++ b/.github/workflows/iroha2-dev-pr-static.yml @@ -32,10 +32,10 @@ jobs: run: cargo fmt --all -- --check - name: Lints without features if: always() - run: cargo lints clippy --workspace --benches --tests --examples --no-default-features --quiet + run: cargo clippy -Zlints --workspace --benches --tests --examples --no-default-features --quiet - name: Lints with all features enabled if: always() - run: cargo lints clippy --workspace --benches --tests --examples --all-features --quiet + run: cargo clippy -Zlints --workspace --benches --tests --examples --all-features --quiet - name: Documentation if: always() run: cargo doc --no-deps --quiet diff --git a/.github/workflows/iroha2-dev-pr-wasm.yaml b/.github/workflows/iroha2-dev-pr-wasm.yaml index ca9f785c51c..d78d1d03e2c 100644 --- a/.github/workflows/iroha2-dev-pr-wasm.yaml +++ b/.github/workflows/iroha2-dev-pr-wasm.yaml @@ -35,7 +35,7 @@ jobs: run: cargo fmt --all -- --check - name: Lints if: always() - run: cargo lints clippy --workspace --benches --tests --examples --quiet + run: cargo clippy -Zlints --workspace --benches --tests --examples --quiet - name: Documentation if: always() run: cargo doc --no-deps --quiet diff --git a/Cargo.toml b/Cargo.toml index e9717ddedd8..cfad00e687a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -130,6 +130,158 @@ serde_with = { version = "2.2.0", default-features = false } parity-scale-codec = { version = "3.2.1", default-features = false } json5 = "0.4.1" +[workspace.lints] +rust.anonymous_parameters = "deny" + +# lower the priority to allow overriding later +clippy.pedantic = { level = "deny", priority = -1 } +clippy.all = { level = "deny", priority = -1 } +clippy.dbg_macro = "deny" + +# clippy.nursery = "deny" +clippy.debug_assert_with_mut_call = "deny" +clippy.derive_partial_eq_without_eq = "deny" +clippy.empty_line_after_outer_attr = "deny" +clippy.fallible_impl_from = "deny" +clippy.future_not_send = "deny" +clippy.iter_with_drain = "deny" +clippy.mutex_integer = "deny" +clippy.needless_collect = "deny" +clippy.path_buf_push_overwrite = "deny" +clippy.suboptimal_flops = "deny" +clippy.trailing_empty_array = "deny" +clippy.transmute_undefined_repr = "deny" +clippy.trivial_regex = "deny" +clippy.unused_peekable = "deny" +clippy.unused_rounding = "deny" + +rust.future_incompatible = "deny" +rust.missing_copy_implementations = "deny" +rust.missing_docs = "deny" +rust.nonstandard_style = "deny" +rust.private_doc_tests = "deny" +rust.rust_2018_idioms = "deny" +rust.trivial_casts = "deny" +rust.trivial_numeric_casts = "deny" +rust.unconditional_recursion = "deny" +rust.unsafe_code = "deny" +rust.unused = "deny" +rust.unused_import_braces = "deny" +rust.variant_size_differences = "deny" +rust.unused_tuple_struct_fields = "deny" +rust.explicit_outlives_requirements = "deny" +rust.non_ascii_idents = "deny" +# TODO: reenable +# rust.unreachable_pub = "deny" +# rust.unsafe_op_in_unsafe_fn = "deny" + +# These are up to personal taste. We don't want these to be enabled ever. +clippy.string_add = "allow" +clippy.as_conversions = "allow" +clippy.else_if_without_else = "allow" +clippy.enum_glob_use = "allow" +clippy.exhaustive_enums = "allow" +clippy.exhaustive_structs = "allow" +clippy.implicit_return = "allow" +clippy.inconsistent_struct_constructor = "allow" +clippy.indexing_slicing = "allow" +clippy.arithmetic_side_effects = "allow" +clippy.let_underscore_must_use = "allow" +clippy.match_wildcard_for_single_variants = "allow" +clippy.missing_docs_in_private_items = "allow" +clippy.module_name_repetitions = "allow" +clippy.shadow_reuse = "allow" +clippy.shadow_same = "allow" + +# These are normally decisions, which need to be audited by a human. +clippy.unwrap_in_result = "allow" +clippy.expect_used = "allow" +clippy.unreachable = "allow" +clippy.wildcard_enum_match_arm = "allow" +clippy.wildcard_imports = "allow" +# Our preferred style. +clippy.non-ascii-literal = "allow" +clippy.std_instead_of_core = "allow" + +# This lint could be useful in theory. The trade-off of making +# refactoring away from references difficult isn't worth it in all +# cases, so if it is enabled, it should be enabled locally. +clippy.pattern_type_mismatch = "allow" + +# Style guide. +clippy.mod-module-files = "allow" +clippy.separated-literal-suffix = "allow" +# Most trybuild code triggers a false-positive. + +# Not all public items should be inline. We only inline **trivial** functions. +clippy.missing_inline_in_public_items = "allow" + +# --- Re-enable candidates ----- + +# Lots of false-positives. +clippy.self-named-module-files = "allow" +clippy.manual_let_else = "allow" + +# We often need to shadow the name of the method to specialise. +# As soon as trait specialisation is stable we need to remove it. +clippy.same_name_method = "allow" +clippy.pub_use = "allow" + +# Style guide candidate. Explicitly converting the return value to +# () is good for refactoring, and if there is necessary +# processing of the data returned by a function, it should +# **really** be marked as #[must_use] +clippy.semicolon_if_nothing_returned = "allow" + +# This lint has way too many false-positives, so even enabling it +# as a warning is too much. Instead prefer adding explicit +# `#[deny]` directives +clippy.must_use_candidate = "allow" + +# Unstable and many false-positives +## https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn +clippy.missing_const_for_fn = "allow" + +# Too much affected code. Often impossible to apply suggestion on stable rust. +rust.elided_lifetimes_in_paths = "allow" + +# This lint produces a lot of false positives. Recommend local #[deny] directives +clippy.use_self = "allow" + +# We don't want to manually deny every `clippy.restriction.*` lint. +clippy.blanket-clippy-restriction-lints = "allow" + +# A lot of false-positive. +clippy.partial_pub_fields = "allow" + +# Should be enabled per trait impl rather than globally. +clippy.missing_trait_methods = "allow" + +# We allow this and deny `clippy.semicolon_inside_block`. +clippy.semicolon_outside_block = "allow" + +# It is debatable whether it's actually easier to read, +# additionally, not all patterns are covered by the inlined syntax +clippy.uninlined_format_args = "allow" + +rust.unknown_lints = "warn" +# these lints were duplicated, with `allow` taking precedence +# clippy.inconsistent_struct_constructor = "warn" +# clippy.match_wildcard_for_single_variants = "warn" +# clippy.arithmetic_side_effects = "warn" +clippy.option_if_let_else = "warn" +clippy.or_fun_call = "warn" +clippy.redundant_pub_crate = "warn" +clippy.string_lit_as_bytes = "warn" +clippy.suspicious_operation_groupings = "warn" +clippy.useless_let_if_seq = "warn" + +# unstable +# rust.non_exhaustive_omitted_patterns = "warn" + +rust.single_use_lifetimes = "warn" +rust.unused_lifetimes = "warn" + [workspace] resolver = "2" members = [ diff --git a/Dockerfile.build b/Dockerfile.build index c2d5e7c3632..c1d97aaa77e 100644 --- a/Dockerfile.build +++ b/Dockerfile.build @@ -12,7 +12,6 @@ RUN rustup component add llvm-tools-preview clippy RUN rustup component add rust-src RUN rustup component add rustfmt RUN rustup target add wasm32-unknown-unknown -RUN cargo install cargo-lints RUN cargo install webassembly-test-runner RUN cargo install cargo-llvm-cov diff --git a/Dockerfile.build.glibc b/Dockerfile.build.glibc index 5b9ee42d4b8..8ae5ff306c0 100644 --- a/Dockerfile.build.glibc +++ b/Dockerfile.build.glibc @@ -12,7 +12,6 @@ RUN rustup component add llvm-tools-preview clippy RUN rustup component add rust-src RUN rustup component add rustfmt RUN rustup target add wasm32-unknown-unknown -RUN cargo install cargo-lints RUN cargo install webassembly-test-runner RUN cargo install cargo-llvm-cov diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 77d51e16893..ba0bd4ac4d1 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -14,6 +14,9 @@ license.workspace = true keywords.workspace = true categories.workspace = true +[lints] +workspace = true + [features] default = ["bridge", "telemetry", "schema-endpoint"] diff --git a/cli/derive/Cargo.toml b/cli/derive/Cargo.toml index 60ea4adab49..d258df86e55 100644 --- a/cli/derive/Cargo.toml +++ b/cli/derive/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/client/Cargo.toml b/client/Cargo.toml index 11b16f5d52f..64c6d60fb16 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -14,6 +14,9 @@ license.workspace = true keywords.workspace = true categories.workspace = true +[lints] +workspace = true + [badges] is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledger/iroha" } is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" } diff --git a/client_cli/Cargo.toml b/client_cli/Cargo.toml index b75ecf0bc3c..dd48bdddb81 100644 --- a/client_cli/Cargo.toml +++ b/client_cli/Cargo.toml @@ -14,6 +14,9 @@ license.workspace = true keywords.workspace = true categories = ["cryptography::cryptocurrencies", "command-line-utilities"] +[lints] +workspace = true + [badges] is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledger/iroha" } is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" } diff --git a/config/Cargo.toml b/config/Cargo.toml index 89a01d1bc68..4d0bf7dfc40 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [dependencies] iroha_config_base = { workspace = true } iroha_data_model = { workspace = true } diff --git a/config/base/Cargo.toml b/config/base/Cargo.toml index 67734ac2ca7..93241f408b7 100644 --- a/config/base/Cargo.toml +++ b/config/base/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [dependencies] iroha_config_derive = { workspace = true } iroha_crypto = { workspace = true, features = ["std"] } diff --git a/config/base/derive/Cargo.toml b/config/base/derive/Cargo.toml index 7b446dbe35e..8aa95845755 100644 --- a/config/base/derive/Cargo.toml +++ b/config/base/derive/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/core/Cargo.toml b/core/Cargo.toml index 30899cfc0bd..df812f281e7 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -14,6 +14,9 @@ license.workspace = true keywords.workspace = true categories.workspace = true +[lints] +workspace = true + [features] default = ["bridge", "cli", "telemetry"] diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml index f8095874243..ab3f3a44028 100644 --- a/crypto/Cargo.toml +++ b/crypto/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [features] default = ["std"] # Enable static linkage of the rust standard library. diff --git a/crypto/src/lib.rs b/crypto/src/lib.rs index 4a89c6c9d84..e866bb85d15 100755 --- a/crypto/src/lib.rs +++ b/crypto/src/lib.rs @@ -1,5 +1,7 @@ //! This module contains structures and implementations related to the cryptographic parts of the Iroha. #![cfg_attr(not(feature = "std"), no_std)] +// in no_std some code gets cfg-ed out, so we silence the warnings +#![cfg_attr(not(feature = "std"), allow(unused, unused_tuple_struct_fields))] #![allow(clippy::arithmetic_side_effects)] #[cfg(not(feature = "std"))] diff --git a/data_model/Cargo.toml b/data_model/Cargo.toml index f5aaf21c9a0..6d7203ec735 100644 --- a/data_model/Cargo.toml +++ b/data_model/Cargo.toml @@ -8,6 +8,9 @@ authors.workspace = true license.workspace = true categories = ["cryptography::cryptocurrencies", "api-bindings"] +[lints] +workspace = true + [badges] is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledger/iroha" } is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" } diff --git a/data_model/derive/Cargo.toml b/data_model/derive/Cargo.toml index 0fd8e83b862..0fb3f485bbd 100644 --- a/data_model/derive/Cargo.toml +++ b/data_model/derive/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/data_model/src/lib.rs b/data_model/src/lib.rs index d66a385484b..45c9791b156 100644 --- a/data_model/src/lib.rs +++ b/data_model/src/lib.rs @@ -10,6 +10,8 @@ clippy::extra_unused_lifetimes, // Thanks to `EnumKind` not knowing how to write a derive macro. clippy::items_after_test_module, // Clippy bug )] +// in no_std some code gets cfg-ed out, so we silence the warnings +#![cfg_attr(not(feature = "std"), allow(unused, unused_tuple_struct_fields))] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] diff --git a/dsl/Cargo.toml b/dsl/Cargo.toml index 3c3adf0c2b6..7cdbd40ee01 100755 --- a/dsl/Cargo.toml +++ b/dsl/Cargo.toml @@ -1,8 +1,14 @@ [package] name = "iroha_dsl" -version = "2.0.0-pre-rc.19" -edition = "2021" -authors = ["Yasser"] + +edition.workspace = true +version.workspace = true +authors.workspace = true + +license.workspace = true + +[lints] +workspace = true [lib] proc-macro = true diff --git a/dsl/src/lib.rs b/dsl/src/lib.rs index f254dc88040..c1378c24b1d 100755 --- a/dsl/src/lib.rs +++ b/dsl/src/lib.rs @@ -1,3 +1,6 @@ +// TODO: add docs +#![allow(missing_docs)] + use std::{convert::TryFrom, iter::Peekable, str::FromStr}; use litrs::Literal; diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml index 3c95a1734af..64c50507343 100644 --- a/ffi/Cargo.toml +++ b/ffi/Cargo.toml @@ -8,6 +8,9 @@ authors.workspace = true license.workspace = true categories = ["development-tools::ffi"] +[lints] +workspace = true + [features] # Enables sharing mutable references of non-robust transmutable types across FFI. # When handing out non-robust mutable references across FFI, it's possible for the caller diff --git a/ffi/derive/Cargo.toml b/ffi/derive/Cargo.toml index 9cfa904eef3..d8c320bfa11 100644 --- a/ffi/derive/Cargo.toml +++ b/ffi/derive/Cargo.toml @@ -8,6 +8,9 @@ authors.workspace = true license.workspace = true categories = ["development-tools::ffi"] +[lints] +workspace = true + [lib] proc-macro = true diff --git a/futures/Cargo.toml b/futures/Cargo.toml index a9cc5e8f75a..592064ea911 100644 --- a/futures/Cargo.toml +++ b/futures/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [features] default = [] # Support lightweight telemetry, including diagnostics diff --git a/futures/derive/Cargo.toml b/futures/derive/Cargo.toml index b1850f24d02..772801c9f21 100644 --- a/futures/derive/Cargo.toml +++ b/futures/derive/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [features] default = ["telemetry"] # Support lightweight telemetry, including diagnostics diff --git a/genesis/Cargo.toml b/genesis/Cargo.toml index 32a2ec623c2..994afeb51a9 100644 --- a/genesis/Cargo.toml +++ b/genesis/Cargo.toml @@ -1,8 +1,14 @@ [package] name = "iroha_genesis" -version = "2.0.0-pre-rc.19" -authors = ["Iroha 2 team "] -edition = "2021" + +edition.workspace = true +version.workspace = true +authors.workspace = true + +license.workspace = true + +[lints] +workspace = true [dependencies] iroha_config = { workspace = true } diff --git a/lints.toml b/lints.toml deleted file mode 100644 index b36eb51c845..00000000000 --- a/lints.toml +++ /dev/null @@ -1,167 +0,0 @@ -# For all clippy lints please visit: https://rust-lang.github.io/rust-clippy/master/ -deny = [ - 'anonymous_parameters', - 'clippy::all', - 'clippy::dbg_macro', - - # 'clippy::nursery', - 'clippy::debug_assert_with_mut_call', - 'clippy::derive_partial_eq_without_eq', - 'clippy::empty_line_after_outer_attr', - 'clippy::fallible_impl_from', - 'clippy::future_not_send', - 'clippy::iter_with_drain', - 'clippy::mutex_integer', - 'clippy::needless_collect', - 'clippy::path_buf_push_overwrite', - 'clippy::suboptimal_flops', - 'clippy::trailing_empty_array', - 'clippy::transmute_undefined_repr', - 'clippy::trivial_regex', - 'clippy::unused_peekable', - 'clippy::unused_rounding', - - 'clippy::pedantic', - 'future_incompatible', - 'missing_copy_implementations', - 'missing_docs', - 'nonstandard_style', - 'private_doc_tests', - 'rust_2018_idioms', - 'trivial_casts', - 'trivial_numeric_casts', - 'unconditional_recursion', - 'unsafe_code', - 'unused', - 'unused_import_braces', - 'variant_size_differences', - 'unused_tuple_struct_fields', - 'explicit_outlives_requirements', - 'non_ascii_idents', - # TODO: reenable - # 'unreachable_pub', - # 'unsafe_op_in_unsafe_fn', -] - -allow = [ - # These are up to personal taste. We don't want these to be enabled ever. - 'clippy::string_add', - 'unknown_lints', - 'clippy::as_conversions', - 'clippy::else_if_without_else', - 'clippy::enum_glob_use', - 'clippy::exhaustive_enums', - 'clippy::exhaustive_structs', - 'clippy::implicit_return', - 'clippy::inconsistent_struct_constructor', - 'clippy::indexing_slicing', - 'clippy::arithmetic_side_effects', - 'clippy::let_underscore_must_use', - 'clippy::match_wildcard_for_single_variants', - 'clippy::missing_docs_in_private_items', - 'clippy::module_name_repetitions', - 'clippy::pattern_type_mismatch', - 'clippy::shadow_reuse', - 'clippy::shadow_same', - - # These are normally decisions, which need to be audited by a human. - 'clippy::unwrap_in_result', - 'clippy::expect_used', - 'clippy::unreachable', - 'clippy::wildcard_enum_match_arm', - 'clippy::wildcard_imports', - # Our preferred style. - 'clippy::non-ascii-literal', - 'clippy::std_instead_of_core', - - # This lint could be useful in theory. The trade-off of making - # refactoring away from references difficult isn't worth it in all - # cases, so if it is enabled, it should be enabled locally. - 'clippy::pattern_type_mismatch', - - # Style guide. - 'clippy::mod-module-files', - 'clippy::separated-literal-suffix', - # Most trybuild code triggers a false-positive. - - # Not all public items should be inline. We only inline **trivial** functions. - 'clippy::missing_inline_in_public_items', - - 'unknown_lints', - - # --- Re-enable candidates ----- - - # Lots of false-positives. - 'clippy::self-named-module-files', - 'clippy::manual_let_else', - - # We often need to shadow the name of the method to specialise. - # As soon as trait specialisation is stable we need to remove it. - 'clippy::same_name_method', - 'clippy::pub_use', - - # Style guide candidate. Explicitly converting the return value to - # () is good for refactoring, and if there is necessary - # processing of the data returned by a function, it should - # **really** be marked as #[must_use] - 'clippy::semicolon_if_nothing_returned', - - # This lint has way too many false-positives, so even enabling it - # as a warning is too much. Instead prefer adding explicit - # `#[deny]` directives - 'clippy::must_use_candidate', - - # Unstable and many false-positives - ## https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn - 'clippy::missing_const_for_fn', - - # Too much affected code. Often impossible to apply suggestion on stable rust. - 'elided_lifetimes_in_paths', - - # This lint produces a lot of false positives. Recommend local #[deny] directives - 'clippy::use_self', - - # We don't want to manually deny every `clippy::restriction::*` lint. - 'clippy::blanket-clippy-restriction-lints', - - # A lot of false-positive. - 'clippy::partial_pub_fields', - - # Should be enabled per trait impl rather than globally. - 'clippy::missing_trait_methods', - - # We allow this and deny `clippy::semicolon_inside_block`. - 'clippy::semicolon_outside_block', - - # It is debatable whether it's actually easier to read, - # additionally, not all patterns are covered by the inlined syntax - 'clippy::uninlined_format_args', -] - -warn = [ - # These are lints which should really be conveyed to the author, - # but not necessarily fixed. - - 'unknown_lints', - 'clippy::inconsistent_struct_constructor', - 'clippy::match_wildcard_for_single_variants', - 'clippy::arithmetic_side_effects', - 'clippy::option_if_let_else', - 'clippy::or_fun_call', - 'clippy::redundant_pub_crate', - 'clippy::string_lit_as_bytes', - 'clippy::suspicious_operation_groupings', - 'clippy::useless_let_if_seq', - - # unstable - # 'non_exhaustive_omitted_patterns', - - 'single_use_lifetimes', - 'unused_lifetimes', - - # A couple of false positives. - # 'unused_qualifications', - - # Lots of false-positives. - # 'unused_crate_dependencies', -] diff --git a/logger/Cargo.toml b/logger/Cargo.toml index 12e94839986..918e23bb3ba 100644 --- a/logger/Cargo.toml +++ b/logger/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [dependencies] iroha_config = { workspace = true } iroha_data_model = { workspace = true } diff --git a/macro/Cargo.toml b/macro/Cargo.toml index 8fd1b71b41d..aee10f93f8b 100644 --- a/macro/Cargo.toml +++ b/macro/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [badges] is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledger/iroha" } is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" } diff --git a/macro/derive/Cargo.toml b/macro/derive/Cargo.toml index e7dd8d06e2a..5f09f48c489 100644 --- a/macro/derive/Cargo.toml +++ b/macro/derive/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/p2p/Cargo.toml b/p2p/Cargo.toml index 758888f1fde..d28d34b35eb 100644 --- a/p2p/Cargo.toml +++ b/p2p/Cargo.toml @@ -8,6 +8,9 @@ authors.workspace = true license.workspace = true categories = ["network-programming"] +[lints] +workspace = true + [dependencies] iroha_logger = { workspace = true } iroha_crypto = { workspace = true } diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 43ef5bbabfb..bbbd408827d 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [badges] is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledger/iroha" } is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" } @@ -39,7 +42,6 @@ smallstr = { version = "0.3.0", default-features = false, features = ["serde", " thiserror = { workspace = true, optional = true } displaydoc = { workspace = true } - [dev-dependencies] serde_json = { workspace = true, features = ["alloc"] } trybuild = { workspace = true } diff --git a/schema/Cargo.toml b/schema/Cargo.toml index d696b5c0426..d118ec66407 100644 --- a/schema/Cargo.toml +++ b/schema/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [dependencies] iroha_schema_derive = { workspace = true } diff --git a/schema/derive/Cargo.toml b/schema/derive/Cargo.toml index fa2fea8a9bf..d17a56721ee 100644 --- a/schema/derive/Cargo.toml +++ b/schema/derive/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/schema/gen/Cargo.toml b/schema/gen/Cargo.toml index f231c08239b..53e89aa94b1 100644 --- a/schema/gen/Cargo.toml +++ b/schema/gen/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [dependencies] iroha_genesis = { workspace = true } iroha_primitives = { workspace = true } diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml index f1ce840ced3..184b9e572ac 100644 --- a/substrate/Cargo.toml +++ b/substrate/Cargo.toml @@ -7,4 +7,7 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [dependencies] diff --git a/telemetry/Cargo.toml b/telemetry/Cargo.toml index d63dd4f830f..6a3e7ae10de 100644 --- a/telemetry/Cargo.toml +++ b/telemetry/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [features] # Support developer-specific telemetry. # Should not be enabled on production builds. diff --git a/telemetry/derive/Cargo.toml b/telemetry/derive/Cargo.toml index 6348a5683a7..b2c53970a87 100644 --- a/telemetry/derive/Cargo.toml +++ b/telemetry/derive/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/tools/kagami/Cargo.toml b/tools/kagami/Cargo.toml index 8d3830559c9..7a4d4145ecf 100644 --- a/tools/kagami/Cargo.toml +++ b/tools/kagami/Cargo.toml @@ -9,6 +9,9 @@ description = "A tool used to generate cryptographic keys, docs, the schema and license.workspace = true +[lints] +workspace = true + [dependencies] iroha_crypto = { workspace = true } iroha_config = { workspace = true } diff --git a/tools/kagami/src/main.rs b/tools/kagami/src/main.rs index b869fbd8c20..f5f56789939 100644 --- a/tools/kagami/src/main.rs +++ b/tools/kagami/src/main.rs @@ -4,7 +4,8 @@ #![allow( clippy::arithmetic_side_effects, clippy::std_instead_of_core, - clippy::std_instead_of_alloc + clippy::std_instead_of_alloc, + missing_docs )] use std::{ io::{stdout, BufWriter, Write}, diff --git a/tools/kura_inspector/Cargo.toml b/tools/kura_inspector/Cargo.toml index 8833be01cc0..31854303380 100644 --- a/tools/kura_inspector/Cargo.toml +++ b/tools/kura_inspector/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [dependencies] iroha_core = { workspace = true } iroha_version = { workspace = true } diff --git a/tools/parity_scale_decoder/Cargo.toml b/tools/parity_scale_decoder/Cargo.toml index 42dfb4747d3..34458b12eb4 100644 --- a/tools/parity_scale_decoder/Cargo.toml +++ b/tools/parity_scale_decoder/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [features] # Disable colour for all program output. # Useful for Docker-based deployment and terminals without colour support. diff --git a/tools/swarm/Cargo.toml b/tools/swarm/Cargo.toml index cbd4508bf93..1500d1526b4 100644 --- a/tools/swarm/Cargo.toml +++ b/tools/swarm/Cargo.toml @@ -6,6 +6,9 @@ version.workspace = true authors.workspace = true license.workspace = true +[lints] +workspace = true + [dependencies] iroha_crypto.workspace = true iroha_data_model.workspace = true diff --git a/tools/swarm/src/main.rs b/tools/swarm/src/main.rs index bcd4a2b297e..18e83f64be9 100644 --- a/tools/swarm/src/main.rs +++ b/tools/swarm/src/main.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + mod cli; mod compose; mod ui; diff --git a/tools/wasm_builder_cli/Cargo.toml b/tools/wasm_builder_cli/Cargo.toml index 51f4d0e0e56..2cd39c40274 100644 --- a/tools/wasm_builder_cli/Cargo.toml +++ b/tools/wasm_builder_cli/Cargo.toml @@ -6,6 +6,8 @@ version.workspace = true authors.workspace = true license.workspace = true +[lints] +workspace = true [dependencies] iroha_wasm_builder.workspace = true diff --git a/tools/wasm_builder_cli/src/main.rs b/tools/wasm_builder_cli/src/main.rs index dde4bd00e49..4ecd5a589ce 100644 --- a/tools/wasm_builder_cli/src/main.rs +++ b/tools/wasm_builder_cli/src/main.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + use std::path::PathBuf; use clap::{Args, Parser}; diff --git a/version/Cargo.toml b/version/Cargo.toml index 91041519a36..89b396ff8a9 100644 --- a/version/Cargo.toml +++ b/version/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [features] default = ["std", "derive", "scale", "json"] # Enable static linkage of the rust standard library. diff --git a/version/derive/Cargo.toml b/version/derive/Cargo.toml index 5667539058d..be02b1e5acf 100644 --- a/version/derive/Cargo.toml +++ b/version/derive/Cargo.toml @@ -7,6 +7,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 0320c154c9a..ecc18d3b244 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -30,6 +30,158 @@ proc-macro2 = "1.0.49" webassembly-test = "0.1.0" +[workspace.lints] +rust.anonymous_parameters = "deny" + +# lower the priority to allow overriding later +clippy.pedantic = { level = "deny", priority = -1 } +clippy.all = { level = "deny", priority = -1 } +clippy.dbg_macro = "deny" + +# clippy.nursery = "deny" +clippy.debug_assert_with_mut_call = "deny" +clippy.derive_partial_eq_without_eq = "deny" +clippy.empty_line_after_outer_attr = "deny" +clippy.fallible_impl_from = "deny" +clippy.future_not_send = "deny" +clippy.iter_with_drain = "deny" +clippy.mutex_integer = "deny" +clippy.needless_collect = "deny" +clippy.path_buf_push_overwrite = "deny" +clippy.suboptimal_flops = "deny" +clippy.trailing_empty_array = "deny" +clippy.transmute_undefined_repr = "deny" +clippy.trivial_regex = "deny" +clippy.unused_peekable = "deny" +clippy.unused_rounding = "deny" + +rust.future_incompatible = "deny" +rust.missing_copy_implementations = "deny" +rust.missing_docs = "deny" +rust.nonstandard_style = "deny" +rust.private_doc_tests = "deny" +rust.rust_2018_idioms = "deny" +rust.trivial_casts = "deny" +rust.trivial_numeric_casts = "deny" +rust.unconditional_recursion = "deny" +rust.unsafe_code = "deny" +rust.unused = "deny" +rust.unused_import_braces = "deny" +rust.variant_size_differences = "deny" +rust.unused_tuple_struct_fields = "deny" +rust.explicit_outlives_requirements = "deny" +rust.non_ascii_idents = "deny" +# TODO: reenable +# rust.unreachable_pub = "deny" +# rust.unsafe_op_in_unsafe_fn = "deny" + +# These are up to personal taste. We don't want these to be enabled ever. +clippy.string_add = "allow" +clippy.as_conversions = "allow" +clippy.else_if_without_else = "allow" +clippy.enum_glob_use = "allow" +clippy.exhaustive_enums = "allow" +clippy.exhaustive_structs = "allow" +clippy.implicit_return = "allow" +clippy.inconsistent_struct_constructor = "allow" +clippy.indexing_slicing = "allow" +clippy.arithmetic_side_effects = "allow" +clippy.let_underscore_must_use = "allow" +clippy.match_wildcard_for_single_variants = "allow" +clippy.missing_docs_in_private_items = "allow" +clippy.module_name_repetitions = "allow" +clippy.shadow_reuse = "allow" +clippy.shadow_same = "allow" + +# These are normally decisions, which need to be audited by a human. +clippy.unwrap_in_result = "allow" +clippy.expect_used = "allow" +clippy.unreachable = "allow" +clippy.wildcard_enum_match_arm = "allow" +clippy.wildcard_imports = "allow" +# Our preferred style. +clippy.non-ascii-literal = "allow" +clippy.std_instead_of_core = "allow" + +# This lint could be useful in theory. The trade-off of making +# refactoring away from references difficult isn't worth it in all +# cases, so if it is enabled, it should be enabled locally. +clippy.pattern_type_mismatch = "allow" + +# Style guide. +clippy.mod-module-files = "allow" +clippy.separated-literal-suffix = "allow" +# Most trybuild code triggers a false-positive. + +# Not all public items should be inline. We only inline **trivial** functions. +clippy.missing_inline_in_public_items = "allow" + +# --- Re-enable candidates ----- + +# Lots of false-positives. +clippy.self-named-module-files = "allow" +clippy.manual_let_else = "allow" + +# We often need to shadow the name of the method to specialise. +# As soon as trait specialisation is stable we need to remove it. +clippy.same_name_method = "allow" +clippy.pub_use = "allow" + +# Style guide candidate. Explicitly converting the return value to +# () is good for refactoring, and if there is necessary +# processing of the data returned by a function, it should +# **really** be marked as #[must_use] +clippy.semicolon_if_nothing_returned = "allow" + +# This lint has way too many false-positives, so even enabling it +# as a warning is too much. Instead prefer adding explicit +# `#[deny]` directives +clippy.must_use_candidate = "allow" + +# Unstable and many false-positives +## https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn +clippy.missing_const_for_fn = "allow" + +# Too much affected code. Often impossible to apply suggestion on stable rust. +rust.elided_lifetimes_in_paths = "allow" + +# This lint produces a lot of false positives. Recommend local #[deny] directives +clippy.use_self = "allow" + +# We don't want to manually deny every `clippy.restriction.*` lint. +clippy.blanket-clippy-restriction-lints = "allow" + +# A lot of false-positive. +clippy.partial_pub_fields = "allow" + +# Should be enabled per trait impl rather than globally. +clippy.missing_trait_methods = "allow" + +# We allow this and deny `clippy.semicolon_inside_block`. +clippy.semicolon_outside_block = "allow" + +# It is debatable whether it's actually easier to read, +# additionally, not all patterns are covered by the inlined syntax +clippy.uninlined_format_args = "allow" + +rust.unknown_lints = "warn" +# these lints were duplicated, with `allow` taking precedence +# clippy.inconsistent_struct_constructor = "warn" +# clippy.match_wildcard_for_single_variants = "warn" +# clippy.arithmetic_side_effects = "warn" +clippy.option_if_let_else = "warn" +clippy.or_fun_call = "warn" +clippy.redundant_pub_crate = "warn" +clippy.string_lit_as_bytes = "warn" +clippy.suspicious_operation_groupings = "warn" +clippy.useless_let_if_seq = "warn" + +# unstable +# rust.non_exhaustive_omitted_patterns = "warn" + +rust.single_use_lifetimes = "warn" +rust.unused_lifetimes = "warn" + [package] name = "iroha_wasm" diff --git a/wasm/derive/Cargo.toml b/wasm/derive/Cargo.toml index aea05d5be96..42aa8006f4a 100644 --- a/wasm/derive/Cargo.toml +++ b/wasm/derive/Cargo.toml @@ -7,6 +7,9 @@ edition.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/wasm/lints.toml b/wasm/lints.toml deleted file mode 120000 index 883d2da34b1..00000000000 --- a/wasm/lints.toml +++ /dev/null @@ -1 +0,0 @@ -../lints.toml \ No newline at end of file diff --git a/wasm/trigger/Cargo.toml b/wasm/trigger/Cargo.toml index 117b4585933..f14c79c46df 100644 --- a/wasm/trigger/Cargo.toml +++ b/wasm/trigger/Cargo.toml @@ -6,6 +6,9 @@ authors.workspace = true edition.workspace = true license.workspace = true +[lints] +workspace = true + [features] # Enables debugging tools such as `dbg()` and `DebugUnwrapExt` debug = ["iroha_wasm/debug"] diff --git a/wasm/trigger/derive/Cargo.toml b/wasm/trigger/derive/Cargo.toml index 2dedb97d33c..05feb5bd61e 100644 --- a/wasm/trigger/derive/Cargo.toml +++ b/wasm/trigger/derive/Cargo.toml @@ -7,6 +7,9 @@ edition.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/wasm/validator/Cargo.toml b/wasm/validator/Cargo.toml index 607f70bc836..e9454e6c78a 100644 --- a/wasm/validator/Cargo.toml +++ b/wasm/validator/Cargo.toml @@ -6,6 +6,9 @@ authors.workspace = true edition.workspace = true license.workspace = true +[lints] +workspace = true + [features] # Enables debugging tools such as `dbg()` and `DebugUnwrapExt` debug = ["iroha_wasm/debug"] diff --git a/wasm/validator/derive/Cargo.toml b/wasm/validator/derive/Cargo.toml index 19eb1ea27da..04f6438d9f1 100644 --- a/wasm/validator/derive/Cargo.toml +++ b/wasm/validator/derive/Cargo.toml @@ -7,6 +7,9 @@ edition.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true diff --git a/wasm/validator/src/permission.rs b/wasm/validator/src/permission.rs index 300e7c8e5d2..6d6bb263f72 100644 --- a/wasm/validator/src/permission.rs +++ b/wasm/validator/src/permission.rs @@ -84,6 +84,7 @@ pub mod asset { /// Pass condition that checks if `authority` is the owner of `asset_id`. #[derive(Debug, Clone)] pub struct Owner<'asset> { + /// Asset id to check against pub asset_id: &'asset AssetId, } @@ -115,6 +116,7 @@ pub mod asset_definition { /// Pass condition that checks if `authority` is the owner of `asset_definition_id`. #[derive(Debug, Clone)] pub struct Owner<'asset_definition> { + /// Asset definition id to check against pub asset_definition_id: &'asset_definition AssetDefinitionId, } @@ -139,6 +141,7 @@ pub mod account { /// Pass condition that checks if `authority` is the owner of `account_id`. #[derive(Debug, Clone)] pub struct Owner<'asset> { + /// Account id to check against pub account_id: &'asset AccountId, } @@ -175,6 +178,7 @@ pub mod trigger { /// Pass condition that checks if `authority` is the owner of `trigger_id`. #[derive(Debug, Clone)] pub struct Owner<'trigger> { + /// Trigger id to check against pub trigger_id: &'trigger TriggerId, } diff --git a/wasm_builder/Cargo.toml b/wasm_builder/Cargo.toml index 64954992991..f7abb4db419 100644 --- a/wasm_builder/Cargo.toml +++ b/wasm_builder/Cargo.toml @@ -8,6 +8,9 @@ authors.workspace = true license.workspace = true categories = ["development-tools::build-utils"] +[lints] +workspace = true + [dependencies] eyre = { workspace = true } serde_json = { workspace = true, features = ["std"] } diff --git a/wasm_codec/Cargo.toml b/wasm_codec/Cargo.toml index 302bcad24ea..e75b860c9e5 100644 --- a/wasm_codec/Cargo.toml +++ b/wasm_codec/Cargo.toml @@ -6,6 +6,8 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true [dependencies] iroha_core_wasm_codec_derive = { version = "=2.0.0-pre-rc.19", path = "derive" } diff --git a/wasm_codec/derive/Cargo.toml b/wasm_codec/derive/Cargo.toml index 5cbc4f6dbc4..27119faf744 100644 --- a/wasm_codec/derive/Cargo.toml +++ b/wasm_codec/derive/Cargo.toml @@ -6,6 +6,9 @@ authors.workspace = true license.workspace = true +[lints] +workspace = true + [lib] proc-macro = true