Skip to content

Commit d57b4a6

Browse files
lookbusy1344claude
andcommitted
Fix all compiler warnings and clippy issues
- Remove unused re-exports from module files - Change worker_func to take ConfigSettings by reference - Collapse nested if-else blocks in files.rs - Make parse functions public for unit tests - Add #[cfg(test)] attribute to unit_tests module - Remove unused PathBuf import from integration tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 916f05e commit d57b4a6

File tree

15 files changed

+31
-38
lines changed

15 files changed

+31
-38
lines changed

src/cli/args.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use anyhow::{Result, anyhow};
55
use pico_args::Arguments;
66

77
use crate::cli::config::{ConfigSettings, HELP};
8-
use crate::core::types::{HashAlgorithm, OutputEncoding, DEFAULT_HASH, VERSION, GIT_VERSION_SHORT};
8+
use crate::core::types::{DEFAULT_HASH, GIT_VERSION_SHORT, HashAlgorithm, OutputEncoding, VERSION};
99

1010
pub fn process_command_line(mut pargs: Arguments) -> Result<ConfigSettings> {
1111
let algo_str: Option<String> = pargs.opt_value_from_str(["-a", "--algorithm"])?;
@@ -54,14 +54,14 @@ pub fn process_command_line(mut pargs: Arguments) -> Result<ConfigSettings> {
5454
Ok(config)
5555
}
5656

57-
fn parse_hash_algorithm(algorithm: Option<&str>) -> Result<HashAlgorithm, strum::ParseError> {
57+
pub fn parse_hash_algorithm(algorithm: Option<&str>) -> Result<HashAlgorithm, strum::ParseError> {
5858
match algorithm {
5959
Some(algo_str) if !algo_str.is_empty() => HashAlgorithm::from_str(algo_str),
6060
_ => Ok(DEFAULT_HASH),
6161
}
6262
}
6363

64-
fn parse_hash_encoding(encoding: Option<&str>) -> Result<OutputEncoding, strum::ParseError> {
64+
pub fn parse_hash_encoding(encoding: Option<&str>) -> Result<OutputEncoding, strum::ParseError> {
6565
match encoding {
6666
Some(enc_str) if !enc_str.is_empty() => OutputEncoding::from_str(enc_str),
6767
_ => Ok(OutputEncoding::Unspecified),
@@ -90,4 +90,4 @@ fn args_finished(args: Arguments) -> Result<Vec<OsString>> {
9090
}
9191

9292
Ok(unused)
93-
}
93+
}

src/cli/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ OPTIONS:
6464
Algorithm can be:
6565
CRC32, MD5, SHA1, WHIRLPOOL, BLAKE2S-256, BLAKE2B-512,
6666
SHA2 / SHA2-256 / SHA-256, SHA2-224, SHA2-384, SHA2-512,
67-
SHA3 / SHA3-256 (default), SHA3-384, SHA3-512";
67+
SHA3 / SHA3-256 (default), SHA3-384, SHA3-512";

src/cli/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ pub mod args;
22
pub mod config;
33

44
pub use args::{process_command_line, show_help};
5-
pub use config::{ConfigSettings, HELP};

src/core/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub mod types;
22
pub mod worker;
33

4-
pub use types::{BasicHash, HashAlgorithm, OutputEncoding, DEFAULT_HASH, VERSION, GIT_VERSION_SHORT};
5-
pub use worker::worker_func;
4+
pub use worker::worker_func;

src/core/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ impl fmt::Display for BasicHash {
6161
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6262
write!(f, "{}", self.0)
6363
}
64-
}
64+
}

src/core/worker.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use crate::hash::algorithms::call_hasher;
1010
use crate::io::files::get_required_filenames;
1111
use crate::progress::ProgressManager;
1212

13-
pub fn worker_func(config: ConfigSettings) -> Result<()> {
13+
pub fn worker_func(config: &ConfigSettings) -> Result<()> {
1414
if config.debug_mode {
15-
show_initial_info(&config);
15+
show_initial_info(config);
1616
}
1717

18-
let paths = get_required_filenames(&config)?;
18+
let paths = get_required_filenames(config)?;
1919

2020
if paths.is_empty() {
2121
if config.debug_mode {
@@ -29,9 +29,9 @@ pub fn worker_func(config: ConfigSettings) -> Result<()> {
2929
}
3030

3131
if config.single_thread || paths.len() == 1 {
32-
file_hashes_st(&config, &paths);
32+
file_hashes_st(config, &paths);
3333
} else {
34-
file_hashes_mt(&config, &paths);
34+
file_hashes_mt(config, &paths);
3535
}
3636

3737
Ok(())
@@ -145,4 +145,4 @@ where
145145
}
146146

147147
result
148-
}
148+
}

src/hash/algorithms.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use sha3::{Sha3_256, Sha3_384, Sha3_512};
77
use whirlpool::Whirlpool;
88

99
use crate::core::types::{BasicHash, HashAlgorithm, OutputEncoding};
10-
use crate::hash::digest_impl::hash_file_encoded;
1110
use crate::hash::crc32::Crc32;
11+
use crate::hash::digest_impl::hash_file_encoded;
1212

1313
pub fn call_hasher(
1414
algo: HashAlgorithm,
@@ -38,4 +38,4 @@ pub fn call_hasher(
3838
HashAlgorithm::Blake2S256 => hash_file_encoded::<Blake2s256>(path, encoding),
3939
HashAlgorithm::Blake2B512 => hash_file_encoded::<Blake2b512>(path, encoding),
4040
}
41-
}
41+
}

src/hash/crc32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ impl Write for Crc32 {
6161
fn flush(&mut self) -> std::io::Result<()> {
6262
Ok(())
6363
}
64-
}
64+
}

src/hash/digest_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ fn file_size(path: impl AsRef<str>) -> anyhow::Result<u64> {
7676
fn build_heap_buffer<T: Default + Copy>(len: usize) -> Box<[T]> {
7777
let vec = vec![T::default(); len];
7878
vec.into_boxed_slice()
79-
}
79+
}

src/hash/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
pub mod algorithms;
22
pub mod crc32;
33
pub mod digest_impl;
4-
5-
pub use algorithms::call_hasher;
6-
pub use digest_impl::hash_file_encoded;

0 commit comments

Comments
 (0)