From ed08c76178864b89253453622687562cb2037f79 Mon Sep 17 00:00:00 2001 From: ivan-aksamentov Date: Mon, 12 Feb 2024 07:54:33 +0100 Subject: [PATCH 1/3] chore: commonize cargo deps and package config fields https://doc.rust-lang.org/cargo/reference/workspaces.html --- Cargo.lock | 46 ---------- Cargo.toml | 88 +++++++++++++++++++ packages/nextclade-cli/Cargo.toml | 91 ++++++++++---------- packages/nextclade-web/Cargo.toml | 50 ++++++----- packages/nextclade/Cargo.toml | 135 +++++++++++++++--------------- 5 files changed, 229 insertions(+), 181 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e1f2b5bd..1ac825c18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1752,7 +1752,6 @@ dependencies = [ "rayon", "regex", "rstest", - "rstest_reuse", "schemars", "semver 1.0.17", "serde", @@ -1804,7 +1803,6 @@ dependencies = [ "regex", "reqwest", "rstest", - "rstest_reuse", "schemars", "semver 1.0.17", "serde", @@ -1833,7 +1831,6 @@ dependencies = [ "serde", "serde-wasm-bindgen", "wasm-bindgen", - "wasm-bindgen-test", "wasm-logger", "web-sys", ] @@ -2352,18 +2349,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "rstest_reuse" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45f80dcc84beab3a327bbe161f77db25f336a1452428176787c8c79ac79d7073" -dependencies = [ - "quote", - "rand", - "rustc_version 0.4.0", - "syn 1.0.109", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2490,12 +2475,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "scopeguard" version = "1.1.0" @@ -3269,30 +3248,6 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" -[[package]] -name = "wasm-bindgen-test" -version = "0.3.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e6e302a7ea94f83a6d09e78e7dc7d9ca7b186bc2829c24a22d0753efd680671" -dependencies = [ - "console_error_panic_hook", - "js-sys", - "scoped-tls", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecb993dd8c836930ed130e020e77d9b2e65dd0fbab1b67c790b0f5d80b11a575" -dependencies = [ - "proc-macro2", - "quote", -] - [[package]] name = "wasm-logger" version = "0.2.0" @@ -3481,7 +3436,6 @@ checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ "aes", "byteorder", - "bzip2", "constant_time_eq", "crc32fast", "crossbeam-utils", diff --git a/Cargo.toml b/Cargo.toml index e6b2a9424..d03e58ba3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = '2' members = [ "packages/*", @@ -7,3 +8,90 @@ members = [ exclude = [ "packages/3rdparty", ] + + +[workspace.package] +name = "nextclade" +version = "3.2.0" +description = "Alignment, mutation calling, phylogenetic placement, clade assignment and quality control checks for viral genetic sequences. Library module." +repository = "https://github.com/nextstrain/nextclade" +documentation = "https://docs.nextstrain.org/projects/nextclade/en/stable/" +homepage = "https://clades.nextstrain.org/" +edition = "2021" +license = "MIT" +publish = false +authors = ["Nextstrain team"] + + +[workspace.dependencies] +assert2 = "=0.3.11" +atty = "=0.2.14" +auto_ops = "=0.3.0" +bio = "=1.3.1" +bio-types = "=1.0.0" +bzip2 = { version = "=0.4.4", features = ["static"] } +chrono = { version = "=0.4.26", default-features = false, features = ["clock", "std", "wasmbind"] } +clap = { version = "=4.4.2", features = ["derive", "color", "unicode", "unstable-styles"] } +clap-markdown = "=0.1.3" +clap_complete = "=4.4.1" +clap_complete_fig = "=4.4.0" +color-eyre = "=0.6.2" +comfy-table = "=7.0.1" +console_error_panic_hook = "=0.1.7" +criterion = { version = "=0.5.1", features = ["html_reports"] } +crossbeam = "=0.8.2" +crossbeam-channel = "=0.5.8" +csv = "=1.2.2" +ctor = "=0.2.2" +derive_more = "=0.99.17" +dotenv = "=0.15.0" +dotenv_codegen = "=0.15.0" +edit-distance = "=2.1.0" +either = "=1.8.1" +env_logger = "=0.10.0" +eyre = "=0.6.8" +flate2 = "=1.0.26" +gcollections = "=1.5.0" +getrandom = { version = "=0.2.10", features = ["js"] } +indexmap = { version = "=1.9.3", features = ["serde"] } +intervallum = "=1.4.0" +itertools = "=0.11.0" +js-sys = { version = "=0.3.64", features = [] } +lazy_static = "=1.4.0" +log = "=0.4.19" +maplit = "=1.0.2" +multimap = "=0.8.3" +num = "=0.4.0" +num-traits = "=0.2.15" +num_cpus = "=1.16.0" +optfield = "=0.3.0" +ordered-float = { version = "=3.9.1", features = ["rand", "serde", "schemars"] } +owo-colors = "=3.5.0" +pretty_assertions = "=1.3.0" +rayon = "=1.7.0" +regex = "=1.8.4" +reqwest = { version = "=0.11.18", default-features = false, features = ["blocking", "deflate", "gzip", "brotli", "socks", "rustls-tls"] } +rstest = "=0.17.0" +rstest_reuse = "=0.5.0" +schemars = { version = "=0.8.12", features = ["chrono", "either", "enumset", "indexmap"] } +semver = { version = "=1.0.17", features = ["serde"] } +serde = { version = "=1.0.164", features = ["derive"] } +serde-wasm-bindgen = { version = "=0.5.0" } +serde_json = { version = "=1.0.99", features = ["preserve_order", "indexmap", "unbounded_depth"] } +serde_repr = "=0.1.12" +serde_stacker = { version = "=0.1.8" } +serde_yaml = "=0.9.22" +strsim = "=0.10.0" +strum = "=0.25.0" +strum_macros = "=0.25.0" +tinytemplate = "=1.2.1" +traversal = "=0.1.2" +url = { version = "=2.4.0", features = ["serde"] } +urlencoding = "=2.1.2" +validator = { version = "=0.16.1", features = ["derive"] } +wasm-bindgen = { version = "=0.2.87", features = ["serde-serialize"] } +wasm-logger = "=0.2.0" +web-sys = { version = "=0.3.64", features = ["console"] } +xz2 = { version = "=0.1.7", features = ["static"] } +zip = { version = "=0.6.6", default-features = false, features = ["aes-crypto", "deflate", "time"] } +zstd = { version = "=0.12.3", features = ["zstdmt"] } diff --git a/packages/nextclade-cli/Cargo.toml b/packages/nextclade-cli/Cargo.toml index 1aa8e5eb5..3597f0169 100644 --- a/packages/nextclade-cli/Cargo.toml +++ b/packages/nextclade-cli/Cargo.toml @@ -1,52 +1,53 @@ [package] name = "nextclade-cli" -version = "3.2.0" -description = "Alignment, mutation calling, phylogenetic placement, clade assignment and quality control checks for viral genetic sequences. CLI module." -repository = "https://github.com/nextstrain/nextclade" -documentation = "https://docs.nextstrain.org/projects/nextclade/en/stable/" -homepage = "https://clades.nextstrain.org/" -edition = "2021" -license = "MIT" -publish = false + +authors.workspace = true +description.workspace = true +documentation.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +publish.workspace = true +repository.workspace = true +version.workspace = true [dependencies] -assert2 = "=0.3.11" -clap = { version = "=4.4.2", features = ["derive", "color", "unicode", "unstable-styles"] } -clap-markdown = "=0.1.3" -clap_complete = "=4.4.1" -clap_complete_fig = "=4.4.0" -color-eyre = "=0.6.2" -comfy-table = "=7.0.1" -crossbeam = "=0.8.2" -crossbeam-channel = "=0.5.8" -ctor = "=0.2.2" -dotenv = "=0.15.0" -dotenv_codegen = "=0.15.0" -eyre = "=0.6.8" -indexmap = { version = "=1.9.3", features = ["serde"] } -itertools = "=0.11.0" -lazy_static = "=1.4.0" -log = "=0.4.19" +assert2 = { workspace = true } +clap = { workspace = true } +clap-markdown = { workspace = true } +clap_complete = { workspace = true } +clap_complete_fig = { workspace = true } +color-eyre = { workspace = true } +comfy-table = { workspace = true } +crossbeam = { workspace = true } +crossbeam-channel = { workspace = true } +ctor = { workspace = true } +dotenv = { workspace = true } +dotenv_codegen = { workspace = true } +eyre = { workspace = true } +indexmap = { workspace = true } +itertools = { workspace = true } +lazy_static = { workspace = true } +log = { workspace = true } nextclade = { path = "../nextclade" } -num_cpus = "=1.16.0" -ordered-float = { version = "=3.9.1", features = ["rand", "serde", "schemars"] } -owo-colors = "=3.5.0" -pretty_assertions = "=1.3.0" -rayon = "=1.7.0" -regex = "=1.8.4" -reqwest = { version = "=0.11.18", default-features = false, features = ["blocking", "deflate", "gzip", "brotli", "socks", "rustls-tls"] } -schemars = { version = "=0.8.12", features = ["chrono", "either", "enumset", "indexmap1"] } -semver = { version = "=1.0.17", features = ["serde"] } -serde = { version = "=1.0.164", features = ["derive"] } -serde_json = { version = "=1.0.99", features = ["preserve_order", "indexmap", "unbounded_depth"] } -strum = "=0.25.0" -strum_macros = "=0.25" -tinytemplate = "=1.2.1" -url = { version = "=2.4.0", features = ["serde"] } -zip = { version = "=0.6.6", default-features = false, features = ["aes-crypto", "bzip2", "deflate", "time"] } +num_cpus = { workspace = true } +ordered-float = { workspace = true } +owo-colors = { workspace = true } +pretty_assertions = { workspace = true } +rayon = { workspace = true } +regex = { workspace = true } +reqwest = { workspace = true } +schemars = { workspace = true } +semver = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +strum = { workspace = true } +strum_macros = { workspace = true } +tinytemplate = { workspace = true } +url = { workspace = true } +zip = { workspace = true } [dev-dependencies] -assert2 = "=0.3.11" -criterion = { version = "=0.5.1", features = ["html_reports"] } -rstest = "=0.17.0" -rstest_reuse = "=0.5.0" +assert2 = { workspace = true } +criterion = { workspace = true } +rstest = { workspace = true } diff --git a/packages/nextclade-web/Cargo.toml b/packages/nextclade-web/Cargo.toml index 57c2ff608..e0fc12c24 100644 --- a/packages/nextclade-web/Cargo.toml +++ b/packages/nextclade-web/Cargo.toml @@ -1,37 +1,41 @@ [package] name = "nextclade-web" -version = "3.2.0" -description = "Alignment, mutation calling, phylogenetic placement, clade assignment and quality control checks for viral genetic sequences. WebAssembly module." -edition = "2021" -license = "MIT" -publish = false build = "src/build.rs" +authors.workspace = true +description.workspace = true +documentation.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +publish.workspace = true +repository.workspace = true +version.workspace = true + [lib] crate-type = ["cdylib", "rlib"] [dependencies] -assert2 = "=0.3.11" -chrono = { version = "=0.4.26", default-features = false, features = ["clock", "std", "wasmbind"] } -console_error_panic_hook = "=0.1.7" -eyre = "=0.6.8" -getrandom = { version = "=0.2.10", features = ["js"] } -itertools = "=0.11.0" -js-sys = { version = "=0.3.64", features = [] } -log = "=0.4.19" +assert2 = { workspace = true } +chrono = { workspace = true } +console_error_panic_hook = { workspace = true } +eyre = { workspace = true } +getrandom = { workspace = true } +itertools = { workspace = true } +js-sys = { workspace = true } +log = { workspace = true } nextclade = { path = "../nextclade" } -schemars = { version = "=0.8.12", features = ["chrono", "either", "enumset", "indexmap1"] } -serde = { version = "=1.0.164", features = ["derive"] } -serde-wasm-bindgen = { version = "=0.5.0" } -wasm-bindgen = { version = "=0.2.87", features = ["serde-serialize"] } -wasm-logger = "=0.2.0" -web-sys = { version = "=0.3.64", features = ["console"] } +schemars = { workspace = true } +serde = { workspace = true } +serde-wasm-bindgen = { workspace = true } +wasm-bindgen = { workspace = true } +wasm-logger = { workspace = true } +web-sys = { workspace = true } [build-dependencies] nextclade = { path = "../nextclade" } -schemars = { version = "=0.8.12", features = ["chrono", "either", "enumset", "indexmap1"] } -eyre = "=0.6.8" +schemars = { workspace = true } +eyre = { workspace = true } [dev-dependencies] -assert2 = "=0.3.11" -wasm-bindgen-test = "=0.3.37" +assert2 = { workspace = true } diff --git a/packages/nextclade/Cargo.toml b/packages/nextclade/Cargo.toml index 68194acf7..616296433 100644 --- a/packages/nextclade/Cargo.toml +++ b/packages/nextclade/Cargo.toml @@ -1,81 +1,82 @@ [package] name = "nextclade" -version = "3.2.0" -description = "Alignment, mutation calling, phylogenetic placement, clade assignment and quality control checks for viral genetic sequences. Library module." -repository = "https://github.com/nextstrain/nextclade" -documentation = "https://docs.nextstrain.org/projects/nextclade/en/stable/" -homepage = "https://clades.nextstrain.org/" -edition = "2021" -license = "MIT" -publish = false + +authors.workspace = true +description.workspace = true +documentation.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +publish.workspace = true +repository.workspace = true +version.workspace = true [lib] crate-type = ["lib"] [dependencies] -assert2 = "=0.3.11" -auto_ops = "=0.3.0" -bio = "=1.3.1" -bio-types = "=1.0.0" -chrono = { version = "=0.4.26", default-features = false, features = ["clock", "std", "wasmbind"] } -clap = { version = "=4.4.2", features = ["derive", "color", "unicode", "unstable-styles"] } -clap_complete = "=4.4.1" -clap_complete_fig = "=4.4.0" -color-eyre = "=0.6.2" -csv = "=1.2.2" -ctor = "=0.2.2" -derive_more = "=0.99.17" -edit-distance = "=2.1.0" -either = "=1.8.1" -env_logger = "=0.10.0" -eyre = "=0.6.8" -flate2 = "=1.0.26" -gcollections = "=1.5.0" -getrandom = "=0.2.10" -indexmap = { version = "=1.9.3", features = ["serde"] } -intervallum = "=1.4.0" -itertools = "=0.11.0" -lazy_static = "=1.4.0" -log = "=0.4.19" -maplit = "=1.0.2" -multimap = "=0.8.3" -num = "=0.4.0" -num-traits = "=0.2.15" -num_cpus = "=1.16.0" -optfield = "=0.3.0" -ordered-float = { version = "=3.9.1", features = ["rand", "serde", "schemars"] } -owo-colors = "=3.5.0" -pretty_assertions = "=1.3.0" -rayon = "=1.7.0" -regex = "=1.8.4" -schemars = { version = "=0.8.12", features = ["chrono", "either", "enumset", "indexmap"] } -semver = { version = "=1.0.17", features = ["serde"] } -serde = { version = "=1.0.164", features = ["derive"] } -serde_json = { version = "=1.0.99", features = ["preserve_order", "indexmap", "unbounded_depth"] } -serde_repr = "=0.1.12" -serde_stacker = { version = "=0.1.8" } -serde_yaml = "=0.9.22" -strsim = "=0.10.0" -strum = "=0.25.0" -strum_macros = "=0.25.0" -tinytemplate = "=1.2.1" -traversal = "=0.1.2" -urlencoding = "=2.1.2" -validator = { version = "=0.16.1", features = ["derive"] } -wasm-bindgen = { version = "=0.2.87", features = ["serde-serialize"] } -zip = { version = "=0.6.6", default-features = false, features = ["aes-crypto", "deflate", "time"] } +assert2 = { workspace = true } +auto_ops = { workspace = true } +bio = { workspace = true } +bio-types = { workspace = true } +chrono = { workspace = true } +clap = { workspace = true } +clap_complete = { workspace = true } +clap_complete_fig = { workspace = true } +color-eyre = { workspace = true } +csv = { workspace = true } +ctor = { workspace = true } +derive_more = { workspace = true } +edit-distance = { workspace = true } +either = { workspace = true } +env_logger = { workspace = true } +eyre = { workspace = true } +flate2 = { workspace = true } +gcollections = { workspace = true } +getrandom = { workspace = true } +indexmap = { workspace = true } +intervallum = { workspace = true } +itertools = { workspace = true } +lazy_static = { workspace = true } +log = { workspace = true } +maplit = { workspace = true } +multimap = { workspace = true } +num = { workspace = true } +num-traits = { workspace = true } +num_cpus = { workspace = true } +optfield = { workspace = true } +ordered-float = { workspace = true } +owo-colors = { workspace = true } +pretty_assertions = { workspace = true } +rayon = { workspace = true } +regex = { workspace = true } +schemars = { workspace = true } +semver = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +serde_repr = { workspace = true } +serde_stacker = { workspace = true } +serde_yaml = { workspace = true } +strsim = { workspace = true } +strum = { workspace = true } +strum_macros = { workspace = true } +tinytemplate = { workspace = true } +traversal = { workspace = true } +urlencoding = { workspace = true } +validator = { workspace = true } +wasm-bindgen = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -atty = "=0.2.14" -bzip2 = { version = "=0.4.4", features = ["static"] } -xz2 = { version = "=0.1.7", features = ["static"] } -zstd = { version = "=0.12.3", features = ["zstdmt"] } +atty = { workspace = true } +bzip2 = { workspace = true } +xz2 = { workspace = true } +zip = { workspace = true } +zstd = { workspace = true } [dev-dependencies] -assert2 = "=0.3.11" -criterion = { version = "=0.5.1", features = ["html_reports"] } -rstest = "=0.17.0" -rstest_reuse = "=0.5.0" +assert2 = { workspace = true } +criterion = { workspace = true } +rstest = { workspace = true } [[bench]] From 339e8b6855be10df600444694fba0cd699f326d3 Mon Sep 17 00:00:00 2001 From: ivan-aksamentov Date: Wed, 14 Feb 2024 13:51:50 +0100 Subject: [PATCH 2/3] refactor: improve lint config This improves clippy and compiler linting configuration, by using `workspace.lints` and `lints` sections in the `Cargo.toml` files instead of (ab)using `rustflags` in the `.cargo/config.toml`. This setup now correctly applies configuration to the `build.rs` step, which previously emitted a very large number of compiler warnings. This also enables warnings for a few more compiler rules. --- .cargo/config.toml | 191 ------------------------------ Cargo.toml | 151 +++++++++++++++++++++++ packages/nextclade-cli/Cargo.toml | 4 + packages/nextclade-web/Cargo.toml | 4 + packages/nextclade/Cargo.toml | 3 + 5 files changed, 162 insertions(+), 191 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index d40604ad1..4aee3ac8e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -87,194 +87,3 @@ opt-level = 3 [profile.test.package.pretty_assertions] opt-level = 3 - -[target.'cfg(all())'] -rustflags = [ - # - # Enable some of the default lints which are disabled by default - "-Wdeprecated_in_future", - "-Wfuture_incompatible", - "-Wnonstandard_style", - "-Wrust_2018_idioms", - # "-Wtrivial_casts", - "-Wtrivial_numeric_casts", - # Enable all clippy lint groups - # Order is important! - "-Wclippy::all", - "-Wclippy::pedantic", - "-Aclippy::blanket_clippy_restriction_lints", - "-Wclippy::restriction", - "-Wclippy::nursery", - # - # Enable some of the clippy lints disabled by default - "-Wclippy::await_holding_lock", - "-Wclippy::char_lit_as_u8", - "-Wclippy::checked_conversions", - "-Wclippy::dbg_macro", - "-Wclippy::debug_assert_with_mut_call", - "-Wclippy::disallowed_script_idents", - "-Wclippy::doc_markdown", - "-Wclippy::empty_enum", - "-Wclippy::enum_glob_use", - "-Wclippy::equatable_if_let", - "-Wclippy::exit", - "-Wclippy::expl_impl_clone_on_copy", - "-Wclippy::explicit_deref_methods", - "-Wclippy::explicit_into_iter_loop", - "-Wclippy::fallible_impl_from", - "-Wclippy::filter_map_next", - "-Wclippy::flat_map_option", - "-Wclippy::float_cmp_const", - "-Wclippy::fn_params_excessive_bools", - "-Wclippy::fn_to_numeric_cast_any", - "-Wclippy::from_iter_instead_of_collect", - "-Wclippy::if_let_mutex", - "-Wclippy::implicit_clone", - "-Wclippy::imprecise_flops", - "-Wclippy::index_refutable_slice", - "-Wclippy::inefficient_to_string", - "-Wclippy::invalid_upcast_comparisons", - "-Wclippy::iter_not_returning_iterator", - "-Wclippy::large_digit_groups", - "-Wclippy::large_stack_arrays", - "-Wclippy::large_types_passed_by_value", - "-Wclippy::let_unit_value", - "-Wclippy::linkedlist", - "-Wclippy::lossy_float_literal", - "-Wclippy::macro_use_imports", - "-Wclippy::manual_ok_or", - "-Wclippy::map_err_ignore", - "-Wclippy::map_flatten", - "-Wclippy::map_unwrap_or", - "-Wclippy::match_on_vec_items", - "-Wclippy::match_same_arms", - "-Wclippy::match_wild_err_arm", - "-Wclippy::match_wildcard_for_single_variants", - "-Wclippy::mem_forget", - "-Wclippy::mismatched_target_os", - "-Wclippy::missing_enforced_import_renames", - "-Wclippy::mut_mut", - "-Wclippy::mutex_integer", - "-Wclippy::needless_continue", - "-Wclippy::needless_for_each", - "-Wclippy::negative_feature_names", - "-Wclippy::nonstandard_macro_braces", - "-Wclippy::option_option", - "-Wclippy::path_buf_push_overwrite", - "-Wclippy::ptr_as_ptr", - "-Wclippy::rc_mutex", - "-Wclippy::ref_option_ref", - "-Wclippy::rest_pat_in_fully_bound_structs", - "-Wclippy::same_functions_in_if_condition", - "-Wclippy::semicolon_if_nothing_returned", - "-Wclippy::single_match_else", - "-Wclippy::string_add", - "-Wclippy::string_add_assign", - "-Wclippy::string_lit_as_bytes", - "-Wclippy::string_to_string", - "-Wclippy::trailing_empty_array", - "-Wclippy::trait_duplication_in_bounds", - "-Wclippy::unimplemented", - "-Wclippy::unnecessary_wraps", - "-Wclippy::unnested_or_patterns", - "-Wclippy::useless_transmute", - "-Wclippy::verbose_file_reads", - "-Wclippy::zero_sized_map_values", - # - # Disable some of the clippy lints - "-Aclippy::absolute_paths", - "-Aclippy::allow_attributes", - "-Aclippy::arithmetic-side-effects", - "-Aclippy::arithmetic_side_effects", - "-Aclippy::as_conversions", - "-Aclippy::assign_op_pattern", - "-Aclippy::bool-to-int-with-if", - "-Aclippy::cast_lossless", - "-Aclippy::cast_possible_truncation", - "-Aclippy::cast_possible_wrap", - "-Aclippy::cast_precision_loss", - "-Aclippy::cast_sign_loss", - "-Aclippy::cognitive_complexity", - "-Aclippy::comparison-chain", - "-Aclippy::default_numeric_fallback", - "-Aclippy::deref_by_slicing", - "-Aclippy::doc_markdown", - "-Aclippy::else_if_without_else", - "-Aclippy::exhaustive_enums", - "-Aclippy::exhaustive_structs", - "-Aclippy::expect_used", - "-Aclippy::float_arithmetic", - "-Aclippy::if_not_else", - "-Aclippy::impl-trait-in-params", - "-Aclippy::implicit_hasher", - "-Aclippy::implicit_return", - "-Aclippy::inconsistent_digit_grouping", - "-Aclippy::indexing_slicing", - "-Aclippy::integer_division", - "-Aclippy::iter_nth_zero", - "-Aclippy::large_digit_groups", - "-Aclippy::len_zero", - "-Aclippy::let_underscore_must_use", - "-Aclippy::manual-string-new", - "-Aclippy::match_same_arms", - "-Aclippy::min_ident_chars", - "-Aclippy::missing-assert-message", - "-Aclippy::missing_docs_in_private_items", - "-Aclippy::missing_errors_doc", - "-Aclippy::missing_inline_in_public_items", - "-Aclippy::missing_panics_doc", - "-Aclippy::missing_trait_methods", - "-Aclippy::mod_module_files", - "-Aclippy::module_inception", - "-Aclippy::module_name_repetitions", - "-Aclippy::modulo_arithmetic", - "-Aclippy::must_use_candidate", - "-Aclippy::needless_for_each", - "-Aclippy::needless_raw_string_hashes", - "-Aclippy::needless_raw_strings", - "-Aclippy::new_without_default", - "-Aclippy::non_ascii_literal", - "-Aclippy::option_if_let_else", - "-Aclippy::panic", - "-Aclippy::panic_in_result_fn", - "-Aclippy::pattern_type_mismatch", - "-Aclippy::print_stderr", - "-Aclippy::print_stdout", - "-Aclippy::pub-use", - "-Aclippy::question-mark-used", - "-Aclippy::self-named-module-files", - "-Aclippy::semicolon_inside_block", - "-Aclippy::semicolon_outside_block", - "-Aclippy::separated_literal_suffix", - "-Aclippy::shadow_reuse", - "-Aclippy::shadow_same", - "-Aclippy::shadow_unrelated", - "-Aclippy::should_implement_trait", - "-Aclippy::similar_names", - "-Aclippy::single_call_fn", - "-Aclippy::single_char_lifetime_names", - "-Aclippy::std-instead-of-alloc", - "-Aclippy::std_instead_of_core", - "-Aclippy::struct_field_names", - "-Aclippy::suboptimal_flops", - "-Aclippy::too_many_arguments", - "-Aclippy::too_many_lines", - "-Aclippy::type_repetition_in_bounds", - "-Aclippy::unnecessary_wraps", - "-Aclippy::unreachable", - "-Aclippy::unreadable_literal", - "-Aclippy::unsafe_derive_deserialize", - "-Aclippy::unused_self", - "-Aclippy::unused_unit", - "-Aclippy::unwrap_in_result", - "-Aclippy::unwrap_used", - "-Aclippy::use_debug", - "-Aclippy::use_self", - "-Aclippy::useless_transmute", - "-Aclippy::wildcard_enum_match_arm", - # - # Disable some of the default rust checks - "-Adead_code", - "-Aelided_lifetimes_in_paths", - "-Aunused_variables", -] diff --git a/Cargo.toml b/Cargo.toml index d03e58ba3..817964672 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,3 +95,154 @@ web-sys = { version = "=0.3.64", features = ["console"] } xz2 = { version = "=0.1.7", features = ["static"] } zip = { version = "=0.6.6", default-features = false, features = ["aes-crypto", "deflate", "time"] } zstd = { version = "=0.12.3", features = ["zstdmt"] } + + +[workspace.lints.rust] +# Lint groups +# https://doc.rust-lang.org/rustc/lints/groups.html +deprecated_in_future = "warn" +future_incompatible = "warn" +nonstandard_style = "warn" +rust_2018_idioms = "warn" +rust_2021_compatibility = "warn" +trivial_numeric_casts = "warn" + +# Disable some of the lints enabled by default +# https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html +dead_code = "allow" +elided_lifetimes_in_paths = "allow" +unused_variables = "allow" + +# Enable lints not enabled by default +# https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html +absolute_paths_not_starting_with_crate = "warn" +explicit_outlives_requirements = "warn" +ffi_unwind_calls = "warn" +keyword_idents = "warn" +let_underscore_drop = "warn" +macro_use_extern_crate = "warn" +meta_variable_misuse = "warn" +missing_abi = "warn" +non_ascii_idents = "warn" +rust_2021_incompatible_closure_captures = "warn" +rust_2021_incompatible_or_patterns = "warn" +rust_2021_prefixes_incompatible_syntax = "warn" +rust_2021_prelude_collisions = "warn" +single_use_lifetimes = "warn" +trivial_casts = "warn" +unit_bindings = "warn" +unsafe_code = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_lifetimes = "warn" +unused_macro_rules = "warn" +unused_qualifications = "warn" +unused_tuple_struct_fields = "warn" +variant_size_differences = "warn" +# missing_copy_implementations = "warn" +# missing_debug_implementations = "warn" + +[workspace.lints.clippy] +# https://rust-lang.github.io/rust-clippy/stable/ +# This is a strict (sometimes too much) Clippy setup. +# We go bold and enable all Clippy lints, then disable the ones that we don't need. +# This has an advantage that when upgrading Rust and Clippy, we receive new lints automatically. +all = { level = "warn", priority = -2 } +pedantic = { level = "warn", priority = -1 } +blanket_clippy_restriction_lints = "allow" +restriction = { level = "warn", priority = -1 } +nursery = { level = "warn", priority = -1 } +# Disable some of the Clippy lints +absolute_paths = "allow" +allow_attributes = "allow" +arithmetic_side_effects = "allow" +as_conversions = "allow" +assign_op_pattern = "allow" +bool_to_int_with_if = "allow" +cast_lossless = "allow" +cast_possible_truncation = "allow" +cast_possible_wrap = "allow" +cast_precision_loss = "allow" +cast_sign_loss = "allow" +cognitive_complexity = "allow" +comparison_chain = "allow" +default_numeric_fallback = "allow" +deref_by_slicing = "allow" +doc_markdown = "allow" +else_if_without_else = "allow" +exhaustive_enums = "allow" +exhaustive_structs = "allow" +expect_used = "allow" +float_arithmetic = "allow" +if_not_else = "allow" +impl_trait_in_params = "allow" +implicit_hasher = "allow" +implicit_return = "allow" +inconsistent_digit_grouping = "allow" +indexing_slicing = "allow" +integer_division = "allow" +iter_nth_zero = "allow" +large_digit_groups = "allow" +len_zero = "allow" +let_underscore_must_use = "allow" +manual_string_new = "allow" +match_same_arms = "allow" +min_ident_chars = "allow" +missing_assert_message = "allow" +missing_docs_in_private_items = "allow" +missing_errors_doc = "allow" +missing_inline_in_public_items = "allow" +missing_panics_doc = "allow" +missing_trait_methods = "allow" +mod_module_files = "allow" +module_inception = "allow" +module_name_repetitions = "allow" +modulo_arithmetic = "allow" +must_use_candidate = "allow" +needless_for_each = "allow" +needless_raw_string_hashes = "allow" +needless_raw_strings = "allow" +new_without_default = "allow" +non_ascii_literal = "allow" +option_if_let_else = "allow" +panic = "allow" +panic_in_result_fn = "allow" +pattern_type_mismatch = "allow" +print_stderr = "allow" +print_stdout = "allow" +pub_use = "allow" +question_mark_used = "allow" +self_named_module_files = "allow" +semicolon_inside_block = "allow" +semicolon_outside_block = "allow" +separated_literal_suffix = "allow" +shadow_reuse = "allow" +shadow_same = "allow" +shadow_unrelated = "allow" +should_implement_trait = "allow" +similar_names = "allow" +single_call_fn = "allow" +single_char_lifetime_names = "allow" +std_instead_of_alloc = "allow" +std_instead_of_core = "allow" +struct_field_names = "allow" +suboptimal_flops = "allow" +too_many_arguments = "allow" +too_many_lines = "allow" +type_repetition_in_bounds = "allow" +unnecessary_wraps = "allow" +unreachable = "allow" +unreadable_literal = "allow" +unsafe_derive_deserialize = "allow" +unused_self = "allow" +unused_unit = "allow" +unwrap_in_result = "allow" +unwrap_used = "allow" +use_debug = "allow" +use_self = "allow" +useless_transmute = "allow" +wildcard_enum_match_arm = "allow" + + +[workspace.lints.rustdoc] +broken_intra_doc_links = "warn" +bare_urls = "warn" diff --git a/packages/nextclade-cli/Cargo.toml b/packages/nextclade-cli/Cargo.toml index 3597f0169..6072a8469 100644 --- a/packages/nextclade-cli/Cargo.toml +++ b/packages/nextclade-cli/Cargo.toml @@ -7,10 +7,14 @@ documentation.workspace = true edition.workspace = true homepage.workspace = true license.workspace = true +lints.workspace = true publish.workspace = true repository.workspace = true version.workspace = true +[lints] +workspace = true + [dependencies] assert2 = { workspace = true } clap = { workspace = true } diff --git a/packages/nextclade-web/Cargo.toml b/packages/nextclade-web/Cargo.toml index e0fc12c24..6e13e04ab 100644 --- a/packages/nextclade-web/Cargo.toml +++ b/packages/nextclade-web/Cargo.toml @@ -8,10 +8,14 @@ documentation.workspace = true edition.workspace = true homepage.workspace = true license.workspace = true +lints.workspace = true publish.workspace = true repository.workspace = true version.workspace = true +[lints] +workspace = true + [lib] crate-type = ["cdylib", "rlib"] diff --git a/packages/nextclade/Cargo.toml b/packages/nextclade/Cargo.toml index 616296433..ea4a8acc6 100644 --- a/packages/nextclade/Cargo.toml +++ b/packages/nextclade/Cargo.toml @@ -11,6 +11,9 @@ publish.workspace = true repository.workspace = true version.workspace = true +[lints] +workspace = true + [lib] crate-type = ["lib"] From 052c1ca825150d27a03da2fa0c41835c35707f86 Mon Sep 17 00:00:00 2001 From: ivan-aksamentov Date: Wed, 14 Feb 2024 13:52:52 +0100 Subject: [PATCH 3/3] refactor: fix new lint warnings For the new rules added as a part of 339e8b6855be10df600444694fba0cd699f326d3 --- .../nextclade-cli/src/cli/nextclade_seq_sort.rs | 6 +++--- packages/nextclade/src/graph/edge.rs | 4 ++-- packages/nextclade/src/graph/node.rs | 2 +- packages/nextclade/src/io/compression.rs | 6 +++--- packages/nextclade/src/io/file.rs | 6 ++++-- .../nextclade/src/translate/frame_shifts_detect.rs | 14 +++++++------- packages/nextclade/src/tree/split_muts.rs | 12 ++++++------ 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/packages/nextclade-cli/src/cli/nextclade_seq_sort.rs b/packages/nextclade-cli/src/cli/nextclade_seq_sort.rs index 65fd9c131..d52976ab8 100644 --- a/packages/nextclade-cli/src/cli/nextclade_seq_sort.rs +++ b/packages/nextclade-cli/src/cli/nextclade_seq_sort.rs @@ -250,7 +250,7 @@ struct StatsPrinter { } impl StatsPrinter { - pub fn new(enabled: bool) -> Self { + fn new(enabled: bool) -> Self { if enabled { println!("Suggested datasets for each sequence"); println!("{}┐", "─".repeat(110)); @@ -268,7 +268,7 @@ impl StatsPrinter { } } - pub fn print_seq(&mut self, datasets: &[MinimizerSearchDatasetResult], seq_name: &str) { + fn print_seq(&mut self, datasets: &[MinimizerSearchDatasetResult], seq_name: &str) { if !self.enabled { return; } @@ -304,7 +304,7 @@ impl StatsPrinter { println!("{}┤", "─".repeat(110)); } - pub fn finish(&self) { + fn finish(&self) { if !self.enabled { return; } diff --git a/packages/nextclade/src/graph/edge.rs b/packages/nextclade/src/graph/edge.rs index 97bdae479..61c490436 100644 --- a/packages/nextclade/src/graph/edge.rs +++ b/packages/nextclade/src/graph/edge.rs @@ -43,7 +43,7 @@ impl Serialize for GraphEdgeKey { } } -impl schemars::JsonSchema for GraphEdgeKey { +impl JsonSchema for GraphEdgeKey { fn schema_name() -> String { "GraphEdgeKey".to_owned() } @@ -54,7 +54,7 @@ impl schemars::JsonSchema for GraphEdgeKey { } /// Edge representing a connection between two nodes. Relevant data can be -/// stored in the edge atomically. Edge's target and source node's are +/// stored in the edge atomically. Edge's target and source nodes are /// weak references and can't outlive the nodes they represent. #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] pub struct Edge { diff --git a/packages/nextclade/src/graph/node.rs b/packages/nextclade/src/graph/node.rs index 368b1d848..307655ee2 100644 --- a/packages/nextclade/src/graph/node.rs +++ b/packages/nextclade/src/graph/node.rs @@ -42,7 +42,7 @@ impl Serialize for GraphNodeKey { } } -impl schemars::JsonSchema for GraphNodeKey { +impl JsonSchema for GraphNodeKey { fn schema_name() -> String { "GraphNodeKey".to_owned() } diff --git a/packages/nextclade/src/io/compression.rs b/packages/nextclade/src/io/compression.rs index c1e577bf8..b99073ebf 100644 --- a/packages/nextclade/src/io/compression.rs +++ b/packages/nextclade/src/io/compression.rs @@ -115,7 +115,7 @@ impl<'r> Decompressor<'r> { } } -impl<'r> Read for Decompressor<'r> { +impl Read for Decompressor<'_> { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { self .decompressor @@ -174,7 +174,7 @@ impl<'w> Compressor<'w> { } } -impl<'w> Write for Compressor<'w> { +impl Write for Compressor<'_> { fn write(&mut self, buf: &[u8]) -> std::io::Result { self .compressor @@ -208,7 +208,7 @@ impl<'w> Write for Compressor<'w> { } } -impl<'w> Drop for Compressor<'w> { +impl Drop for Compressor<'_> { fn drop(&mut self) { self.flush().unwrap(); } diff --git a/packages/nextclade/src/io/file.rs b/packages/nextclade/src/io/file.rs index 6d8959612..499d80d81 100644 --- a/packages/nextclade/src/io/file.rs +++ b/packages/nextclade/src/io/file.rs @@ -1,11 +1,13 @@ use crate::io::fs::ensure_dir; use eyre::{Report, WrapErr}; -use log::{info, warn}; - +use log::info; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Write}; use std::path::{Path, PathBuf}; +#[cfg(not(target_arch = "wasm32"))] +use log::warn; + use crate::io::compression::{Compressor, Decompressor}; #[cfg(not(target_arch = "wasm32"))] use atty::{is as is_tty, Stream}; diff --git a/packages/nextclade/src/translate/frame_shifts_detect.rs b/packages/nextclade/src/translate/frame_shifts_detect.rs index e35eb7229..4ac9e4615 100644 --- a/packages/nextclade/src/translate/frame_shifts_detect.rs +++ b/packages/nextclade/src/translate/frame_shifts_detect.rs @@ -17,7 +17,7 @@ struct FrameShiftDetector { } impl FrameShiftDetector { - pub fn new(start_frame: i32) -> Self { + fn new(start_frame: i32) -> Self { Self { frame_shifts: vec![], frame: start_frame, @@ -30,22 +30,22 @@ impl FrameShiftDetector { } /// Returns frame shifts detected so far */ - pub fn get_frame_shifts(&self) -> &[NucAlnLocalRange] { + fn get_frame_shifts(&self) -> &[NucAlnLocalRange] { &self.frame_shifts } /// Call this for every insertion */ - pub fn add_insertion(&mut self, pos: i32) { + fn add_insertion(&mut self, pos: i32) { self.update(-1, pos); } /// Call this for every deletion */ - pub fn add_deletion(&mut self, pos: i32) { + fn add_deletion(&mut self, pos: i32) { self.update(1, pos); } /// Call this for every non-shifting character (not an indel) */ - pub fn advance(&mut self, pos: i32) { + fn advance(&mut self, pos: i32) { // Avoid full run in advance() on every character. // Only run 1 character when requested by setting `dirty = true` in `update()`. if !self.dirty { @@ -72,7 +72,7 @@ impl FrameShiftDetector { } /// Run this after sequence iteration is over, with the length of the sequence */ - pub fn done(&mut self, pos: i32) { + fn done(&mut self, pos: i32) { if self.begin != POSITION_INVALID { debug_assert!(self.begin >= 0); debug_assert!(self.begin <= pos); @@ -84,7 +84,7 @@ impl FrameShiftDetector { } /** Resets the state of the detector */ - pub fn reset(&mut self) { + fn reset(&mut self) { self.begin = POSITION_INVALID; self.end = POSITION_INVALID; self.last_indel = POSITION_INVALID; diff --git a/packages/nextclade/src/tree/split_muts.rs b/packages/nextclade/src/tree/split_muts.rs index 5655e1d9d..b9d7a40d8 100644 --- a/packages/nextclade/src/tree/split_muts.rs +++ b/packages/nextclade/src/tree/split_muts.rs @@ -52,9 +52,9 @@ pub fn split_muts(left: &BranchMutations, right: &BranchMutations) -> Result>, - pub aa_muts_shared: BTreeMap>, - pub aa_muts_right: BTreeMap>, + aa_muts_left: BTreeMap>, + aa_muts_shared: BTreeMap>, + aa_muts_right: BTreeMap>, } fn split_aa_muts( @@ -79,9 +79,9 @@ fn split_aa_muts( #[derive(Debug, Clone)] struct Split3WayResult { - pub left: Vec, - pub shared: Vec, - pub right: Vec, + left: Vec, + shared: Vec, + right: Vec, } fn split_3_way(left: &[M], right: &[M]) -> Result, Report>