Browse Source

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>
pull/1202/head
Spenser Black 2 years ago committed by GitHub
parent
commit
d6bc16be36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/cli.rs
  2. 16
      src/info/git/mod.rs

10
src/cli.rs

@ -385,7 +385,7 @@ mod test { @@ -385,7 +385,7 @@ mod test {
assert_eq!(
config,
CliOptions::parse_from(&[
CliOptions::parse_from([
"onefetch",
"/tmp/folder",
"--number-of-authors",
@ -406,22 +406,22 @@ mod test { @@ -406,22 +406,22 @@ mod test {
#[test]
fn test_config_with_image_protocol_but_no_image() {
assert!(CliOptions::try_parse_from(&["onefetch", "--image-protocol", "sixel"]).is_err())
assert!(CliOptions::try_parse_from(["onefetch", "--image-protocol", "sixel"]).is_err())
}
#[test]
fn test_config_with_color_resolution_but_no_image() {
assert!(CliOptions::try_parse_from(&["onefetch", "--color-resolution", "32"]).is_err())
assert!(CliOptions::try_parse_from(["onefetch", "--color-resolution", "32"]).is_err())
}
#[test]
fn test_config_with_ascii_colors_but_out_of_bounds() {
assert!(CliOptions::try_parse_from(&["onefetch", "--ascii-colors", "17"]).is_err())
assert!(CliOptions::try_parse_from(["onefetch", "--ascii-colors", "17"]).is_err())
}
#[test]
fn test_config_with_text_colors_but_out_of_bounds() {
assert!(CliOptions::try_parse_from(&["onefetch", "--text-colors", "17"]).is_err())
assert!(CliOptions::try_parse_from(["onefetch", "--text-colors", "17"]).is_err())
}
}

16
src/info/git/mod.rs

@ -117,13 +117,15 @@ pub fn traverse_commit_graph(repo: &gix::Repository, options: &CliOptions) -> Re @@ -117,13 +117,15 @@ pub fn traverse_commit_graph(repo: &gix::Repository, options: &CliOptions) -> Re
Ok(git_metrics)
}
type NumberOfCommitsBySignature = HashMap<Sig, usize>;
fn get_author_channel(
repo: &gix::Repository,
num_threads: usize,
bot_regex_pattern: &Option<MyRegex>,
mailmap: &gix::mailmap::Snapshot,
) -> (
Vec<JoinHandle<Result<HashMap<Sig, usize>>>>,
Vec<JoinHandle<Result<NumberOfCommitsBySignature>>>,
crossbeam_channel::Sender<ObjectId>,
) {
// 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( @@ -140,7 +142,7 @@ fn get_author_channel(
let bot_regex_pattern = bot_regex_pattern.clone();
let rx = rx.clone();
move || -> anyhow::Result<_> {
let mut number_of_commits_by_signature: HashMap<Sig, usize> = HashMap::new();
let mut number_of_commits_by_signature = NumberOfCommitsBySignature::new();
// We are sure to see each object only once.
repo.object_cache_size(0);
while let Ok(commit_id) = rx.recv() {
@ -160,22 +162,22 @@ fn get_author_channel( @@ -160,22 +162,22 @@ fn get_author_channel(
(threads, tx)
}
type NumberOfCommitsByFilepath = HashMap<BString, usize>;
type ChurnPair = (NumberOfCommitsByFilepath, usize);
fn get_churn_channel(
repo: &gix::Repository,
has_commit_graph_traversal_ended: &Arc<AtomicBool>,
total_number_of_commits: &Arc<AtomicUsize>,
churn_pool_size_opt: Option<usize>,
) -> Result<(
JoinHandle<Result<(HashMap<BString, usize>, usize)>>,
Sender<ObjectId>,
)> {
) -> Result<(JoinHandle<Result<ChurnPair>>, Sender<ObjectId>)> {
let (tx, rx) = channel::<gix::hash::ObjectId>();
let thread = std::thread::spawn({
let repo = repo.clone();
let has_commit_graph_traversal_ended = has_commit_graph_traversal_ended.clone();
let total_number_of_commits = total_number_of_commits.clone();
move || -> Result<_> {
let mut number_of_commits_by_file_path: HashMap<BString, usize> = HashMap::new();
let mut number_of_commits_by_file_path = NumberOfCommitsByFilepath::new();
let mut number_of_diffs_computed = 0;
while let Ok(commit_id) = rx.recv() {
let commit = repo.find_object(commit_id)?.into_commit();

Loading…
Cancel
Save