Skip to content

Commit d6bc16b

Browse files
spenserblacko2sh
andauthored
Resolve clippy warnings (#1201)
* Remove unnecessary references * Simplify return types with aliases Co-authored-by: Ossama Hjaji <ossama-hjaji@live.fr> --------- Co-authored-by: Ossama Hjaji <ossama-hjaji@live.fr>
1 parent 6995172 commit d6bc16b

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/cli.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ mod test {
385385

386386
assert_eq!(
387387
config,
388-
CliOptions::parse_from(&[
388+
CliOptions::parse_from([
389389
"onefetch",
390390
"/tmp/folder",
391391
"--number-of-authors",
@@ -406,22 +406,22 @@ mod test {
406406

407407
#[test]
408408
fn test_config_with_image_protocol_but_no_image() {
409-
assert!(CliOptions::try_parse_from(&["onefetch", "--image-protocol", "sixel"]).is_err())
409+
assert!(CliOptions::try_parse_from(["onefetch", "--image-protocol", "sixel"]).is_err())
410410
}
411411

412412
#[test]
413413
fn test_config_with_color_resolution_but_no_image() {
414-
assert!(CliOptions::try_parse_from(&["onefetch", "--color-resolution", "32"]).is_err())
414+
assert!(CliOptions::try_parse_from(["onefetch", "--color-resolution", "32"]).is_err())
415415
}
416416

417417
#[test]
418418
fn test_config_with_ascii_colors_but_out_of_bounds() {
419-
assert!(CliOptions::try_parse_from(&["onefetch", "--ascii-colors", "17"]).is_err())
419+
assert!(CliOptions::try_parse_from(["onefetch", "--ascii-colors", "17"]).is_err())
420420
}
421421

422422
#[test]
423423
fn test_config_with_text_colors_but_out_of_bounds() {
424-
assert!(CliOptions::try_parse_from(&["onefetch", "--text-colors", "17"]).is_err())
424+
assert!(CliOptions::try_parse_from(["onefetch", "--text-colors", "17"]).is_err())
425425
}
426426
}
427427

src/info/git/mod.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,15 @@ pub fn traverse_commit_graph(repo: &gix::Repository, options: &CliOptions) -> Re
117117
Ok(git_metrics)
118118
}
119119

120+
type NumberOfCommitsBySignature = HashMap<Sig, usize>;
121+
120122
fn get_author_channel(
121123
repo: &gix::Repository,
122124
num_threads: usize,
123125
bot_regex_pattern: &Option<MyRegex>,
124126
mailmap: &gix::mailmap::Snapshot,
125127
) -> (
126-
Vec<JoinHandle<Result<HashMap<Sig, usize>>>>,
128+
Vec<JoinHandle<Result<NumberOfCommitsBySignature>>>,
127129
crossbeam_channel::Sender<ObjectId>,
128130
) {
129131
// we intentionally over-allocate threads a little as the main thread won't be very busy anyway
@@ -140,7 +142,7 @@ fn get_author_channel(
140142
let bot_regex_pattern = bot_regex_pattern.clone();
141143
let rx = rx.clone();
142144
move || -> anyhow::Result<_> {
143-
let mut number_of_commits_by_signature: HashMap<Sig, usize> = HashMap::new();
145+
let mut number_of_commits_by_signature = NumberOfCommitsBySignature::new();
144146
// We are sure to see each object only once.
145147
repo.object_cache_size(0);
146148
while let Ok(commit_id) = rx.recv() {
@@ -160,22 +162,22 @@ fn get_author_channel(
160162
(threads, tx)
161163
}
162164

165+
type NumberOfCommitsByFilepath = HashMap<BString, usize>;
166+
type ChurnPair = (NumberOfCommitsByFilepath, usize);
167+
163168
fn get_churn_channel(
164169
repo: &gix::Repository,
165170
has_commit_graph_traversal_ended: &Arc<AtomicBool>,
166171
total_number_of_commits: &Arc<AtomicUsize>,
167172
churn_pool_size_opt: Option<usize>,
168-
) -> Result<(
169-
JoinHandle<Result<(HashMap<BString, usize>, usize)>>,
170-
Sender<ObjectId>,
171-
)> {
173+
) -> Result<(JoinHandle<Result<ChurnPair>>, Sender<ObjectId>)> {
172174
let (tx, rx) = channel::<gix::hash::ObjectId>();
173175
let thread = std::thread::spawn({
174176
let repo = repo.clone();
175177
let has_commit_graph_traversal_ended = has_commit_graph_traversal_ended.clone();
176178
let total_number_of_commits = total_number_of_commits.clone();
177179
move || -> Result<_> {
178-
let mut number_of_commits_by_file_path: HashMap<BString, usize> = HashMap::new();
180+
let mut number_of_commits_by_file_path = NumberOfCommitsByFilepath::new();
179181
let mut number_of_diffs_computed = 0;
180182
while let Ok(commit_id) = rx.recv() {
181183
let commit = repo.find_object(commit_id)?.into_commit();

0 commit comments

Comments
 (0)