Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`.
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`.
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`.
Expand Down
13 changes: 6 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
12 changes: 5 additions & 7 deletions cli/ai_instructions.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
4 changes: 1 addition & 3 deletions dylint.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
24 changes: 11 additions & 13 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
10 changes: 4 additions & 6 deletions src/app/hdd.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
8 changes: 3 additions & 5 deletions src/app/hdd/test.rs
Original file line number Diff line number Diff line change
@@ -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`].
Expand Down
6 changes: 2 additions & 4 deletions src/app/hdd/test_linux.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/app/mount_point.rs
Original file line number Diff line number Diff line change
@@ -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>(
Expand Down
12 changes: 5 additions & 7 deletions src/app/overlapping_arguments.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
32 changes: 17 additions & 15 deletions src/app/sub.rs
Original file line number Diff line number Diff line change
@@ -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<Size, SizeGetter, HardlinksHandler, Report>
Expand Down
10 changes: 6 additions & 4 deletions src/app/sub/unix_ext.rs
Original file line number Diff line number Diff line change
@@ -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<Size> HardlinkSubroutines<Size> for HardlinkAware<Size>
Expand Down
3 changes: 2 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/args/depth.rs
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
8 changes: 3 additions & 5 deletions src/args/fraction.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
6 changes: 2 additions & 4 deletions src/args/threads.rs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
3 changes: 2 additions & 1 deletion src/data_tree/hardlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Name, Size> DataTree<Name, Size>
where
Expand Down
10 changes: 4 additions & 6 deletions src/data_tree/reflection.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
3 changes: 2 additions & 1 deletion src/data_tree/reflection/convert.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::Reflection;
use crate::{data_tree::DataTree, size};
use crate::data_tree::DataTree;
use crate::size;

impl<Name, Size: size::Size> From<DataTree<Name, Size>> for Reflection<Name, Size> {
fn from(source: DataTree<Name, Size>) -> Self {
Expand Down
6 changes: 4 additions & 2 deletions src/data_tree/reflection/par_methods.rs
Original file line number Diff line number Diff line change
@@ -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<Name, Size> Reflection<Name, Size>
where
Expand Down
6 changes: 4 additions & 2 deletions src/data_tree/retain/test.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
25 changes: 11 additions & 14 deletions src/fs_tree_builder.rs
Original file line number Diff line number Diff line change
@@ -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`].
///
Expand Down
Loading
Loading