diff --git a/dylint.toml b/dylint.toml index 0bcf008e..c15c9e48 100644 --- a/dylint.toml +++ b/dylint.toml @@ -1,11 +1,6 @@ [workspace.metadata.dylint] libraries = [ - { git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.14" }, -] - -[perfectionist] -disable = [ - { name = "arc_rc_clone", reason = "already use clippy::clone_on_ref_ptr" }, + { git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.17" }, ] ["perfectionist::derive_ordering"] @@ -24,6 +19,11 @@ prefix = [ "LowerHex", "UpperHex", "Octal", ] +# The intended long-term style is "module". It is set to "crate" for now. +# See https://github.com/KSXGitHub/parallel-disk-usage/issues/432. +["perfectionist::import_granularity"] +style = "crate" + ["perfectionist::macro_argument_binding"] deny_extra = ["debug_assert_op", "debug_assert_op_expr"] allow_extra = ["assert_op_expr"] diff --git a/src/hardlink/hardlink_list/test.rs b/src/hardlink/hardlink_list/test.rs index 04240f86..801f9d1e 100644 --- a/src/hardlink/hardlink_list/test.rs +++ b/src/hardlink/hardlink_list/test.rs @@ -26,7 +26,7 @@ fn add(list: HardlinkList) -> HardlinkList { #[test] fn insertion_order_is_irrelevant_to_equality() { - let a = HardlinkList::new() + let first_order = HardlinkList::new() .pipe(add::<3>) .pipe(add::<1>) .pipe(add::<4>) @@ -37,7 +37,7 @@ fn insertion_order_is_irrelevant_to_equality() { .pipe(add::<2>) .into_reflection(); - let b = HardlinkList::new() + let second_order = HardlinkList::new() .pipe(add::<5>) .pipe(add::<6>) .pipe(add::<2>) @@ -48,7 +48,7 @@ fn insertion_order_is_irrelevant_to_equality() { .pipe(add::<4>) .into_reflection(); - let c = HardlinkList::new() + let sorted_order = HardlinkList::new() .pipe(add::<0>) .pipe(add::<1>) .pipe(add::<2>) @@ -59,14 +59,14 @@ fn insertion_order_is_irrelevant_to_equality() { .pipe(add::<7>) .into_reflection(); - assert_eq!(a, b); - assert_eq!(b, c); - assert_eq!(a, c); + assert_eq!(first_order, second_order); + assert_eq!(second_order, sorted_order); + assert_eq!(first_order, sorted_order); } #[test] fn omitting_insertion_cause_inequality() { - let a = HardlinkList::new() + let complete = HardlinkList::new() .pipe(add::<0>) .pipe(add::<1>) .pipe(add::<2>) @@ -77,7 +77,7 @@ fn omitting_insertion_cause_inequality() { .pipe(add::<7>) .into_reflection(); - let b = HardlinkList::new() + let missing_one = HardlinkList::new() .pipe(add::<0>) .pipe(add::<1>) .pipe(add::<2>) @@ -87,13 +87,13 @@ fn omitting_insertion_cause_inequality() { .pipe(add::<7>) .into_reflection(); - assert_ne!(a, b); - assert_ne!(b, a); + assert_ne!(complete, missing_one); + assert_ne!(missing_one, complete); } #[test] fn insertion_difference_cause_inequality() { - let a = HardlinkList::new() + let with_row_6 = HardlinkList::new() .pipe(add::<0>) .pipe(add::<1>) .pipe(add::<2>) @@ -103,7 +103,7 @@ fn insertion_difference_cause_inequality() { .pipe(add::<6>) .into_reflection(); - let b = HardlinkList::new() + let with_row_7 = HardlinkList::new() .pipe(add::<0>) .pipe(add::<1>) .pipe(add::<2>) @@ -113,8 +113,8 @@ fn insertion_difference_cause_inequality() { .pipe(add::<7>) .into_reflection(); - assert_ne!(a, b); - assert_ne!(b, a); + assert_ne!(with_row_6, with_row_7); + assert_ne!(with_row_7, with_row_6); } #[test] diff --git a/src/hardlink/link_path_list/test.rs b/src/hardlink/link_path_list/test.rs index 5bf35431..ae0a7119 100644 --- a/src/hardlink/link_path_list/test.rs +++ b/src/hardlink/link_path_list/test.rs @@ -4,40 +4,40 @@ use pretty_assertions::{assert_eq, assert_ne}; #[test] fn item_order_is_irrelevant_to_equality() { - let a = ["3", "4", "0", "2", "1"] + let first_order = ["3", "4", "0", "2", "1"] .pipe(LinkPathList::many) .into_reflection(); - let b = ["4", "0", "3", "2", "1"] + let second_order = ["4", "0", "3", "2", "1"] .pipe(LinkPathList::many) .into_reflection(); - let c = ["0", "1", "2", "3", "4"] + let sorted_order = ["0", "1", "2", "3", "4"] .pipe(LinkPathList::many) .into_reflection(); - assert_eq!(a, b); - assert_eq!(b, c); - assert_eq!(a, c); + assert_eq!(first_order, second_order); + assert_eq!(second_order, sorted_order); + assert_eq!(first_order, sorted_order); } #[test] fn item_absent_cause_inequality() { - let a = ["0", "1", "2", "3"] + let without_last = ["0", "1", "2", "3"] .pipe(LinkPathList::many) .into_reflection(); - let b = ["0", "1", "2", "3", "4"] + let with_last = ["0", "1", "2", "3", "4"] .pipe(LinkPathList::many) .into_reflection(); - assert_ne!(a, b); - assert_ne!(b, a); + assert_ne!(without_last, with_last); + assert_ne!(with_last, without_last); } #[test] fn item_difference_cause_inequality() { - let a = ["0", "1", "2", "3", "5"] + let with_five = ["0", "1", "2", "3", "5"] .pipe(LinkPathList::many) .into_reflection(); - let b = ["0", "1", "2", "3", "4"] + let with_four = ["0", "1", "2", "3", "4"] .pipe(LinkPathList::many) .into_reflection(); - assert_ne!(a, b); - assert_ne!(b, a); + assert_ne!(with_five, with_four); + assert_ne!(with_four, with_five); } diff --git a/src/usage_md.rs b/src/usage_md.rs index d718568d..31d576d9 100644 --- a/src/usage_md.rs +++ b/src/usage_md.rs @@ -1,6 +1,5 @@ use crate::args::Args; -use clap::builder::PossibleValue; -use clap::{Arg, ArgAction, Command, CommandFactory}; +use clap::{Arg, ArgAction, Command, CommandFactory, builder::PossibleValue}; use derive_more::{Display, Error}; use itertools::Itertools; use pipe_trait::Pipe; diff --git a/tests/_utils.rs b/tests/_utils.rs index 1d30da0b..1d56ad76 100644 --- a/tests/_utils.rs +++ b/tests/_utils.rs @@ -34,7 +34,7 @@ pub const DEFAULT_GET_SIZE: get_size::GetApparentSize = get_size::GetApparentSiz /// Representation of a temporary filesystem item. /// -/// **NOTE:** Delete this once https://github.com/samgiles/rs-mktemp/issues/8 is resolved. +/// **NOTE:** Delete this once is resolved. #[derive(Debug, AsRef, Deref)] #[as_ref(forward)] #[deref(forward)] diff --git a/tests/args_fraction.rs b/tests/args_fraction.rs index 6413218f..b1878f50 100644 --- a/tests/args_fraction.rs +++ b/tests/args_fraction.rs @@ -4,14 +4,20 @@ use parallel_disk_usage::args::fraction::{ConversionError::*, Fraction, FromStrE use pretty_assertions::assert_eq; #[test] -#[allow(clippy::float_cmp)] +#[allow( + clippy::float_cmp, + reason = "the parsed fraction is expected to equal the source literal exactly" +)] fn typical() { let actual: f32 = "0.5".parse::().expect("create ratio").into(); assert_eq!(actual, 0.5); } #[test] -#[allow(clippy::float_cmp)] +#[allow( + clippy::float_cmp, + reason = "the parsed fraction is expected to equal the source literal exactly" +)] fn equal_to_zero() { let actual: f32 = "0".parse::().expect("create ratio").into(); assert_eq!(actual, 0.0); @@ -30,7 +36,10 @@ fn less_than_zero() { } #[test] -#[allow(clippy::float_cmp)] +#[allow( + clippy::float_cmp, + reason = "the parsed fraction is expected to equal the source literal exactly" +)] fn less_than_one() { let actual: f32 = "0.99999".parse::().expect("create ratio").into(); assert_eq!(actual, 0.99999); diff --git a/tests/hardlinks_deduplication.rs b/tests/hardlinks_deduplication.rs index 7816a0d6..d4f9b139 100644 --- a/tests/hardlinks_deduplication.rs +++ b/tests/hardlinks_deduplication.rs @@ -39,7 +39,10 @@ fn stdio(command: Command) -> Command { #[test] fn simple_tree_with_some_hardlinks() { - #![expect(clippy::identity_op)] + #![expect( + clippy::identity_op, + reason = "the explicit identity terms keep each component aligned with the structure it represents" + )] let sizes = [200_000, 220_000, 310_000, 110_000, 210_000]; let workspace = SampleWorkspace::simple_tree_with_some_hardlinks(sizes); @@ -488,7 +491,10 @@ fn complex_tree_with_shared_and_unique_files() { // of reasoning. // It should still produce the same result as the proper // deduplication formula however. - #[expect(clippy::erasing_op)] + #[expect( + clippy::erasing_op, + reason = "the explicit zero term keeps the external branch aligned with its siblings in the size breakdown" + )] let expected_size: Bytes = [ inode_size("."), inode_size("no-hardlinks"), @@ -665,7 +671,10 @@ fn complex_tree_with_shared_and_unique_files() { #[test] fn hardlinks_and_non_hardlinks() { - #![expect(clippy::identity_op)] + #![expect( + clippy::identity_op, + reason = "the explicit identity terms keep each component aligned with the structure it represents" + )] let files_per_branch = 2 * 4; let workspace = diff --git a/tests/hardlinks_deduplication_multi_args.rs b/tests/hardlinks_deduplication_multi_args.rs index 2e1ed737..e398b91d 100644 --- a/tests/hardlinks_deduplication_multi_args.rs +++ b/tests/hardlinks_deduplication_multi_args.rs @@ -35,7 +35,10 @@ fn stdio(command: Command) -> Command { #[test] fn simple_tree_with_some_hardlinks() { - #![expect(clippy::identity_op)] + #![expect( + clippy::identity_op, + reason = "the explicit identity terms keep each component aligned with the structure it represents" + )] let sizes = [200_000, 220_000, 310_000, 110_000, 210_000]; let workspace = SampleWorkspace::simple_tree_with_some_hardlinks(sizes); @@ -397,7 +400,10 @@ fn multiple_hardlinks_to_a_single_file() { #[test] fn multiple_duplicated_arguments() { - #![expect(clippy::identity_op)] + #![expect( + clippy::identity_op, + reason = "the explicit identity terms keep each component aligned with the structure it represents" + )] let sizes = [200_000, 220_000, 310_000, 110_000, 210_000]; let workspace = SampleWorkspace::simple_tree_with_some_symlinks_and_hardlinks(sizes);