Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Apr 12, 2024
1 parent 66a53f5 commit cc99495
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lychee-bin/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,25 +275,25 @@ async fn handle(
// - Skip caching excluded links; they might not be excluded in the next run.
// - Skip caching links for which the status code has been explicitly excluded from the cache.
let status = response.status();
if ignore_cache(&uri, status, cache_exclude_status) {
if ignore_cache(&uri, status, &cache_exclude_status) {
return response;
}

cache.insert(uri, status.into());
response
}

fn ignore_cache(uri: &Uri, status: &Status, cache_exclude_status: HashSet<u16>) -> bool {
fn ignore_cache(uri: &Uri, status: &Status, cache_exclude_status: &HashSet<u16>) -> bool {
let status_code = match status.code() {
None => 0,
Some(code) => code.as_u16(),
};

return uri.is_file()
uri.is_file()
|| status.is_excluded()
|| status.is_unsupported()
|| status.is_unknown()
|| cache_exclude_status.contains(&status_code);
|| cache_exclude_status.contains(&status_code)
}

fn show_progress(
Expand Down Expand Up @@ -404,7 +404,7 @@ mod tests {
ignore_cache(
&Uri::try_from("https://[::1]").unwrap(),
&Status::Ok(StatusCode::OK),
exclude.clone()
&exclude
)
);

Expand All @@ -414,7 +414,7 @@ mod tests {
ignore_cache(
&Uri::try_from("file:///home").unwrap(),
&Status::Ok(StatusCode::OK),
exclude.clone()
&exclude
)
);

Expand All @@ -424,7 +424,7 @@ mod tests {
ignore_cache(
&Uri::try_from("https://[::1]").unwrap(),
&Status::Unsupported(ErrorKind::EmptyUrl),
exclude.clone()
&exclude
)
);

Expand All @@ -434,7 +434,7 @@ mod tests {
ignore_cache(
&Uri::try_from("https://[::1]").unwrap(),
&Status::UnknownStatusCode(StatusCode::IM_A_TEAPOT),
exclude.clone()
&exclude
)
);

Expand All @@ -445,7 +445,7 @@ mod tests {
ignore_cache(
&Uri::try_from("https://[::1]").unwrap(),
&Status::Ok(StatusCode::OK),
exclude.clone()
&exclude
)
);
}
Expand Down

0 comments on commit cc99495

Please sign in to comment.