Skip to content

Commit e10c860

Browse files
DCNick3mversic
authored andcommitted
[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 <[email protected]>
1 parent 1159a42 commit e10c860

File tree

58 files changed

+463
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+463
-181
lines changed

.github/workflows/iroha2-dev-pr-static.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ jobs:
3232
run: cargo fmt --all -- --check
3333
- name: Lints without features
3434
if: always()
35-
run: cargo lints clippy --workspace --benches --tests --examples --no-default-features --quiet
35+
run: cargo clippy -Zlints --workspace --benches --tests --examples --no-default-features --quiet
3636
- name: Lints with all features enabled
3737
if: always()
38-
run: cargo lints clippy --workspace --benches --tests --examples --all-features --quiet
38+
run: cargo clippy -Zlints --workspace --benches --tests --examples --all-features --quiet
3939
- name: Documentation
4040
if: always()
4141
run: cargo doc --no-deps --quiet

.github/workflows/iroha2-dev-pr-wasm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: cargo fmt --all -- --check
3636
- name: Lints
3737
if: always()
38-
run: cargo lints clippy --workspace --benches --tests --examples --quiet
38+
run: cargo clippy -Zlints --workspace --benches --tests --examples --quiet
3939
- name: Documentation
4040
if: always()
4141
run: cargo doc --no-deps --quiet

Cargo.toml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,158 @@ serde_with = { version = "2.2.0", default-features = false }
130130
parity-scale-codec = { version = "3.2.1", default-features = false }
131131
json5 = "0.4.1"
132132

133+
[workspace.lints]
134+
rust.anonymous_parameters = "deny"
135+
136+
# lower the priority to allow overriding later
137+
clippy.pedantic = { level = "deny", priority = -1 }
138+
clippy.all = { level = "deny", priority = -1 }
139+
clippy.dbg_macro = "deny"
140+
141+
# clippy.nursery = "deny"
142+
clippy.debug_assert_with_mut_call = "deny"
143+
clippy.derive_partial_eq_without_eq = "deny"
144+
clippy.empty_line_after_outer_attr = "deny"
145+
clippy.fallible_impl_from = "deny"
146+
clippy.future_not_send = "deny"
147+
clippy.iter_with_drain = "deny"
148+
clippy.mutex_integer = "deny"
149+
clippy.needless_collect = "deny"
150+
clippy.path_buf_push_overwrite = "deny"
151+
clippy.suboptimal_flops = "deny"
152+
clippy.trailing_empty_array = "deny"
153+
clippy.transmute_undefined_repr = "deny"
154+
clippy.trivial_regex = "deny"
155+
clippy.unused_peekable = "deny"
156+
clippy.unused_rounding = "deny"
157+
158+
rust.future_incompatible = "deny"
159+
rust.missing_copy_implementations = "deny"
160+
rust.missing_docs = "deny"
161+
rust.nonstandard_style = "deny"
162+
rust.private_doc_tests = "deny"
163+
rust.rust_2018_idioms = "deny"
164+
rust.trivial_casts = "deny"
165+
rust.trivial_numeric_casts = "deny"
166+
rust.unconditional_recursion = "deny"
167+
rust.unsafe_code = "deny"
168+
rust.unused = "deny"
169+
rust.unused_import_braces = "deny"
170+
rust.variant_size_differences = "deny"
171+
rust.unused_tuple_struct_fields = "deny"
172+
rust.explicit_outlives_requirements = "deny"
173+
rust.non_ascii_idents = "deny"
174+
# TODO: reenable
175+
# rust.unreachable_pub = "deny"
176+
# rust.unsafe_op_in_unsafe_fn = "deny"
177+
178+
# These are up to personal taste. We don't want these to be enabled ever.
179+
clippy.string_add = "allow"
180+
clippy.as_conversions = "allow"
181+
clippy.else_if_without_else = "allow"
182+
clippy.enum_glob_use = "allow"
183+
clippy.exhaustive_enums = "allow"
184+
clippy.exhaustive_structs = "allow"
185+
clippy.implicit_return = "allow"
186+
clippy.inconsistent_struct_constructor = "allow"
187+
clippy.indexing_slicing = "allow"
188+
clippy.arithmetic_side_effects = "allow"
189+
clippy.let_underscore_must_use = "allow"
190+
clippy.match_wildcard_for_single_variants = "allow"
191+
clippy.missing_docs_in_private_items = "allow"
192+
clippy.module_name_repetitions = "allow"
193+
clippy.shadow_reuse = "allow"
194+
clippy.shadow_same = "allow"
195+
196+
# These are normally decisions, which need to be audited by a human.
197+
clippy.unwrap_in_result = "allow"
198+
clippy.expect_used = "allow"
199+
clippy.unreachable = "allow"
200+
clippy.wildcard_enum_match_arm = "allow"
201+
clippy.wildcard_imports = "allow"
202+
# Our preferred style.
203+
clippy.non-ascii-literal = "allow"
204+
clippy.std_instead_of_core = "allow"
205+
206+
# This lint could be useful in theory. The trade-off of making
207+
# refactoring away from references difficult isn't worth it in all
208+
# cases, so if it is enabled, it should be enabled locally.
209+
clippy.pattern_type_mismatch = "allow"
210+
211+
# Style guide.
212+
clippy.mod-module-files = "allow"
213+
clippy.separated-literal-suffix = "allow"
214+
# Most trybuild code triggers a false-positive.
215+
216+
# Not all public items should be inline. We only inline **trivial** functions.
217+
clippy.missing_inline_in_public_items = "allow"
218+
219+
# --- Re-enable candidates -----
220+
221+
# Lots of false-positives.
222+
clippy.self-named-module-files = "allow"
223+
clippy.manual_let_else = "allow"
224+
225+
# We often need to shadow the name of the method to specialise.
226+
# As soon as trait specialisation is stable we need to remove it.
227+
clippy.same_name_method = "allow"
228+
clippy.pub_use = "allow"
229+
230+
# Style guide candidate. Explicitly converting the return value to
231+
# () is good for refactoring, and if there is necessary
232+
# processing of the data returned by a function, it should
233+
# **really** be marked as #[must_use]
234+
clippy.semicolon_if_nothing_returned = "allow"
235+
236+
# This lint has way too many false-positives, so even enabling it
237+
# as a warning is too much. Instead prefer adding explicit
238+
# `#[deny]` directives
239+
clippy.must_use_candidate = "allow"
240+
241+
# Unstable and many false-positives
242+
## https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn
243+
clippy.missing_const_for_fn = "allow"
244+
245+
# Too much affected code. Often impossible to apply suggestion on stable rust.
246+
rust.elided_lifetimes_in_paths = "allow"
247+
248+
# This lint produces a lot of false positives. Recommend local #[deny] directives
249+
clippy.use_self = "allow"
250+
251+
# We don't want to manually deny every `clippy.restriction.*` lint.
252+
clippy.blanket-clippy-restriction-lints = "allow"
253+
254+
# A lot of false-positive.
255+
clippy.partial_pub_fields = "allow"
256+
257+
# Should be enabled per trait impl rather than globally.
258+
clippy.missing_trait_methods = "allow"
259+
260+
# We allow this and deny `clippy.semicolon_inside_block`.
261+
clippy.semicolon_outside_block = "allow"
262+
263+
# It is debatable whether it's actually easier to read,
264+
# additionally, not all patterns are covered by the inlined syntax
265+
clippy.uninlined_format_args = "allow"
266+
267+
rust.unknown_lints = "warn"
268+
# these lints were duplicated, with `allow` taking precedence
269+
# clippy.inconsistent_struct_constructor = "warn"
270+
# clippy.match_wildcard_for_single_variants = "warn"
271+
# clippy.arithmetic_side_effects = "warn"
272+
clippy.option_if_let_else = "warn"
273+
clippy.or_fun_call = "warn"
274+
clippy.redundant_pub_crate = "warn"
275+
clippy.string_lit_as_bytes = "warn"
276+
clippy.suspicious_operation_groupings = "warn"
277+
clippy.useless_let_if_seq = "warn"
278+
279+
# unstable
280+
# rust.non_exhaustive_omitted_patterns = "warn"
281+
282+
rust.single_use_lifetimes = "warn"
283+
rust.unused_lifetimes = "warn"
284+
133285
[workspace]
134286
resolver = "2"
135287
members = [

Dockerfile.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ RUN rustup component add llvm-tools-preview clippy
1212
RUN rustup component add rust-src
1313
RUN rustup component add rustfmt
1414
RUN rustup target add wasm32-unknown-unknown
15-
RUN cargo install cargo-lints
1615
RUN cargo install webassembly-test-runner
1716
RUN cargo install cargo-llvm-cov
1817

Dockerfile.build.glibc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ RUN rustup component add llvm-tools-preview clippy
1212
RUN rustup component add rust-src
1313
RUN rustup component add rustfmt
1414
RUN rustup target add wasm32-unknown-unknown
15-
RUN cargo install cargo-lints
1615
RUN cargo install webassembly-test-runner
1716
RUN cargo install cargo-llvm-cov
1817

cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ license.workspace = true
1414
keywords.workspace = true
1515
categories.workspace = true
1616

17+
[lints]
18+
workspace = true
19+
1720
[features]
1821
default = ["bridge", "telemetry", "schema-endpoint"]
1922

cli/derive/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ authors.workspace = true
77

88
license.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
[lib]
1114
proc-macro = true
1215

client/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ license.workspace = true
1414
keywords.workspace = true
1515
categories.workspace = true
1616

17+
[lints]
18+
workspace = true
19+
1720
[badges]
1821
is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledger/iroha" }
1922
is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" }

client_cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ license.workspace = true
1414
keywords.workspace = true
1515
categories = ["cryptography::cryptocurrencies", "command-line-utilities"]
1616

17+
[lints]
18+
workspace = true
19+
1720
[badges]
1821
is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledger/iroha" }
1922
is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" }

config/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ authors.workspace = true
77

88
license.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
[dependencies]
1114
iroha_config_base = { workspace = true }
1215
iroha_data_model = { workspace = true }

config/base/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ authors.workspace = true
77

88
license.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
[dependencies]
1114
iroha_config_derive = { workspace = true }
1215
iroha_crypto = { workspace = true, features = ["std"] }

config/base/derive/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ authors.workspace = true
77

88
license.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
[lib]
1114
proc-macro = true
1215

core/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ license.workspace = true
1414
keywords.workspace = true
1515
categories.workspace = true
1616

17+
[lints]
18+
workspace = true
19+
1720
[features]
1821
default = ["bridge", "cli", "telemetry"]
1922

crypto/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ authors.workspace = true
77

88
license.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
[features]
1114
default = ["std"]
1215
# Enable static linkage of the rust standard library.

crypto/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! This module contains structures and implementations related to the cryptographic parts of the Iroha.
22
#![cfg_attr(not(feature = "std"), no_std)]
3+
// in no_std some code gets cfg-ed out, so we silence the warnings
4+
#![cfg_attr(not(feature = "std"), allow(unused, unused_tuple_struct_fields))]
35
#![allow(clippy::arithmetic_side_effects)]
46

57
#[cfg(not(feature = "std"))]

data_model/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ authors.workspace = true
88
license.workspace = true
99
categories = ["cryptography::cryptocurrencies", "api-bindings"]
1010

11+
[lints]
12+
workspace = true
13+
1114
[badges]
1215
is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledger/iroha" }
1316
is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" }

data_model/derive/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ authors.workspace = true
77

88
license.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
[lib]
1114
proc-macro = true
1215

data_model/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
clippy::extra_unused_lifetimes, // Thanks to `EnumKind` not knowing how to write a derive macro.
1111
clippy::items_after_test_module, // Clippy bug
1212
)]
13+
// in no_std some code gets cfg-ed out, so we silence the warnings
14+
#![cfg_attr(not(feature = "std"), allow(unused, unused_tuple_struct_fields))]
1315
#![cfg_attr(not(feature = "std"), no_std)]
1416

1517
#[cfg(not(feature = "std"))]

dsl/Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
[package]
22
name = "iroha_dsl"
3-
version = "2.0.0-pre-rc.19"
4-
edition = "2021"
5-
authors = ["Yasser"]
3+
4+
edition.workspace = true
5+
version.workspace = true
6+
authors.workspace = true
7+
8+
license.workspace = true
9+
10+
[lints]
11+
workspace = true
612

713
[lib]
814
proc-macro = true

dsl/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// TODO: add docs
2+
#![allow(missing_docs)]
3+
14
use std::{convert::TryFrom, iter::Peekable, str::FromStr};
25

36
use litrs::Literal;

ffi/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ authors.workspace = true
88
license.workspace = true
99
categories = ["development-tools::ffi"]
1010

11+
[lints]
12+
workspace = true
13+
1114
[features]
1215
# Enables sharing mutable references of non-robust transmutable types across FFI.
1316
# When handing out non-robust mutable references across FFI, it's possible for the caller

ffi/derive/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ authors.workspace = true
88
license.workspace = true
99
categories = ["development-tools::ffi"]
1010

11+
[lints]
12+
workspace = true
13+
1114
[lib]
1215
proc-macro = true
1316

futures/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ authors.workspace = true
77

88
license.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
[features]
1114
default = []
1215
# Support lightweight telemetry, including diagnostics

futures/derive/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ authors.workspace = true
77

88
license.workspace = true
99

10+
[lints]
11+
workspace = true
12+
1013
[features]
1114
default = ["telemetry"]
1215
# Support lightweight telemetry, including diagnostics

0 commit comments

Comments
 (0)