Skip to content

Commit 4849235

Browse files
KSXGitHubclaude
andauthored
lint: upgrade perfectionist (#433)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4e19260 commit 4849235

8 files changed

Lines changed: 68 additions & 45 deletions

File tree

dylint.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
[workspace.metadata.dylint]
22
libraries = [
3-
{ git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.14" },
4-
]
5-
6-
[perfectionist]
7-
disable = [
8-
{ name = "arc_rc_clone", reason = "already use clippy::clone_on_ref_ptr" },
3+
{ git = "https://github.com/KSXGitHub/perfectionist", tag = "0.0.0-rc.17" },
94
]
105

116
["perfectionist::derive_ordering"]
@@ -24,6 +19,11 @@ prefix = [
2419
"LowerHex", "UpperHex", "Octal",
2520
]
2621

22+
# The intended long-term style is "module". It is set to "crate" for now.
23+
# See https://github.com/KSXGitHub/parallel-disk-usage/issues/432.
24+
["perfectionist::import_granularity"]
25+
style = "crate"
26+
2727
["perfectionist::macro_argument_binding"]
2828
deny_extra = ["debug_assert_op", "debug_assert_op_expr"]
2929
allow_extra = ["assert_op_expr"]

src/hardlink/hardlink_list/test.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn add<const ROW: usize>(list: HardlinkList<Bytes>) -> HardlinkList<Bytes> {
2626

2727
#[test]
2828
fn insertion_order_is_irrelevant_to_equality() {
29-
let a = HardlinkList::new()
29+
let first_order = HardlinkList::new()
3030
.pipe(add::<3>)
3131
.pipe(add::<1>)
3232
.pipe(add::<4>)
@@ -37,7 +37,7 @@ fn insertion_order_is_irrelevant_to_equality() {
3737
.pipe(add::<2>)
3838
.into_reflection();
3939

40-
let b = HardlinkList::new()
40+
let second_order = HardlinkList::new()
4141
.pipe(add::<5>)
4242
.pipe(add::<6>)
4343
.pipe(add::<2>)
@@ -48,7 +48,7 @@ fn insertion_order_is_irrelevant_to_equality() {
4848
.pipe(add::<4>)
4949
.into_reflection();
5050

51-
let c = HardlinkList::new()
51+
let sorted_order = HardlinkList::new()
5252
.pipe(add::<0>)
5353
.pipe(add::<1>)
5454
.pipe(add::<2>)
@@ -59,14 +59,14 @@ fn insertion_order_is_irrelevant_to_equality() {
5959
.pipe(add::<7>)
6060
.into_reflection();
6161

62-
assert_eq!(a, b);
63-
assert_eq!(b, c);
64-
assert_eq!(a, c);
62+
assert_eq!(first_order, second_order);
63+
assert_eq!(second_order, sorted_order);
64+
assert_eq!(first_order, sorted_order);
6565
}
6666

6767
#[test]
6868
fn omitting_insertion_cause_inequality() {
69-
let a = HardlinkList::new()
69+
let complete = HardlinkList::new()
7070
.pipe(add::<0>)
7171
.pipe(add::<1>)
7272
.pipe(add::<2>)
@@ -77,7 +77,7 @@ fn omitting_insertion_cause_inequality() {
7777
.pipe(add::<7>)
7878
.into_reflection();
7979

80-
let b = HardlinkList::new()
80+
let missing_one = HardlinkList::new()
8181
.pipe(add::<0>)
8282
.pipe(add::<1>)
8383
.pipe(add::<2>)
@@ -87,13 +87,13 @@ fn omitting_insertion_cause_inequality() {
8787
.pipe(add::<7>)
8888
.into_reflection();
8989

90-
assert_ne!(a, b);
91-
assert_ne!(b, a);
90+
assert_ne!(complete, missing_one);
91+
assert_ne!(missing_one, complete);
9292
}
9393

9494
#[test]
9595
fn insertion_difference_cause_inequality() {
96-
let a = HardlinkList::new()
96+
let with_row_6 = HardlinkList::new()
9797
.pipe(add::<0>)
9898
.pipe(add::<1>)
9999
.pipe(add::<2>)
@@ -103,7 +103,7 @@ fn insertion_difference_cause_inequality() {
103103
.pipe(add::<6>)
104104
.into_reflection();
105105

106-
let b = HardlinkList::new()
106+
let with_row_7 = HardlinkList::new()
107107
.pipe(add::<0>)
108108
.pipe(add::<1>)
109109
.pipe(add::<2>)
@@ -113,8 +113,8 @@ fn insertion_difference_cause_inequality() {
113113
.pipe(add::<7>)
114114
.into_reflection();
115115

116-
assert_ne!(a, b);
117-
assert_ne!(b, a);
116+
assert_ne!(with_row_6, with_row_7);
117+
assert_ne!(with_row_7, with_row_6);
118118
}
119119

120120
#[test]

src/hardlink/link_path_list/test.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@ use pretty_assertions::{assert_eq, assert_ne};
44

55
#[test]
66
fn item_order_is_irrelevant_to_equality() {
7-
let a = ["3", "4", "0", "2", "1"]
7+
let first_order = ["3", "4", "0", "2", "1"]
88
.pipe(LinkPathList::many)
99
.into_reflection();
10-
let b = ["4", "0", "3", "2", "1"]
10+
let second_order = ["4", "0", "3", "2", "1"]
1111
.pipe(LinkPathList::many)
1212
.into_reflection();
13-
let c = ["0", "1", "2", "3", "4"]
13+
let sorted_order = ["0", "1", "2", "3", "4"]
1414
.pipe(LinkPathList::many)
1515
.into_reflection();
16-
assert_eq!(a, b);
17-
assert_eq!(b, c);
18-
assert_eq!(a, c);
16+
assert_eq!(first_order, second_order);
17+
assert_eq!(second_order, sorted_order);
18+
assert_eq!(first_order, sorted_order);
1919
}
2020

2121
#[test]
2222
fn item_absent_cause_inequality() {
23-
let a = ["0", "1", "2", "3"]
23+
let without_last = ["0", "1", "2", "3"]
2424
.pipe(LinkPathList::many)
2525
.into_reflection();
26-
let b = ["0", "1", "2", "3", "4"]
26+
let with_last = ["0", "1", "2", "3", "4"]
2727
.pipe(LinkPathList::many)
2828
.into_reflection();
29-
assert_ne!(a, b);
30-
assert_ne!(b, a);
29+
assert_ne!(without_last, with_last);
30+
assert_ne!(with_last, without_last);
3131
}
3232

3333
#[test]
3434
fn item_difference_cause_inequality() {
35-
let a = ["0", "1", "2", "3", "5"]
35+
let with_five = ["0", "1", "2", "3", "5"]
3636
.pipe(LinkPathList::many)
3737
.into_reflection();
38-
let b = ["0", "1", "2", "3", "4"]
38+
let with_four = ["0", "1", "2", "3", "4"]
3939
.pipe(LinkPathList::many)
4040
.into_reflection();
41-
assert_ne!(a, b);
42-
assert_ne!(b, a);
41+
assert_ne!(with_five, with_four);
42+
assert_ne!(with_four, with_five);
4343
}

src/usage_md.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::args::Args;
2-
use clap::builder::PossibleValue;
3-
use clap::{Arg, ArgAction, Command, CommandFactory};
2+
use clap::{Arg, ArgAction, Command, CommandFactory, builder::PossibleValue};
43
use derive_more::{Display, Error};
54
use itertools::Itertools;
65
use pipe_trait::Pipe;

tests/_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub const DEFAULT_GET_SIZE: get_size::GetApparentSize = get_size::GetApparentSiz
3434

3535
/// Representation of a temporary filesystem item.
3636
///
37-
/// **NOTE:** Delete this once https://github.com/samgiles/rs-mktemp/issues/8 is resolved.
37+
/// **NOTE:** Delete this once <https://github.com/samgiles/rs-mktemp/issues/8> is resolved.
3838
#[derive(Debug, AsRef, Deref)]
3939
#[as_ref(forward)]
4040
#[deref(forward)]

tests/args_fraction.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ use parallel_disk_usage::args::fraction::{ConversionError::*, Fraction, FromStrE
44
use pretty_assertions::assert_eq;
55

66
#[test]
7-
#[allow(clippy::float_cmp)]
7+
#[allow(
8+
clippy::float_cmp,
9+
reason = "the parsed fraction is expected to equal the source literal exactly"
10+
)]
811
fn typical() {
912
let actual: f32 = "0.5".parse::<Fraction>().expect("create ratio").into();
1013
assert_eq!(actual, 0.5);
1114
}
1215

1316
#[test]
14-
#[allow(clippy::float_cmp)]
17+
#[allow(
18+
clippy::float_cmp,
19+
reason = "the parsed fraction is expected to equal the source literal exactly"
20+
)]
1521
fn equal_to_zero() {
1622
let actual: f32 = "0".parse::<Fraction>().expect("create ratio").into();
1723
assert_eq!(actual, 0.0);
@@ -30,7 +36,10 @@ fn less_than_zero() {
3036
}
3137

3238
#[test]
33-
#[allow(clippy::float_cmp)]
39+
#[allow(
40+
clippy::float_cmp,
41+
reason = "the parsed fraction is expected to equal the source literal exactly"
42+
)]
3443
fn less_than_one() {
3544
let actual: f32 = "0.99999".parse::<Fraction>().expect("create ratio").into();
3645
assert_eq!(actual, 0.99999);

tests/hardlinks_deduplication.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ fn stdio(command: Command) -> Command {
3939

4040
#[test]
4141
fn simple_tree_with_some_hardlinks() {
42-
#![expect(clippy::identity_op)]
42+
#![expect(
43+
clippy::identity_op,
44+
reason = "the explicit identity terms keep each component aligned with the structure it represents"
45+
)]
4346

4447
let sizes = [200_000, 220_000, 310_000, 110_000, 210_000];
4548
let workspace = SampleWorkspace::simple_tree_with_some_hardlinks(sizes);
@@ -488,7 +491,10 @@ fn complex_tree_with_shared_and_unique_files() {
488491
// of reasoning.
489492
// It should still produce the same result as the proper
490493
// deduplication formula however.
491-
#[expect(clippy::erasing_op)]
494+
#[expect(
495+
clippy::erasing_op,
496+
reason = "the explicit zero term keeps the external branch aligned with its siblings in the size breakdown"
497+
)]
492498
let expected_size: Bytes = [
493499
inode_size("."),
494500
inode_size("no-hardlinks"),
@@ -665,7 +671,10 @@ fn complex_tree_with_shared_and_unique_files() {
665671

666672
#[test]
667673
fn hardlinks_and_non_hardlinks() {
668-
#![expect(clippy::identity_op)]
674+
#![expect(
675+
clippy::identity_op,
676+
reason = "the explicit identity terms keep each component aligned with the structure it represents"
677+
)]
669678

670679
let files_per_branch = 2 * 4;
671680
let workspace =

tests/hardlinks_deduplication_multi_args.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ fn stdio(command: Command) -> Command {
3535

3636
#[test]
3737
fn simple_tree_with_some_hardlinks() {
38-
#![expect(clippy::identity_op)]
38+
#![expect(
39+
clippy::identity_op,
40+
reason = "the explicit identity terms keep each component aligned with the structure it represents"
41+
)]
3942

4043
let sizes = [200_000, 220_000, 310_000, 110_000, 210_000];
4144
let workspace = SampleWorkspace::simple_tree_with_some_hardlinks(sizes);
@@ -397,7 +400,10 @@ fn multiple_hardlinks_to_a_single_file() {
397400

398401
#[test]
399402
fn multiple_duplicated_arguments() {
400-
#![expect(clippy::identity_op)]
403+
#![expect(
404+
clippy::identity_op,
405+
reason = "the explicit identity terms keep each component aligned with the structure it represents"
406+
)]
401407

402408
let sizes = [200_000, 220_000, 310_000, 110_000, 210_000];
403409
let workspace = SampleWorkspace::simple_tree_with_some_symlinks_and_hardlinks(sizes);

0 commit comments

Comments
 (0)