Skip to content

Commit

Permalink
Fix remaining clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Sep 3, 2021
1 parent 63030b3 commit c5d7544
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lychee-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn run_main() -> Result<i32> {

// Load a potentially existing config file and merge it into the config from the CLI
if let Some(c) = Config::load_from_file(&opts.config_file)? {
opts.config.merge(c)
opts.config.merge(c);
}

// Load excludes from file
Expand Down Expand Up @@ -170,7 +170,7 @@ fn fmt(stats: &ResponseStats, format: &Format) -> Result<String> {
async fn run(cfg: &Config, inputs: Vec<Input>) -> Result<i32> {
let mut headers = parse_headers(&cfg.headers)?;
if let Some(auth) = &cfg.basic_auth {
let auth_header = parse_basic_auth(&auth)?;
let auth_header = parse_basic_auth(auth)?;
headers.typed_insert(auth_header);
}

Expand Down
2 changes: 1 addition & 1 deletion lychee-bin/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Display for ResponseStats {
// lets us avoid extra newlines without any additional logic.
write!(f, "\n\nErrors in {}", input)?;
for response in responses {
write!(f, "\n{}", color_response(response))?
write!(f, "\n{}", color_response(response))?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lychee-lib/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Input {
pub fn new(value: &str, glob_ignore_case: bool) -> Self {
if value == STDIN {
Self::Stdin
} else if let Ok(url) = Url::parse(&value) {
} else if let Ok(url) = Url::parse(value) {
Self::RemoteUrl(Box::new(url))
} else {
// this seems to be the only way to determine if this is a glob pattern
Expand Down
31 changes: 13 additions & 18 deletions lychee-lib/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ impl<P: AsRef<Path>> From<P> for FileType {
// `AsRef<Path>` could be implemented for `Url` in the future, which is why
// `From<Url> for FileType` is not allowed.
match path.extension().and_then(std::ffi::OsStr::to_str) {
Some("md") | Some("markdown") => FileType::Markdown,
Some("htm") | Some("html") | None => FileType::Html,
Some("md" | "markdown") => FileType::Markdown,
Some("htm" | "html") | None => FileType::Html,
Some(_) => FileType::Plaintext,
}
}
Expand All @@ -58,7 +58,7 @@ fn extract_links_from_markdown(input: &str) -> Vec<String> {
let parser = Parser::new(input);
parser
.flat_map(|event| match event {
MDEvent::Start(Tag::Link(_, url, _)) | MDEvent::Start(Tag::Image(_, url, _)) => {
MDEvent::Start(Tag::Link(_, url, _) | Tag::Image(_, url, _)) => {
vec![url.to_string()]
}
MDEvent::Text(txt) => extract_links_from_plaintext(&txt.to_string()),
Expand Down Expand Up @@ -125,12 +125,7 @@ fn elem_attr_is_link(attr_name: &str, elem_name: &str) -> bool {
// over at: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
matches!(
(attr_name, elem_name),
("href", _)
| ("src", _)
| ("srcset", _)
| ("cite", _)
| ("data", "object")
| ("onhashchange", "body")
("href" | "src" | "srcset" | "cite", _) | ("data", "object") | ("onhashchange", "body")
)
}

Expand Down Expand Up @@ -241,9 +236,9 @@ mod test {
let input = "http://www.apache.org/licenses/LICENSE-2.0\n";
let link = input.trim_end();

assert_eq!(vec![link], extract_links_from_markdown(&input));
assert_eq!(vec![link], extract_links_from_plaintext(&input));
assert_eq!(vec![link], extract_links_from_html(&input));
assert_eq!(vec![link], extract_links_from_markdown(input));
assert_eq!(vec![link], extract_links_from_plaintext(input));
assert_eq!(vec![link], extract_links_from_html(input));
}

#[test]
Expand All @@ -260,7 +255,7 @@ mod test {
])
.collect::<HashSet<Uri>>();

assert_eq!(links, expected_links)
assert_eq!(links, expected_links);
}

#[test]
Expand Down Expand Up @@ -289,14 +284,14 @@ mod test {
fn test_skip_markdown_anchors() {
let links = extract_uris("This is [a test](#lol).", FileType::Markdown, None);

assert!(links.is_empty())
assert!(links.is_empty());
}

#[test]
fn test_skip_markdown_internal_urls() {
let links = extract_uris("This is [a test](./internal).", FileType::Markdown, None);

assert!(links.is_empty())
assert!(links.is_empty());
}

#[test]
Expand All @@ -317,7 +312,7 @@ mod test {
])
.collect::<HashSet<Uri>>();

assert_eq!(links, expected)
assert_eq!(links, expected);
}

#[test]
Expand All @@ -326,7 +321,7 @@ mod test {
let links = extract_uris(input, FileType::Markdown, None);
let expected = array::IntoIter::new([mail("test@test.com")]).collect::<HashSet<Uri>>();

assert_eq!(links, expected)
assert_eq!(links, expected);
}

#[test]
Expand All @@ -342,7 +337,7 @@ mod test {
])
.collect::<HashSet<Uri>>();

assert_eq!(links, expected)
assert_eq!(links, expected);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion lychee-lib/src/quirks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Default for Quirks {
if let Some(id) = query(&out).get("v") {
*out.url_mut() =
Url::parse(&format!("https://img.youtube.com/vi/{}/0.jpg", &id))
.unwrap()
.unwrap();
}
out
},
Expand Down

0 comments on commit c5d7544

Please sign in to comment.