From f3527bc06dee198abb36195902c58bce75340b9d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 29 May 2026 14:18:22 +0000 Subject: [PATCH] style: switch import granularity from crate to module Set perfectionist::import_granularity to "module" in dylint.toml and reformat the affected use statements throughout the codebase so that imports are merged per module rather than collapsed per crate. Update the import-organization guidance in CONTRIBUTING.md and the generated AI-instruction files accordingly. https://claude.ai/code/session_01JJJRc2hmtFiByBeCZnVsoF --- .github/copilot-instructions.md | 2 +- AGENTS.md | 2 +- CLAUDE.md | 2 +- CONTRIBUTING.md | 13 ++++--- cli/ai_instructions.rs | 12 +++---- dylint.toml | 4 +-- src/app.rs | 24 ++++++------- src/app/hdd.rs | 10 +++--- src/app/hdd/test.rs | 8 ++--- src/app/hdd/test_linux.rs | 6 ++-- src/app/mount_point.rs | 3 +- src/app/overlapping_arguments.rs | 12 +++---- .../test_remove_overlapping_paths.rs | 3 +- src/app/sub.rs | 32 +++++++++-------- src/app/sub/unix_ext.rs | 10 +++--- src/args.rs | 3 +- src/args/depth.rs | 6 ++-- src/args/fraction.rs | 8 ++--- src/args/threads.rs | 6 ++-- src/data_tree/hardlink.rs | 3 +- src/data_tree/reflection.rs | 10 +++--- src/data_tree/reflection/convert.rs | 3 +- src/data_tree/reflection/par_methods.rs | 6 ++-- src/data_tree/retain/test.rs | 6 ++-- src/fs_tree_builder.rs | 25 ++++++------- src/hardlink/aware.rs | 20 ++++++----- src/hardlink/deduplicate.rs | 4 ++- src/hardlink/hardlink_list.rs | 5 ++- src/hardlink/hardlink_list/iter.rs | 7 ++-- src/hardlink/hardlink_list/reflection.rs | 4 ++- src/hardlink/hardlink_list/summary.rs | 10 +++--- src/hardlink/ignorant.rs | 4 ++- src/hardlink/link_path_list/iter.rs | 4 ++- src/hardlink/link_path_list/reflection.rs | 3 +- src/hardlink/record.rs | 3 +- src/json_data.rs | 8 ++--- src/man_page.rs | 3 +- src/os_string_display.rs | 6 ++-- src/reporter/error_report.rs | 3 +- src/reporter/error_report/text_report.rs | 4 ++- src/reporter/event.rs | 3 +- src/reporter/progress_and_error_reporter.rs | 15 ++++---- .../progress_report_state.rs | 10 +++--- src/reporter/progress_report.rs | 3 +- src/runtime_error.rs | 3 +- src/size.rs | 8 ++--- src/tree_builder.rs | 3 +- src/usage_md.rs | 3 +- src/visualizer.rs | 3 +- src/visualizer/display.rs | 3 +- src/visualizer/methods.rs | 3 +- src/visualizer/methods/bar_table.rs | 6 ++-- src/visualizer/methods/initial_table.rs | 8 +++-- src/visualizer/methods/tree_table.rs | 18 ++++------ template/ai-instructions/shared.md | 2 +- tests/_utils.rs | 35 +++++++++---------- tests/args_fraction.rs | 4 ++- tests/cli_errors.rs | 32 +++++++++++------ tests/data_tree_reflection.rs | 7 ++-- tests/fs_tree_builder.rs | 10 +++--- tests/hardlinks_deduplication.rs | 31 +++++++--------- tests/hardlinks_deduplication_multi_args.rs | 27 ++++++-------- tests/hardlinks_without_deduplication.rs | 14 +++----- tests/json.rs | 30 ++++++++-------- tests/one_file_system.rs | 34 +++++++++--------- tests/os_string_display.rs | 4 ++- tests/tree_builder.rs | 8 ++--- tests/usual_cli.rs | 20 +++++------ tests/visualizer.rs | 10 +++--- 69 files changed, 333 insertions(+), 331 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 051bf7bd..b5b320c6 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -7,7 +7,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c - Commit format: Conventional Commits. Pattern: `type(scope): lowercase description`. The scope is optional. - Version releases are the only exception. The commit message is just the version number, such as `0.21.1`. - Write documentation, comments, and other prose for ease of understanding first. Prefer a formal tone when it does not hurt clarity, and use complete sentences. Avoid mid-sentence breaks introduced by em dashes or long parenthetical clauses. Em dashes are a reliable symptom of loose phrasing; when one appears, restructure the surrounding sentence so each clause stands on its own rather than swapping the em dash for another punctuation mark. -- Prefer merged imports. +- Prefer imports merged per module. Combine items from the same module into a single `use` statement, but write a separate `use` statement for each module rather than collapsing every path from a crate into one nested-braces statement. - Use descriptive names for generics, such as `Size` and `Report`. Do not use single letters. - Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; (5) index variables `i`/`j`/`k` in short closures or index-based loops; and (6) test fixtures with identical roles. Single letters are never permitted in multi-line functions or closures. - Use `pipe-trait` to chain through unary functions such as constructors, `Some`, `Ok`, and free functions. Use it to flatten nested calls and to continue method chains. Do not use it for simple standalone calls; prefer `foo(value)` over `value.pipe(foo)`. diff --git a/AGENTS.md b/AGENTS.md index 051bf7bd..b5b320c6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,7 +7,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c - Commit format: Conventional Commits. Pattern: `type(scope): lowercase description`. The scope is optional. - Version releases are the only exception. The commit message is just the version number, such as `0.21.1`. - Write documentation, comments, and other prose for ease of understanding first. Prefer a formal tone when it does not hurt clarity, and use complete sentences. Avoid mid-sentence breaks introduced by em dashes or long parenthetical clauses. Em dashes are a reliable symptom of loose phrasing; when one appears, restructure the surrounding sentence so each clause stands on its own rather than swapping the em dash for another punctuation mark. -- Prefer merged imports. +- Prefer imports merged per module. Combine items from the same module into a single `use` statement, but write a separate `use` statement for each module rather than collapsing every path from a crate into one nested-braces statement. - Use descriptive names for generics, such as `Size` and `Report`. Do not use single letters. - Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; (5) index variables `i`/`j`/`k` in short closures or index-based loops; and (6) test fixtures with identical roles. Single letters are never permitted in multi-line functions or closures. - Use `pipe-trait` to chain through unary functions such as constructors, `Some`, `Ok`, and free functions. Use it to flatten nested calls and to continue method chains. Do not use it for simple standalone calls; prefer `foo(value)` over `value.pipe(foo)`. diff --git a/CLAUDE.md b/CLAUDE.md index 9eabaa1d..2b4f89f1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,7 +7,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c - Commit format: Conventional Commits. Pattern: `type(scope): lowercase description`. The scope is optional. - Version releases are the only exception. The commit message is just the version number, such as `0.21.1`. - Write documentation, comments, and other prose for ease of understanding first. Prefer a formal tone when it does not hurt clarity, and use complete sentences. Avoid mid-sentence breaks introduced by em dashes or long parenthetical clauses. Em dashes are a reliable symptom of loose phrasing; when one appears, restructure the surrounding sentence so each clause stands on its own rather than swapping the em dash for another punctuation mark. -- Prefer merged imports. +- Prefer imports merged per module. Combine items from the same module into a single `use` statement, but write a separate `use` statement for each module rather than collapsing every path from a crate into one nested-braces statement. - Use descriptive names for generics, such as `Size` and `Report`. Do not use single letters. - Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; (5) index variables `i`/`j`/`k` in short closures or index-based loops; and (6) test fixtures with identical roles. Single letters are never permitted in multi-line functions or closures. - Use `pipe-trait` to chain through unary functions such as constructors, `Some`, `Ok`, and free functions. Use it to flatten nested calls and to continue method chains. Do not use it for simple standalone calls; prefer `foo(value)` over `value.pipe(foo)`. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6859b25..3778ef47 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,17 +36,16 @@ Automated tools enforce formatting (`cargo fmt`), linting (`cargo clippy`), and ### Import Organization -Prefer **merged imports**. Combine multiple items from the same crate or module into a single `use` statement with braces rather than separate `use` lines. Import ordering is enforced by `cargo fmt`. Imports gated by a platform attribute such as `#[cfg(unix)]` go in a separate block after the main imports. +Prefer **merged imports** at module granularity. Combine multiple items from the same module into a single `use` statement with braces, but write a separate `use` statement for each module rather than collapsing every path from a crate into one nested-braces statement. This granularity is enforced by the `perfectionist::import_granularity` dylint check (`style = "module"`). Import ordering is enforced by `cargo fmt`. Imports gated by a platform attribute such as `#[cfg(unix)]` go in a separate block after the main imports. ```rust -use crate::{ - args::{Args, Quantity, Threads}, - bytes_format::BytesFormat, - size, -}; +use crate::args::{Args, Quantity, Threads}; +use crate::bytes_format::BytesFormat; +use crate::size; use clap::Parser; use pipe_trait::Pipe; -use std::{io::stdin, time::Duration}; +use std::io::stdin; +use std::time::Duration; #[cfg(unix)] use crate::get_size::{GetBlockCount, GetBlockSize}; diff --git a/cli/ai_instructions.rs b/cli/ai_instructions.rs index 5e76db26..82b52446 100644 --- a/cli/ai_instructions.rs +++ b/cli/ai_instructions.rs @@ -1,13 +1,11 @@ use clap::Parser; use derive_more::Display; use pipe_trait::Pipe; -use std::{ - fmt, - fs::{File, read_to_string}, - io::{self, Write}, - path::{Path, PathBuf}, - process::ExitCode, -}; +use std::fmt; +use std::fs::{File, read_to_string}; +use std::io::{self, Write}; +use std::path::{Path, PathBuf}; +use std::process::ExitCode; const SHARED: &str = include_str!("../template/ai-instructions/shared.md"); const CLAUDE: &str = include_str!("../template/ai-instructions/claude.md"); diff --git a/dylint.toml b/dylint.toml index c15c9e48..36185081 100644 --- a/dylint.toml +++ b/dylint.toml @@ -19,10 +19,8 @@ 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" +style = "module" ["perfectionist::macro_argument_binding"] deny_extra = ["debug_assert_op", "debug_assert_op_expr"] diff --git a/src/app.rs b/src/app.rs index 58c6ff0f..d98cdc2e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -2,22 +2,20 @@ pub mod sub; pub use sub::Sub; -use crate::{ - args::{Args, Quantity, Threads}, - bytes_format::BytesFormat, - device::DeviceBoundary, - get_size::{GetApparentSize, GetSize}, - hardlink, - json_data::{JsonData, JsonDataBody, JsonShared, JsonTree}, - reporter::{ErrorOnlyReporter, ErrorReport, ProgressAndErrorReporter, ProgressReport}, - runtime_error::RuntimeError, - size, - visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, -}; +use crate::args::{Args, Quantity, Threads}; +use crate::bytes_format::BytesFormat; +use crate::device::DeviceBoundary; +use crate::get_size::{GetApparentSize, GetSize}; +use crate::json_data::{JsonData, JsonDataBody, JsonShared, JsonTree}; +use crate::reporter::{ErrorOnlyReporter, ErrorReport, ProgressAndErrorReporter, ProgressReport}; +use crate::runtime_error::RuntimeError; +use crate::visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}; +use crate::{hardlink, size}; use clap::Parser; use hdd::any_path_is_in_hdd; use pipe_trait::Pipe; -use std::{io::stdin, time::Duration}; +use std::io::stdin; +use std::time::Duration; use sub::JsonOutputParam; use sysinfo::{Disk, Disks}; diff --git a/src/app/hdd.rs b/src/app/hdd.rs index c7df4331..e93567d7 100644 --- a/src/app/hdd.rs +++ b/src/app/hdd.rs @@ -1,10 +1,8 @@ use super::mount_point::find_mount_point; -use std::{ - ffi::OsStr, - fs::canonicalize, - io, - path::{Path, PathBuf}, -}; +use std::ffi::OsStr; +use std::fs::canonicalize; +use std::io; +use std::path::{Path, PathBuf}; use sysinfo::{Disk, DiskKind}; #[cfg(target_os = "linux")] diff --git a/src/app/hdd/test.rs b/src/app/hdd/test.rs index 6e628ea5..fe0aeeeb 100644 --- a/src/app/hdd/test.rs +++ b/src/app/hdd/test.rs @@ -1,11 +1,9 @@ use super::{DiskApi, FsApi, any_path_is_in_hdd, path_is_in_hdd}; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use std::{ - ffi::OsStr, - io, - path::{Path, PathBuf}, -}; +use std::ffi::OsStr; +use std::io; +use std::path::{Path, PathBuf}; use sysinfo::DiskKind; /// Fake disk for [`DiskApi`]. diff --git a/src/app/hdd/test_linux.rs b/src/app/hdd/test_linux.rs index 5d2f2044..5ce270bf 100644 --- a/src/app/hdd/test_linux.rs +++ b/src/app/hdd/test_linux.rs @@ -1,10 +1,8 @@ use super::{FsApi, VIRTUAL_DISK_KIND, parse_block_device_name, reclassify_virtual_hdd}; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use std::{ - io, - path::{Path, PathBuf}, -}; +use std::io; +use std::path::{Path, PathBuf}; use sysinfo::DiskKind; /// Test pure parsing of block device names — no sysfs dependency. diff --git a/src/app/mount_point.rs b/src/app/mount_point.rs index c0dbcea7..7c33e141 100644 --- a/src/app/mount_point.rs +++ b/src/app/mount_point.rs @@ -1,4 +1,5 @@ -use std::{ffi::OsStr, path::Path}; +use std::ffi::OsStr; +use std::path::Path; /// Find a mount point that contains `absolute_path`. pub fn find_mount_point<'a>( diff --git a/src/app/overlapping_arguments.rs b/src/app/overlapping_arguments.rs index 328b55bb..ad71b19f 100644 --- a/src/app/overlapping_arguments.rs +++ b/src/app/overlapping_arguments.rs @@ -1,11 +1,9 @@ use pipe_trait::Pipe; -use std::{ - collections::HashSet, - fs::{canonicalize, symlink_metadata}, - io, - mem::take, - path::PathBuf, -}; +use std::collections::HashSet; +use std::fs::{canonicalize, symlink_metadata}; +use std::io; +use std::mem::take; +use std::path::PathBuf; /// Mockable APIs to interact with the system. pub trait Api { diff --git a/src/app/overlapping_arguments/test_remove_overlapping_paths.rs b/src/app/overlapping_arguments/test_remove_overlapping_paths.rs index 7cbab6d2..a581b6ea 100644 --- a/src/app/overlapping_arguments/test_remove_overlapping_paths.rs +++ b/src/app/overlapping_arguments/test_remove_overlapping_paths.rs @@ -2,7 +2,8 @@ use super::{Api, remove_overlapping_paths}; use normalize_path::NormalizePath; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use std::{convert::Infallible, path::PathBuf}; +use std::convert::Infallible; +use std::path::PathBuf; const MOCKED_CURRENT_DIR: &str = "/home/user/current-dir"; diff --git a/src/app/sub.rs b/src/app/sub.rs index 577dd4e5..815b31f8 100644 --- a/src/app/sub.rs +++ b/src/app/sub.rs @@ -1,21 +1,23 @@ -use crate::{ - args::{Depth, Fraction}, - data_tree::DataTree, - device::DeviceBoundary, - fs_tree_builder::FsTreeBuilder, - get_size::GetSize, - hardlink::{DeduplicateSharedSize, HardlinkIgnorant, RecordHardlinks}, - json_data::{BinaryVersion, JsonData, JsonDataBody, JsonShared, JsonTree, SchemaVersion}, - os_string_display::OsStringDisplay, - reporter::ParallelReporter, - runtime_error::RuntimeError, - size, - status_board::GLOBAL_STATUS_BOARD, - visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, +use crate::args::{Depth, Fraction}; +use crate::data_tree::DataTree; +use crate::device::DeviceBoundary; +use crate::fs_tree_builder::FsTreeBuilder; +use crate::get_size::GetSize; +use crate::hardlink::{DeduplicateSharedSize, HardlinkIgnorant, RecordHardlinks}; +use crate::json_data::{ + BinaryVersion, JsonData, JsonDataBody, JsonShared, JsonTree, SchemaVersion, }; +use crate::os_string_display::OsStringDisplay; +use crate::reporter::ParallelReporter; +use crate::runtime_error::RuntimeError; +use crate::size; +use crate::status_board::GLOBAL_STATUS_BOARD; +use crate::visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}; use pipe_trait::Pipe; use serde::Serialize; -use std::{io::stdout, iter::once, path::PathBuf}; +use std::io::stdout; +use std::iter::once; +use std::path::PathBuf; /// The sub program of the main application. pub struct Sub diff --git a/src/app/sub/unix_ext.rs b/src/app/sub/unix_ext.rs index 12fd8bf8..3e46aff1 100644 --- a/src/app/sub/unix_ext.rs +++ b/src/app/sub/unix_ext.rs @@ -1,8 +1,10 @@ use super::HardlinkSubroutines; -use crate::{ - data_tree::DataTree, hardlink::HardlinkAware, json_data::JsonShared, - os_string_display::OsStringDisplay, runtime_error::RuntimeError, size, -}; +use crate::data_tree::DataTree; +use crate::hardlink::HardlinkAware; +use crate::json_data::JsonShared; +use crate::os_string_display::OsStringDisplay; +use crate::runtime_error::RuntimeError; +use crate::size; use pipe_trait::Pipe; impl HardlinkSubroutines for HardlinkAware diff --git a/src/args.rs b/src/args.rs index 6ca380c5..a1e8961d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -8,7 +8,8 @@ pub use fraction::Fraction; pub use quantity::Quantity; pub use threads::Threads; -use crate::{bytes_format::BytesFormat, visualizer::ColumnWidthDistribution}; +use crate::bytes_format::BytesFormat; +use crate::visualizer::ColumnWidthDistribution; use clap::{ColorChoice, Parser}; use derive_setters::Setters; use smart_default::SmartDefault; diff --git a/src/args/depth.rs b/src/args/depth.rs index 375570a7..7248b70f 100644 --- a/src/args/depth.rs +++ b/src/args/depth.rs @@ -1,8 +1,6 @@ use derive_more::{Display, Error}; -use std::{ - num::{NonZeroU64, ParseIntError, TryFromIntError}, - str::FromStr, -}; +use std::num::{NonZeroU64, ParseIntError, TryFromIntError}; +use std::str::FromStr; const INFINITE: &str = "inf"; diff --git a/src/args/fraction.rs b/src/args/fraction.rs index e7bef60a..0bbcf80e 100644 --- a/src/args/fraction.rs +++ b/src/args/fraction.rs @@ -1,9 +1,7 @@ use derive_more::{AsRef, Deref, Display, Error, Into}; -use std::{ - convert::{TryFrom, TryInto}, - num::ParseFloatError, - str::FromStr, -}; +use std::convert::{TryFrom, TryInto}; +use std::num::ParseFloatError; +use std::str::FromStr; /// Floating-point value that is greater than or equal to 0 and less than 1. #[derive(Debug, Display, Default, Clone, Copy, PartialEq, PartialOrd, AsRef, Deref, Into)] diff --git a/src/args/threads.rs b/src/args/threads.rs index 8f058b13..ade48072 100644 --- a/src/args/threads.rs +++ b/src/args/threads.rs @@ -1,8 +1,6 @@ use derive_more::{Display, Error}; -use std::{ - num::{NonZeroUsize, ParseIntError}, - str::FromStr, -}; +use std::num::{NonZeroUsize, ParseIntError}; +use std::str::FromStr; const AUTO: &str = "auto"; const MAX: &str = "max"; diff --git a/src/data_tree/hardlink.rs b/src/data_tree/hardlink.rs index 8cbf93b8..b686d629 100644 --- a/src/data_tree/hardlink.rs +++ b/src/data_tree/hardlink.rs @@ -2,7 +2,8 @@ use super::DataTree; use crate::size; use assert_cmp::debug_assert_op; use rayon::prelude::*; -use std::{ffi::OsStr, path::Path}; +use std::ffi::OsStr; +use std::path::Path; impl DataTree where diff --git a/src/data_tree/reflection.rs b/src/data_tree/reflection.rs index 8288b4b2..47b64666 100644 --- a/src/data_tree/reflection.rs +++ b/src/data_tree/reflection.rs @@ -1,10 +1,8 @@ use crate::size; -use std::{ - collections::VecDeque, - ffi::OsStr, - fmt::{Debug, Display, Error, Formatter}, - path::PathBuf, -}; +use std::collections::VecDeque; +use std::ffi::OsStr; +use std::fmt::{Debug, Display, Error, Formatter}; +use std::path::PathBuf; #[cfg(feature = "json")] use serde::{Deserialize, Serialize}; diff --git a/src/data_tree/reflection/convert.rs b/src/data_tree/reflection/convert.rs index ff360800..ff2aa304 100644 --- a/src/data_tree/reflection/convert.rs +++ b/src/data_tree/reflection/convert.rs @@ -1,5 +1,6 @@ use super::Reflection; -use crate::{data_tree::DataTree, size}; +use crate::data_tree::DataTree; +use crate::size; impl From> for Reflection { fn from(source: DataTree) -> Self { diff --git a/src/data_tree/reflection/par_methods.rs b/src/data_tree/reflection/par_methods.rs index 786c1dad..397cdd68 100644 --- a/src/data_tree/reflection/par_methods.rs +++ b/src/data_tree/reflection/par_methods.rs @@ -1,7 +1,9 @@ use super::{ConversionError, Reflection}; -use crate::{data_tree::DataTree, size}; +use crate::data_tree::DataTree; +use crate::size; use rayon::prelude::*; -use std::{ffi::OsStr, iter::once}; +use std::ffi::OsStr; +use std::iter::once; impl Reflection where diff --git a/src/data_tree/retain/test.rs b/src/data_tree/retain/test.rs index 2c8e7fef..8819b047 100644 --- a/src/data_tree/retain/test.rs +++ b/src/data_tree/retain/test.rs @@ -1,6 +1,8 @@ -use crate::{data_tree::DataTree, size::Bytes}; +use crate::data_tree::DataTree; +use crate::size::Bytes; use pretty_assertions::assert_eq; -use std::{cmp::Ordering, ops::Not}; +use std::cmp::Ordering; +use std::ops::Not; type SampleName = String; type SampleData = Bytes; diff --git a/src/fs_tree_builder.rs b/src/fs_tree_builder.rs index 21b0902d..1a8da080 100644 --- a/src/fs_tree_builder.rs +++ b/src/fs_tree_builder.rs @@ -1,19 +1,16 @@ -use super::{ - data_tree::DataTree, - device::DeviceBoundary, - get_size::GetSize, - hardlink::{RecordHardlinks, RecordHardlinksArgument}, - os_string_display::OsStringDisplay, - reporter::{ErrorReport, Event, Reporter, error_report::Operation::*}, - size, - tree_builder::{Info, TreeBuilder}, -}; +use super::data_tree::DataTree; +use super::device::DeviceBoundary; +use super::get_size::GetSize; +use super::hardlink::{RecordHardlinks, RecordHardlinksArgument}; +use super::os_string_display::OsStringDisplay; +use super::reporter::error_report::Operation::*; +use super::reporter::{ErrorReport, Event, Reporter}; +use super::size; +use super::tree_builder::{Info, TreeBuilder}; use device_id::get_device_id; use pipe_trait::Pipe; -use std::{ - fs::{read_dir, symlink_metadata}, - path::PathBuf, -}; +use std::fs::{read_dir, symlink_metadata}; +use std::path::PathBuf; /// Build a [`DataTree`] from a directory tree using [`From`] or [`Into`]. /// diff --git a/src/hardlink/aware.rs b/src/hardlink/aware.rs index 65f2b0af..4d8ba0c7 100644 --- a/src/hardlink/aware.rs +++ b/src/hardlink/aware.rs @@ -2,18 +2,20 @@ use super::{ DeduplicateSharedSize, HardlinkList, LinkPathList, RecordHardlinks, RecordHardlinksArgument, hardlink_list, }; -use crate::{ - data_tree::DataTree, - device::DeviceNumber, - inode::InodeNumber, - os_string_display::OsStringDisplay, - reporter::{Event, Reporter, event::HardlinkDetection}, - size, -}; +use crate::data_tree::DataTree; +use crate::device::DeviceNumber; +use crate::inode::InodeNumber; +use crate::os_string_display::OsStringDisplay; +use crate::reporter::event::HardlinkDetection; +use crate::reporter::{Event, Reporter}; +use crate::size; use derive_more::{AsMut, AsRef, Display, Error, From, Into}; use pipe_trait::Pipe; use smart_default::SmartDefault; -use std::{convert::Infallible, fmt::Debug, os::unix::fs::MetadataExt, path::Path}; +use std::convert::Infallible; +use std::fmt::Debug; +use std::os::unix::fs::MetadataExt; +use std::path::Path; /// Be aware of hardlinks. Treat them as links that share space. /// Detect files with more than 1 links and record them. diff --git a/src/hardlink/deduplicate.rs b/src/hardlink/deduplicate.rs index 737ae74c..ecba375f 100644 --- a/src/hardlink/deduplicate.rs +++ b/src/hardlink/deduplicate.rs @@ -1,4 +1,6 @@ -use crate::{data_tree::DataTree, os_string_display::OsStringDisplay, size}; +use crate::data_tree::DataTree; +use crate::os_string_display::OsStringDisplay; +use crate::size; /// Ability to correct the sizes in a [`DataTree`] by reducing the size of recorded shared links. /// diff --git a/src/hardlink/hardlink_list.rs b/src/hardlink/hardlink_list.rs index 8fe6dfd7..4846c83f 100644 --- a/src/hardlink/hardlink_list.rs +++ b/src/hardlink/hardlink_list.rs @@ -9,7 +9,10 @@ pub use summary::Summary; pub use Reflection as HardlinkListReflection; pub use Summary as SharedLinkSummary; -use crate::{device::DeviceNumber, hardlink::LinkPathList, inode::InodeNumber, size}; +use crate::device::DeviceNumber; +use crate::hardlink::LinkPathList; +use crate::inode::InodeNumber; +use crate::size; use dashmap::DashMap; use derive_more::{Display, Error}; use smart_default::SmartDefault; diff --git a/src/hardlink/hardlink_list/iter.rs b/src/hardlink/hardlink_list/iter.rs index 539ec5c7..268e02cc 100644 --- a/src/hardlink/hardlink_list/iter.rs +++ b/src/hardlink/hardlink_list/iter.rs @@ -1,6 +1,9 @@ use super::{HardlinkList, InodeKey, Value}; -use crate::{device::DeviceNumber, hardlink::LinkPathList, inode::InodeNumber}; -use dashmap::{iter::Iter as DashIter, mapref::multiple::RefMulti}; +use crate::device::DeviceNumber; +use crate::hardlink::LinkPathList; +use crate::inode::InodeNumber; +use dashmap::iter::Iter as DashIter; +use dashmap::mapref::multiple::RefMulti; use pipe_trait::Pipe; /// Iterator over entries in [`HardlinkList`]. diff --git a/src/hardlink/hardlink_list/reflection.rs b/src/hardlink/hardlink_list/reflection.rs index 7a6659c2..33df41d6 100644 --- a/src/hardlink/hardlink_list/reflection.rs +++ b/src/hardlink/hardlink_list/reflection.rs @@ -1,5 +1,7 @@ use super::{HardlinkList, InodeKey, Value}; -use crate::{device::DeviceNumber, hardlink::LinkPathListReflection, inode::InodeNumber}; +use crate::device::DeviceNumber; +use crate::hardlink::LinkPathListReflection; +use crate::inode::InodeNumber; use dashmap::DashMap; use derive_more::{Display, Error, Into, IntoIterator}; use into_sorted::IntoSortedUnstable; diff --git a/src/hardlink/hardlink_list/summary.rs b/src/hardlink/hardlink_list/summary.rs index 79871e05..22fabf11 100644 --- a/src/hardlink/hardlink_list/summary.rs +++ b/src/hardlink/hardlink_list/summary.rs @@ -1,11 +1,11 @@ -use super::{HardlinkList, Reflection, iter::Item as IterItem, reflection::ReflectionEntry}; +use super::iter::Item as IterItem; +use super::reflection::ReflectionEntry; +use super::{HardlinkList, Reflection}; use crate::size; use derive_more::{Add, AddAssign, Sum}; use derive_setters::Setters; -use std::{ - cmp::Ordering, - fmt::{self, Display}, -}; +use std::cmp::Ordering; +use std::fmt::{self, Display}; #[cfg(feature = "json")] use serde::{Deserialize, Serialize}; diff --git a/src/hardlink/ignorant.rs b/src/hardlink/ignorant.rs index bf9acaeb..5a0800f4 100644 --- a/src/hardlink/ignorant.rs +++ b/src/hardlink/ignorant.rs @@ -1,5 +1,7 @@ use super::{DeduplicateSharedSize, RecordHardlinks, RecordHardlinksArgument}; -use crate::{data_tree::DataTree, os_string_display::OsStringDisplay, size}; +use crate::data_tree::DataTree; +use crate::os_string_display::OsStringDisplay; +use crate::size; use std::convert::Infallible; /// Be ignorant of hardlinks. Treat them as real files. diff --git a/src/hardlink/link_path_list/iter.rs b/src/hardlink/link_path_list/iter.rs index 60915bbd..6209cc3a 100644 --- a/src/hardlink/link_path_list/iter.rs +++ b/src/hardlink/link_path_list/iter.rs @@ -1,6 +1,8 @@ use super::LinkPathList; use pipe_trait::Pipe; -use std::{iter::FusedIterator, path::PathBuf, slice}; +use std::iter::FusedIterator; +use std::path::PathBuf; +use std::slice; /// [Iterator] over the paths inside a [`LinkPathList`]. #[derive(Debug, Clone)] diff --git a/src/hardlink/link_path_list/reflection.rs b/src/hardlink/link_path_list/reflection.rs index f9ac42ed..23c50b54 100644 --- a/src/hardlink/link_path_list/reflection.rs +++ b/src/hardlink/link_path_list/reflection.rs @@ -1,7 +1,8 @@ use super::LinkPathList; use derive_more::{From, Into, IntoIterator}; use pipe_trait::Pipe; -use std::{collections::HashSet, path::PathBuf}; +use std::collections::HashSet; +use std::path::PathBuf; #[cfg(feature = "json")] use serde::{Deserialize, Serialize}; diff --git a/src/hardlink/record.rs b/src/hardlink/record.rs index 074c7834..efcfad33 100644 --- a/src/hardlink/record.rs +++ b/src/hardlink/record.rs @@ -1,4 +1,5 @@ -use std::{fs::Metadata, path::Path}; +use std::fs::Metadata; +use std::path::Path; /// Argument to pass to [`RecordHardlinks::record_hardlinks`]. #[derive(Debug, Clone, Copy)] diff --git a/src/json_data.rs b/src/json_data.rs index eed2b094..3f0ec680 100644 --- a/src/json_data.rs +++ b/src/json_data.rs @@ -4,11 +4,9 @@ pub mod schema_version; pub use binary_version::BinaryVersion; pub use schema_version::SchemaVersion; -use crate::{ - data_tree::DataTreeReflection, - hardlink::{HardlinkListReflection, SharedLinkSummary}, - size::{self, Blocks, Bytes}, -}; +use crate::data_tree::DataTreeReflection; +use crate::hardlink::{HardlinkListReflection, SharedLinkSummary}; +use crate::size::{self, Blocks, Bytes}; use derive_more::{Deref, DerefMut, From, TryInto}; use smart_default::SmartDefault; diff --git a/src/man_page.rs b/src/man_page.rs index cb6ebdf1..e332d788 100644 --- a/src/man_page.rs +++ b/src/man_page.rs @@ -1,7 +1,8 @@ use crate::args::Args; use clap::{Arg, ArgAction, Command, CommandFactory}; use itertools::Itertools; -use std::{collections::BTreeMap, fmt::Write}; +use std::collections::BTreeMap; +use std::fmt::Write; /// A map from argument ID to the set of argument IDs it conflicts with (bidirectional). type ConflictMap = BTreeMap>; diff --git a/src/os_string_display.rs b/src/os_string_display.rs index e729db56..30950a14 100644 --- a/src/os_string_display.rs +++ b/src/os_string_display.rs @@ -1,8 +1,6 @@ use derive_more::{AsMut, AsRef, Deref, DerefMut, From, FromStr}; -use std::{ - ffi::{OsStr, OsString}, - fmt::{Debug, Display, Error, Formatter}, -}; +use std::ffi::{OsStr, OsString}; +use std::fmt::{Debug, Display, Error, Formatter}; #[cfg(feature = "json")] use serde::{Deserialize, Serialize}; diff --git a/src/reporter/error_report.rs b/src/reporter/error_report.rs index c3314cc3..ef6bd2b6 100644 --- a/src/reporter/error_report.rs +++ b/src/reporter/error_report.rs @@ -2,7 +2,8 @@ pub mod operation; pub use operation::Operation; -use std::{io::Error, path::Path}; +use std::io::Error; +use std::path::Path; /// Information regarding a filesystem error. #[derive(Debug)] diff --git a/src/reporter/error_report/text_report.rs b/src/reporter/error_report/text_report.rs index 75510e58..f2c1b5b5 100644 --- a/src/reporter/error_report/text_report.rs +++ b/src/reporter/error_report/text_report.rs @@ -29,7 +29,9 @@ impl<'a> Display for TextReport<'a> { #[cfg(test)] use super::Operation; #[cfg(test)] -use std::{io, path::PathBuf}; +use std::io; +#[cfg(test)] +use std::path::PathBuf; #[test] fn test() { diff --git a/src/reporter/event.rs b/src/reporter/event.rs index 8643ab81..ed3f7b13 100644 --- a/src/reporter/event.rs +++ b/src/reporter/event.rs @@ -1,6 +1,7 @@ use super::ErrorReport; use crate::size; -use std::{fs::Metadata, path::Path}; +use std::fs::Metadata; +use std::path::Path; /// Report trigger event. #[derive(Debug)] diff --git a/src/reporter/progress_and_error_reporter.rs b/src/reporter/progress_and_error_reporter.rs index 04e3daca..83f98127 100644 --- a/src/reporter/progress_and_error_reporter.rs +++ b/src/reporter/progress_and_error_reporter.rs @@ -1,14 +1,13 @@ use super::{ErrorReport, Event, ParallelReporter, ProgressReport, Reporter}; use crate::size; use progress_report_state::ProgressReportState; -use std::{ - any::Any, - marker::PhantomData, - ops::ControlFlow, - sync::{Arc, atomic::Ordering::Relaxed}, - thread::{JoinHandle, sleep, spawn}, - time::Duration, -}; +use std::any::Any; +use std::marker::PhantomData; +use std::ops::ControlFlow; +use std::sync::Arc; +use std::sync::atomic::Ordering::Relaxed; +use std::thread::{JoinHandle, sleep, spawn}; +use std::time::Duration; /// Store progress information and call report function on said information. /// diff --git a/src/reporter/progress_and_error_reporter/progress_report_state.rs b/src/reporter/progress_and_error_reporter/progress_report_state.rs index e832421d..4b840140 100644 --- a/src/reporter/progress_and_error_reporter/progress_report_state.rs +++ b/src/reporter/progress_and_error_reporter/progress_report_state.rs @@ -1,8 +1,8 @@ -use crate::{reporter::ProgressReport, size}; -use std::{ - ops::ControlFlow, - sync::atomic::{AtomicBool, AtomicU64, Ordering::Relaxed}, -}; +use crate::reporter::ProgressReport; +use crate::size; +use std::ops::ControlFlow; +use std::sync::atomic::Ordering::Relaxed; +use std::sync::atomic::{AtomicBool, AtomicU64}; /// Like [`ProgressReport`] but mutable. #[derive(Debug, Default)] diff --git a/src/reporter/progress_report.rs b/src/reporter/progress_report.rs index cbb875e5..db20dcbe 100644 --- a/src/reporter/progress_report.rs +++ b/src/reporter/progress_report.rs @@ -1,4 +1,5 @@ -use crate::{size, status_board::GLOBAL_STATUS_BOARD}; +use crate::size; +use crate::status_board::GLOBAL_STATUS_BOARD; use derive_setters::Setters; use std::fmt::Write; diff --git a/src/runtime_error.rs b/src/runtime_error.rs index 815c4be7..9f14b3ff 100644 --- a/src/runtime_error.rs +++ b/src/runtime_error.rs @@ -1,5 +1,6 @@ use derive_more::{Display, Error}; -use std::{convert::Infallible, process::ExitCode}; +use std::convert::Infallible; +use std::process::ExitCode; /// Error caused by the CLI program. #[derive(Debug, Display, Error)] diff --git a/src/size.rs b/src/size.rs index 34224b8c..bb0fb893 100644 --- a/src/size.rs +++ b/src/size.rs @@ -1,10 +1,8 @@ use super::bytes_format::{self, BytesFormat}; use derive_more::{Add, AddAssign, From, Into, Sub, SubAssign, Sum}; -use std::{ - fmt::{Debug, Display}, - iter::Sum, - ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign}, -}; +use std::fmt::{Debug, Display}; +use std::iter::Sum; +use std::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign}; #[cfg(feature = "json")] use serde::{Deserialize, Serialize}; diff --git a/src/tree_builder.rs b/src/tree_builder.rs index 5f82572b..d2111bf4 100644 --- a/src/tree_builder.rs +++ b/src/tree_builder.rs @@ -2,7 +2,8 @@ pub mod info; pub use info::Info; -use super::{data_tree::DataTree, size}; +use super::data_tree::DataTree; +use super::size; use rayon::prelude::*; /// Collection of functions and starting points in order to build a [`DataTree`] with [`From`] or [`Into`]. diff --git a/src/usage_md.rs b/src/usage_md.rs index 31d576d9..d718568d 100644 --- a/src/usage_md.rs +++ b/src/usage_md.rs @@ -1,5 +1,6 @@ use crate::args::Args; -use clap::{Arg, ArgAction, Command, CommandFactory, builder::PossibleValue}; +use clap::builder::PossibleValue; +use clap::{Arg, ArgAction, Command, CommandFactory}; use derive_more::{Display, Error}; use itertools::Itertools; use pipe_trait::Pipe; diff --git a/src/visualizer.rs b/src/visualizer.rs index 71effaaf..ccc9eb62 100644 --- a/src/visualizer.rs +++ b/src/visualizer.rs @@ -14,7 +14,8 @@ pub use parenthood::Parenthood; pub use proportion_bar::{ProportionBar, ProportionBarBlock}; pub use tree::{TreeHorizontalSlice, TreeSkeletalComponent}; -use super::{data_tree::DataTree, size}; +use super::data_tree::DataTree; +use super::size; use std::fmt::Display; /// Visualize a [`DataTree`]. diff --git a/src/visualizer/display.rs b/src/visualizer/display.rs index 1b3f5137..3d373d2e 100644 --- a/src/visualizer/display.rs +++ b/src/visualizer/display.rs @@ -1,4 +1,5 @@ -use super::{Direction::*, Visualizer}; +use super::Direction::*; +use super::Visualizer; use crate::size; use std::fmt::{Display, Error, Formatter}; diff --git a/src/visualizer/methods.rs b/src/visualizer/methods.rs index f4e99d62..725c369f 100644 --- a/src/visualizer/methods.rs +++ b/src/visualizer/methods.rs @@ -14,7 +14,8 @@ use tree_table::*; use super::{ColumnWidthDistribution, Visualizer}; use crate::size; -use std::{cmp::min, fmt::Display}; +use std::cmp::min; +use std::fmt::Display; use zero_copy_pads::{align_left, align_right}; impl<'a, Name, Size> Visualizer<'a, Name, Size> diff --git a/src/visualizer/methods/bar_table.rs b/src/visualizer/methods/bar_table.rs index 1adbe225..fdf28b95 100644 --- a/src/visualizer/methods/bar_table.rs +++ b/src/visualizer/methods/bar_table.rs @@ -1,8 +1,10 @@ use super::{NodeInfo, TreeRow, TreeTable}; -use crate::{size, visualizer::ProportionBar}; +use crate::size; +use crate::visualizer::ProportionBar; use assert_cmp::debug_assert_op; use derive_more::{Deref, DerefMut}; -use std::{collections::LinkedList, fmt::Display}; +use std::collections::LinkedList; +use std::fmt::Display; #[derive(Deref, DerefMut)] pub(super) struct BarRow { diff --git a/src/visualizer/methods/initial_table.rs b/src/visualizer/methods/initial_table.rs index 31580115..60970b05 100644 --- a/src/visualizer/methods/initial_table.rs +++ b/src/visualizer/methods/initial_table.rs @@ -1,8 +1,12 @@ use super::{BORDER_COLUMNS, NodeInfo, PERCENTAGE_COLUMN_MAX_WIDTH, Table}; -use crate::{data_tree::DataTree, size, visualizer::Visualizer}; +use crate::data_tree::DataTree; +use crate::size; +use crate::visualizer::Visualizer; use assert_cmp::debug_assert_op; use derive_more::{Deref, DerefMut}; -use std::{cmp::max, fmt::Display, num::NonZeroUsize}; +use std::cmp::max; +use std::fmt::Display; +use std::num::NonZeroUsize; #[derive(Deref, DerefMut)] pub(super) struct InitialRow { diff --git a/src/visualizer/methods/tree_table.rs b/src/visualizer/methods/tree_table.rs index 6419ee51..5fe9d192 100644 --- a/src/visualizer/methods/tree_table.rs +++ b/src/visualizer/methods/tree_table.rs @@ -1,19 +1,15 @@ use super::{InitialColumnWidth, InitialRow, InitialTable, Table}; -use crate::{ - size, - visualizer::{ - ChildPosition, Parenthood, TreeHorizontalSlice, TreeSkeletalComponent, Visualizer, - }, +use crate::size; +use crate::visualizer::{ + ChildPosition, Parenthood, TreeHorizontalSlice, TreeSkeletalComponent, Visualizer, }; use assert_cmp::{debug_assert_op, debug_assert_op_expr}; use derive_more::{Deref, DerefMut}; use pipe_trait::Pipe; -use std::{ - cmp::max, - collections::{HashSet, LinkedList}, - fmt::Display, - ops::{Index, IndexMut}, -}; +use std::cmp::max; +use std::collections::{HashSet, LinkedList}; +use std::fmt::Display; +use std::ops::{Index, IndexMut}; use zero_copy_pads::Width; #[derive(Deref, DerefMut)] diff --git a/template/ai-instructions/shared.md b/template/ai-instructions/shared.md index 051bf7bd..b5b320c6 100644 --- a/template/ai-instructions/shared.md +++ b/template/ai-instructions/shared.md @@ -7,7 +7,7 @@ Read and follow the CONTRIBUTING.md file in this repository for all code style c - Commit format: Conventional Commits. Pattern: `type(scope): lowercase description`. The scope is optional. - Version releases are the only exception. The commit message is just the version number, such as `0.21.1`. - Write documentation, comments, and other prose for ease of understanding first. Prefer a formal tone when it does not hurt clarity, and use complete sentences. Avoid mid-sentence breaks introduced by em dashes or long parenthetical clauses. Em dashes are a reliable symptom of loose phrasing; when one appears, restructure the surrounding sentence so each clause stands on its own rather than swapping the em dash for another punctuation mark. -- Prefer merged imports. +- Prefer imports merged per module. Combine items from the same module into a single `use` statement, but write a separate `use` statement for each module rather than collapsing every path from a crate into one nested-braces statement. - Use descriptive names for generics, such as `Size` and `Report`. Do not use single letters. - Use descriptive names for variables and closure parameters. Single letters are permitted only in these cases: (1) conventional names like `n` for count or `f` for formatter; (2) comparison closures like `|a, b|`; (3) trivial single-expression closures; (4) fold accumulators; (5) index variables `i`/`j`/`k` in short closures or index-based loops; and (6) test fixtures with identical roles. Single letters are never permitted in multi-line functions or closures. - Use `pipe-trait` to chain through unary functions such as constructors, `Some`, `Ok`, and free functions. Use it to flatten nested calls and to continue method chains. Do not use it for simple standalone calls; prefer `foo(value)` over `value.pipe(foo)`. diff --git a/tests/_utils.rs b/tests/_utils.rs index 1d56ad76..db7c21d5 100644 --- a/tests/_utils.rs +++ b/tests/_utils.rs @@ -2,28 +2,25 @@ use build_fs_tree::{Build, MergeableFileSystemTree, dir, file}; use command_extra::CommandExtra; use derive_more::{AsRef, Deref}; use into_sorted::IntoSorted; -use parallel_disk_usage::{ - data_tree::{DataTree, DataTreeReflection}, - device::DeviceBoundary, - fs_tree_builder::FsTreeBuilder, - get_size::{self, GetSize}, - hardlink::HardlinkIgnorant, - os_string_display::OsStringDisplay, - reporter::ErrorOnlyReporter, - size, -}; +use parallel_disk_usage::data_tree::{DataTree, DataTreeReflection}; +use parallel_disk_usage::device::DeviceBoundary; +use parallel_disk_usage::fs_tree_builder::FsTreeBuilder; +use parallel_disk_usage::get_size::{self, GetSize}; +use parallel_disk_usage::hardlink::HardlinkIgnorant; +use parallel_disk_usage::os_string_display::OsStringDisplay; +use parallel_disk_usage::reporter::ErrorOnlyReporter; +use parallel_disk_usage::size; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use rand::{RngExt, distr::Alphanumeric, rng}; +use rand::distr::Alphanumeric; +use rand::{RngExt, rng}; use rayon::prelude::*; -use std::{ - cmp::Ordering, - env::temp_dir, - fs::{create_dir, metadata, remove_dir_all, symlink_metadata}, - io::Error, - path::{Path, PathBuf}, - process::{Command, Output}, -}; +use std::cmp::Ordering; +use std::env::temp_dir; +use std::fs::{create_dir, metadata, remove_dir_all, symlink_metadata}; +use std::io::Error; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output}; /// Default size getter method. #[cfg(unix)] diff --git a/tests/args_fraction.rs b/tests/args_fraction.rs index b1878f50..326341d4 100644 --- a/tests/args_fraction.rs +++ b/tests/args_fraction.rs @@ -1,6 +1,8 @@ #![cfg(feature = "cli")] -use parallel_disk_usage::args::fraction::{ConversionError::*, Fraction, FromStrError::*}; +use parallel_disk_usage::args::fraction::ConversionError::*; +use parallel_disk_usage::args::fraction::Fraction; +use parallel_disk_usage::args::fraction::FromStrError::*; use pretty_assertions::assert_eq; #[test] diff --git a/tests/cli_errors.rs b/tests/cli_errors.rs index 0f9a7b3f..b5ca4b20 100644 --- a/tests/cli_errors.rs +++ b/tests/cli_errors.rs @@ -12,19 +12,29 @@ use text_block_macros::text_block; #[cfg(unix)] use maplit::btreeset; #[cfg(unix)] -use parallel_disk_usage::{ - bytes_format::BytesFormat, - data_tree::DataTree, - device::DeviceBoundary, - fs_tree_builder::FsTreeBuilder, - get_size::GetApparentSize, - hardlink::HardlinkIgnorant, - os_string_display::OsStringDisplay, - reporter::{ErrorOnlyReporter, ErrorReport}, - visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, +use parallel_disk_usage::bytes_format::BytesFormat; +#[cfg(unix)] +use parallel_disk_usage::data_tree::DataTree; +#[cfg(unix)] +use parallel_disk_usage::device::DeviceBoundary; +#[cfg(unix)] +use parallel_disk_usage::fs_tree_builder::FsTreeBuilder; +#[cfg(unix)] +use parallel_disk_usage::get_size::GetApparentSize; +#[cfg(unix)] +use parallel_disk_usage::hardlink::HardlinkIgnorant; +#[cfg(unix)] +use parallel_disk_usage::os_string_display::OsStringDisplay; +#[cfg(unix)] +use parallel_disk_usage::reporter::{ErrorOnlyReporter, ErrorReport}; +#[cfg(unix)] +use parallel_disk_usage::visualizer::{ + BarAlignment, ColumnWidthDistribution, Direction, Visualizer, }; #[cfg(unix)] -use std::{collections::BTreeSet, path::Path}; +use std::collections::BTreeSet; +#[cfg(unix)] +use std::path::Path; fn stdio(command: Command) -> Command { command diff --git a/tests/data_tree_reflection.rs b/tests/data_tree_reflection.rs index af723076..a279581f 100644 --- a/tests/data_tree_reflection.rs +++ b/tests/data_tree_reflection.rs @@ -1,7 +1,6 @@ -use parallel_disk_usage::{ - data_tree::{DataTree, Reflection, reflection::ConversionError}, - size::Bytes, -}; +use parallel_disk_usage::data_tree::reflection::ConversionError; +use parallel_disk_usage::data_tree::{DataTree, Reflection}; +use parallel_disk_usage::size::Bytes; use pretty_assertions::assert_eq; use std::mem::transmute; diff --git a/tests/fs_tree_builder.rs b/tests/fs_tree_builder.rs index 52789662..3401b328 100644 --- a/tests/fs_tree_builder.rs +++ b/tests/fs_tree_builder.rs @@ -1,13 +1,13 @@ pub mod _utils; pub use _utils::*; -use parallel_disk_usage::{get_size::GetApparentSize, size::Bytes}; +use parallel_disk_usage::get_size::GetApparentSize; +use parallel_disk_usage::size::Bytes; #[cfg(unix)] -use parallel_disk_usage::{ - get_size::{GetBlockCount, GetBlockSize}, - size::Blocks, -}; +use parallel_disk_usage::get_size::{GetBlockCount, GetBlockSize}; +#[cfg(unix)] +use parallel_disk_usage::size::Blocks; #[test] fn len_as_bytes() { diff --git a/tests/hardlinks_deduplication.rs b/tests/hardlinks_deduplication.rs index d4f9b139..201789e7 100644 --- a/tests/hardlinks_deduplication.rs +++ b/tests/hardlinks_deduplication.rs @@ -8,27 +8,22 @@ use command_extra::CommandExtra; use into_sorted::IntoSorted; use itertools::Itertools; use normalize_path::NormalizePath; -use parallel_disk_usage::{ - bytes_format::BytesFormat, - data_tree::Reflection, - hardlink::{ - LinkPathListReflection, - hardlink_list::{Summary, reflection::ReflectionEntry}, - }, - inode::InodeNumber, - json_data::{JsonData, JsonTree}, - size::Bytes, -}; +use parallel_disk_usage::bytes_format::BytesFormat; +use parallel_disk_usage::data_tree::Reflection; +use parallel_disk_usage::hardlink::LinkPathListReflection; +use parallel_disk_usage::hardlink::hardlink_list::Summary; +use parallel_disk_usage::hardlink::hardlink_list::reflection::ReflectionEntry; +use parallel_disk_usage::inode::InodeNumber; +use parallel_disk_usage::json_data::{JsonData, JsonTree}; +use parallel_disk_usage::size::Bytes; use pipe_trait::Pipe; use pretty_assertions::assert_eq; use rayon::prelude::*; -use std::{ - collections::HashSet, - iter, - ops::Add, - path::PathBuf, - process::{Command, Stdio}, -}; +use std::collections::HashSet; +use std::iter; +use std::ops::Add; +use std::path::PathBuf; +use std::process::{Command, Stdio}; fn stdio(command: Command) -> Command { command diff --git a/tests/hardlinks_deduplication_multi_args.rs b/tests/hardlinks_deduplication_multi_args.rs index e398b91d..4ce72cdb 100644 --- a/tests/hardlinks_deduplication_multi_args.rs +++ b/tests/hardlinks_deduplication_multi_args.rs @@ -7,24 +7,19 @@ pub use _utils::*; use command_extra::CommandExtra; use into_sorted::IntoSorted; use itertools::Itertools; -use parallel_disk_usage::{ - bytes_format::BytesFormat, - data_tree::Reflection, - hardlink::{ - LinkPathListReflection, - hardlink_list::{Summary, reflection::ReflectionEntry}, - }, - inode::InodeNumber, - json_data::{JsonData, JsonTree}, - size::Bytes, -}; +use parallel_disk_usage::bytes_format::BytesFormat; +use parallel_disk_usage::data_tree::Reflection; +use parallel_disk_usage::hardlink::LinkPathListReflection; +use parallel_disk_usage::hardlink::hardlink_list::Summary; +use parallel_disk_usage::hardlink::hardlink_list::reflection::ReflectionEntry; +use parallel_disk_usage::inode::InodeNumber; +use parallel_disk_usage::json_data::{JsonData, JsonTree}; +use parallel_disk_usage::size::Bytes; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use std::{ - collections::HashSet, - path::PathBuf, - process::{Command, Stdio}, -}; +use std::collections::HashSet; +use std::path::PathBuf; +use std::process::{Command, Stdio}; fn stdio(command: Command) -> Command { command diff --git a/tests/hardlinks_without_deduplication.rs b/tests/hardlinks_without_deduplication.rs index 27cfc2ce..9705caae 100644 --- a/tests/hardlinks_without_deduplication.rs +++ b/tests/hardlinks_without_deduplication.rs @@ -5,17 +5,13 @@ pub mod _utils; pub use _utils::*; use command_extra::CommandExtra; -use parallel_disk_usage::{ - data_tree::Reflection, - json_data::{JsonData, JsonTree}, - size::Bytes, -}; +use parallel_disk_usage::data_tree::Reflection; +use parallel_disk_usage::json_data::{JsonData, JsonTree}; +use parallel_disk_usage::size::Bytes; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use std::{ - ops::{Add, Mul}, - process::{Command, Stdio}, -}; +use std::ops::{Add, Mul}; +use std::process::{Command, Stdio}; fn stdio(command: Command) -> Command { command diff --git a/tests/json.rs b/tests/json.rs index 7bc40622..93b199d4 100644 --- a/tests/json.rs +++ b/tests/json.rs @@ -6,25 +6,23 @@ pub use _utils::*; use assert_cmp::assert_op_expr; use command_extra::CommandExtra; -use parallel_disk_usage::{ - bytes_format::BytesFormat, - data_tree::DataTree, - device::DeviceBoundary, - fs_tree_builder::FsTreeBuilder, - get_size::GetApparentSize, - hardlink::HardlinkIgnorant, - json_data::{JsonData, JsonTree, SchemaVersion}, - reporter::{ErrorOnlyReporter, ErrorReport}, - size::Bytes, - visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, +use parallel_disk_usage::bytes_format::BytesFormat; +use parallel_disk_usage::data_tree::DataTree; +use parallel_disk_usage::device::DeviceBoundary; +use parallel_disk_usage::fs_tree_builder::FsTreeBuilder; +use parallel_disk_usage::get_size::GetApparentSize; +use parallel_disk_usage::hardlink::HardlinkIgnorant; +use parallel_disk_usage::json_data::{JsonData, JsonTree, SchemaVersion}; +use parallel_disk_usage::reporter::{ErrorOnlyReporter, ErrorReport}; +use parallel_disk_usage::size::Bytes; +use parallel_disk_usage::visualizer::{ + BarAlignment, ColumnWidthDistribution, Direction, Visualizer, }; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use std::{ - convert::TryInto, - io::Write, - process::{Command, Stdio}, -}; +use std::convert::TryInto; +use std::io::Write; +use std::process::{Command, Stdio}; type SampleName = String; type SampleSize = Bytes; diff --git a/tests/one_file_system.rs b/tests/one_file_system.rs index fe764a6f..62d19633 100644 --- a/tests/one_file_system.rs +++ b/tests/one_file_system.rs @@ -21,27 +21,25 @@ pub mod _utils; pub use _utils::*; use command_extra::CommandExtra; -use parallel_disk_usage::{ - bytes_format::BytesFormat, - data_tree::DataTree, - device::DeviceBoundary, - fs_tree_builder::FsTreeBuilder, - get_size::GetApparentSize, - hardlink::HardlinkIgnorant, - os_string_display::OsStringDisplay, - reporter::{ErrorOnlyReporter, ErrorReport}, - size::Bytes, - visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, +use parallel_disk_usage::bytes_format::BytesFormat; +use parallel_disk_usage::data_tree::DataTree; +use parallel_disk_usage::device::DeviceBoundary; +use parallel_disk_usage::fs_tree_builder::FsTreeBuilder; +use parallel_disk_usage::get_size::GetApparentSize; +use parallel_disk_usage::hardlink::HardlinkIgnorant; +use parallel_disk_usage::os_string_display::OsStringDisplay; +use parallel_disk_usage::reporter::{ErrorOnlyReporter, ErrorReport}; +use parallel_disk_usage::size::Bytes; +use parallel_disk_usage::visualizer::{ + BarAlignment, ColumnWidthDistribution, Direction, Visualizer, }; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use std::{ - fs::{create_dir_all, write as write_file}, - path::Path, - process::{Command, Stdio}, - thread::sleep, - time::Duration, -}; +use std::fs::{create_dir_all, write as write_file}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::thread::sleep; +use std::time::Duration; use which::which; /// When all files reside on a single filesystem, [`DeviceBoundary::Stay`] should produce diff --git a/tests/os_string_display.rs b/tests/os_string_display.rs index 2aa509e4..0971ddde 100644 --- a/tests/os_string_display.rs +++ b/tests/os_string_display.rs @@ -2,7 +2,9 @@ use parallel_disk_usage::os_string_display::OsStringDisplay; use pipe_trait::Pipe; use pretty_assertions::assert_eq; -use std::{ffi::OsString, os::unix::ffi::OsStringExt, path::PathBuf}; +use std::ffi::OsString; +use std::os::unix::ffi::OsStringExt; +use std::path::PathBuf; #[test] fn utf8_os_str() { diff --git a/tests/tree_builder.rs b/tests/tree_builder.rs index 3d0aabdd..2e9e9ca4 100644 --- a/tests/tree_builder.rs +++ b/tests/tree_builder.rs @@ -1,10 +1,8 @@ use build_fs_tree::{FileSystemTree, dir, file}; use derive_more::From; -use parallel_disk_usage::{ - data_tree::{DataTree, DataTreeReflection}, - size::Bytes, - tree_builder::{Info, TreeBuilder}, -}; +use parallel_disk_usage::data_tree::{DataTree, DataTreeReflection}; +use parallel_disk_usage::size::Bytes; +use parallel_disk_usage::tree_builder::{Info, TreeBuilder}; use pipe_trait::Pipe; use pretty_assertions::assert_eq; diff --git a/tests/usual_cli.rs b/tests/usual_cli.rs index b91b9841..57cd4c79 100644 --- a/tests/usual_cli.rs +++ b/tests/usual_cli.rs @@ -4,16 +4,16 @@ pub mod _utils; pub use _utils::*; use command_extra::CommandExtra; -use parallel_disk_usage::{ - bytes_format::BytesFormat, - data_tree::DataTree, - device::DeviceBoundary, - fs_tree_builder::FsTreeBuilder, - get_size::GetApparentSize, - hardlink::HardlinkIgnorant, - os_string_display::OsStringDisplay, - reporter::{ErrorOnlyReporter, ErrorReport}, - visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, +use parallel_disk_usage::bytes_format::BytesFormat; +use parallel_disk_usage::data_tree::DataTree; +use parallel_disk_usage::device::DeviceBoundary; +use parallel_disk_usage::fs_tree_builder::FsTreeBuilder; +use parallel_disk_usage::get_size::GetApparentSize; +use parallel_disk_usage::hardlink::HardlinkIgnorant; +use parallel_disk_usage::os_string_display::OsStringDisplay; +use parallel_disk_usage::reporter::{ErrorOnlyReporter, ErrorReport}; +use parallel_disk_usage::visualizer::{ + BarAlignment, ColumnWidthDistribution, Direction, Visualizer, }; use pipe_trait::Pipe; use pretty_assertions::assert_eq; diff --git a/tests/visualizer.rs b/tests/visualizer.rs index 8c839f26..4cb10660 100644 --- a/tests/visualizer.rs +++ b/tests/visualizer.rs @@ -1,8 +1,8 @@ -use parallel_disk_usage::{ - bytes_format::BytesFormat::*, - data_tree::DataTree, - size::{self, Blocks, Bytes}, - visualizer::{BarAlignment, ColumnWidthDistribution, Direction, Visualizer}, +use parallel_disk_usage::bytes_format::BytesFormat::*; +use parallel_disk_usage::data_tree::DataTree; +use parallel_disk_usage::size::{self, Blocks, Bytes}; +use parallel_disk_usage::visualizer::{ + BarAlignment, ColumnWidthDistribution, Direction, Visualizer, }; use pretty_assertions::assert_eq; use std::cmp::Ordering;