Fix new clippy lints (#1625)

This commit is contained in:
Matthias Endler 2025-02-06 14:51:44 +01:00 committed by GitHub
parent 3fb94e064c
commit 971ee67bc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 9 additions and 10 deletions

View file

@ -320,7 +320,7 @@ async fn handle(
fn ignore_cache(uri: &Uri, status: &Status, cache_exclude_status: &HashSet<u16>) -> bool {
let status_code_excluded = status
.code()
.map_or(false, |code| cache_exclude_status.contains(&code.as_u16()));
.is_some_and(|code| cache_exclude_status.contains(&code.as_u16()));
uri.is_file()
|| status.is_excluded()

View file

@ -294,7 +294,7 @@ async fn run(opts: &LycheeOptions) -> Result<i32> {
.skip_ignored(!opts.config.no_ignore)
.include_verbatim(opts.config.include_verbatim)
// File a bug if you rely on this envvar! It's going to go away eventually.
.use_html5ever(std::env::var("LYCHEE_USE_HTML5EVER").map_or(false, |x| x == "1"));
.use_html5ever(std::env::var("LYCHEE_USE_HTML5EVER").is_ok_and(|x| x == "1"));
if opts.config.dump_inputs {
let sources = collector.collect_sources(inputs);

View file

@ -1604,6 +1604,8 @@ mod cli {
#[test]
#[ignore = "Skipping test because it is flaky"]
fn test_suggests_url_alternatives() -> Result<()> {
let re = Regex::new(r"http://web\.archive\.org/web/.*google\.com/jobs\.html").unwrap();
for _ in 0..3 {
// This can be flaky. Try up to 3 times
let mut cmd = main_command();
@ -1619,7 +1621,6 @@ mod cli {
// We're looking for a suggestion that
// - starts with http://web.archive.org/web/
// - ends with google.com/jobs.html
let re = Regex::new(r"http://web\.archive\.org/web/.*google\.com/jobs\.html").unwrap();
if re.is_match(&String::from_utf8_lossy(&output.stdout)) {
// Test passed
return Ok(());

View file

@ -169,7 +169,7 @@ impl LinkExtractor {
return;
}
if self.current_attributes.get("rel").map_or(false, |rel| {
if self.current_attributes.get("rel").is_some_and(|rel| {
rel.split(',').any(|r| {
r.trim() == "nofollow" || r.trim() == "preconnect" || r.trim() == "dns-prefetch"
})
@ -189,7 +189,7 @@ impl LinkExtractor {
if self
.current_attributes
.get("rel")
.map_or(false, |rel| rel.contains("stylesheet"))
.is_some_and(|rel| rel.contains("stylesheet"))
{
if let Some(href) = self.current_attributes.get("href") {
if href.starts_with("/@") || href.starts_with('@') {

View file

@ -74,7 +74,7 @@ pub fn is_example_domain(uri: &Uri) -> bool {
domain == example
|| domain
.split_once('.')
.map_or(false, |(_subdomain, tld_part)| tld_part == example)
.is_some_and(|(_subdomain, tld_part)| tld_part == example)
}) || EXAMPLE_TLDS
.iter()
.any(|&example_tld| domain.ends_with(example_tld))

View file

@ -88,7 +88,7 @@ impl RetryExt for http::Error {
inner
.source()
.and_then(<(dyn std::error::Error + 'static)>::downcast_ref)
.map_or(false, should_retry_io)
.is_some_and(should_retry_io)
}
}

View file

@ -57,9 +57,7 @@ impl<P: AsRef<Path>> From<P> for FileType {
fn is_url(path: &Path) -> bool {
path.to_str()
.and_then(|s| Url::parse(s).ok())
.map_or(false, |url| {
url.scheme() == "http" || url.scheme() == "https"
})
.is_some_and(|url| url.scheme() == "http" || url.scheme() == "https")
}
#[cfg(test)]