Apply lints to all targets

This commit is contained in:
Juno Takano 2026-03-16 20:07:27 -03:00
commit 6af32696be
19 changed files with 61 additions and 95 deletions

View file

@ -2,3 +2,4 @@ allow-unwrap-in-tests = true
allow-expect-in-tests = true allow-expect-in-tests = true
single-char-binding-names-threshold = 2 single-char-binding-names-threshold = 2
upper-case-acronyms-aggressive = true upper-case-acronyms-aggressive = true
allow-indexing-slicing-in-tests = true

View file

@ -96,7 +96,7 @@ alias f := format
# Lint # Lint
[group: 'develop'] [group: 'develop']
lint: lint:
cargo +nightly clippy cargo +nightly clippy --timings --all-targets
alias l := lint alias l := lint
@ -228,9 +228,10 @@ alias fc := format-assess
# Assess production lints # Assess production lints
[group: 'assess'] [group: 'assess']
lint-assess: lint-assess:
cargo +nightly clippy -- \ cargo +nightly clippy --timings -- \
-D clippy::dbg_macro -D clippy::use_debug \
-D clippy::print_stdout -D clippy::print_stderr \ -D clippy::print_stdout -D clippy::print_stderr \
-D clippy::dbg_macro -D clippy::use_debug
cargo +nightly clippy --timings --all-targets -- \
-D clippy::todo -D clippy::unimplemented -D clippy::unreachable -D clippy::todo -D clippy::unimplemented -D clippy::unreachable
alias la := lint-assess alias la := lint-assess

View file

@ -211,7 +211,6 @@ shadow_reuse = "warn"
shadow_same = "warn" shadow_same = "warn"
shadow_unrelated = "warn" shadow_unrelated = "warn"
should_panic_without_expect = "warn" should_panic_without_expect = "warn"
similar_names = "warn"
single_char_pattern = "warn" single_char_pattern = "warn"
single_match_else = "warn" single_match_else = "warn"
single_option_map = "warn" single_option_map = "warn"

View file

@ -721,8 +721,8 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
let node = graph.nodes.get("Node").unwrap(); let node = &graph.nodes["Node"];
let connection = node.connections.get("Nowhere").unwrap(); let connection = &node.connections["Nowhere"];
assert!(connection.detached); assert!(connection.detached);
} }
@ -743,8 +743,8 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
let node = graph.nodes.get("NodeOne").unwrap(); let node = &graph.nodes["NodeOne"];
let connection = node.connections.get("NodeTwo").unwrap(); let connection = &node.connections["NodeTwo"];
println!("{connection:#?}"); println!("{connection:#?}");
assert!(!connection.detached); assert!(!connection.detached);
} }
@ -763,10 +763,10 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
let n01 = graph.nodes.get("n01").unwrap(); let n01 = &graph.nodes["n01"];
let n02 = graph.nodes.get("n02").unwrap(); let n02 = &graph.nodes["n02"];
let n01_to_n02 = n01.connections.get("n02").unwrap(); let n01_to_n02 = &n01.connections["n02"];
let n02_to_n03 = n02.connections.get("n03").unwrap(); let n02_to_n03 = &n02.connections["n03"];
assert_eq!(n01_to_n02.from, "n01"); assert_eq!(n01_to_n02.from, "n01");
assert_eq!(n01_to_n02.to, "n02"); assert_eq!(n01_to_n02.to, "n02");
@ -793,16 +793,16 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
let n01 = graph.nodes.get("n01").unwrap(); let n01 = &graph.nodes["n01"];
let n02 = graph.nodes.get("n02").unwrap(); let n02 = &graph.nodes["n02"];
let n04 = graph.nodes.get("n04").unwrap(); let n04 = &graph.nodes["n04"];
let n01_to_n02 = n01.connections.get("n02").unwrap(); let n01_to_n02 = &n01.connections["n02"];
let n01_to_n03 = n01.connections.get("n03").unwrap(); let n01_to_n03 = &n01.connections["n03"];
let n01_to_n04 = n01.connections.get("n04").unwrap(); let n01_to_n04 = &n01.connections["n04"];
let n04_to_n01 = n04.connections.get("n01").unwrap(); let n04_to_n01 = &n04.connections["n01"];
let n04_to_n03 = n04.connections.get("n03").unwrap(); let n04_to_n03 = &n04.connections["n03"];
assert_eq!(n01_to_n02.from, "n01"); assert_eq!(n01_to_n02.from, "n01");
assert_eq!(n01_to_n02.to, "n02"); assert_eq!(n01_to_n02.to, "n02");
@ -861,8 +861,8 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
assert!(graph.nodes.get("n01").unwrap().summary.contains(text)); assert!(&graph.nodes["n01"].summary.contains(text));
assert!(graph.nodes.get("n01").unwrap().text.contains(text)); assert!(&graph.nodes["n01"].text.contains(text));
} }
#[test] #[test]
@ -881,8 +881,8 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
assert_eq!(graph.nodes.get("n01").unwrap().summary, summary); assert_eq!(&graph.nodes["n01"].summary, summary);
assert!(graph.nodes.get("n01").unwrap().text.contains(text)); assert!(&graph.nodes["n01"].text.contains(text));
} }
#[test] #[test]
@ -900,7 +900,7 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
assert_eq!(graph.nodes.get("n01").unwrap().summary, first_sentence); assert_eq!(&graph.nodes["n01"].summary, first_sentence);
} }
#[test] #[test]
@ -919,7 +919,7 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
assert_eq!(graph.nodes.get("n01").unwrap().summary, first_paragraph); assert_eq!(&graph.nodes["n01"].summary, first_paragraph);
} }
#[test] #[test]
@ -948,7 +948,7 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
assert_eq!(graph.nodes.get("n01").unwrap().summary, summary); assert_eq!(graph.nodes["n01"].summary, summary);
} }
#[test] #[test]
@ -967,9 +967,9 @@ mod tests {
.unwrap(); .unwrap();
graph.modulate(); graph.modulate();
let n1_to_n2 = graph.nodes.get("n1").unwrap().connections.get("n2"); let n1_to_n2 = &graph.nodes["n1"].connections.get("n2");
let n2_to_n0 = graph.nodes.get("n2").unwrap().connections.get("n0"); let n2_to_n0 = &graph.nodes["n2"].connections.get("n0");
println!("{n1_to_n2:#?}"); println!("{n1_to_n2:#?}");
println!("{n2_to_n0:#?}"); println!("{n2_to_n0:#?}");
@ -991,8 +991,8 @@ mod tests {
graph.modulate(); graph.modulate();
assert_eq!(graph.stats.detached_total, 2); assert_eq!(graph.stats.detached_total, 2);
assert_eq!(*graph.stats.detached.get("anchor").unwrap(), 1); assert_eq!(graph.stats.detached["anchor"], 1);
assert_eq!(*graph.stats.detached.get("this one").unwrap(), 1); assert_eq!(graph.stats.detached["this one"], 1);
} }
#[test] #[test]
@ -1008,7 +1008,7 @@ mod tests {
graph.modulate(); graph.modulate();
assert_eq!(graph.stats.detached_total, 2); assert_eq!(graph.stats.detached_total, 2);
assert_eq!(*graph.stats.detached.get("anchor").unwrap(), 2); assert_eq!(graph.stats.detached["anchor"], 2);
} }
#[test] #[test]
@ -1295,7 +1295,7 @@ mod tests {
assert!(!format!("{none}").contains("exact")); assert!(!format!("{none}").contains("exact"));
let some = QueryResult { let some = QueryResult {
node: Some(node.clone()), node: Some(node),
exact: false, exact: false,
redirect: false, redirect: false,
}; };

View file

@ -600,7 +600,6 @@ mod tests {
assert!( assert!(
validation_error validation_error
.message .message
.clone()
.unwrap() .unwrap()
.contains("Splits to three elements: false") .contains("Splits to three elements: false")
); );

View file

@ -102,39 +102,18 @@ impl Mime {
} }
} }
pub fn kind(&self) -> Result<Kind, String> { /// Returns one of four kind of mimetypes among text, font, image and blob.
let string = String::from(self.clone()); ///
let mut parts = string.split('/'); /// This is mainly used when serving assets through the `fixed` module in
let first_opt = parts.next(); /// order to determine what `Asset` field to use when assemblimg a response
let second_opt = parts.next(); /// body.
if let Some(first) = first_opt pub const fn kind(&self) -> Kind {
&& let Some(second) = second_opt use Mime::*;
{ match self {
if first == "application" { Txt | Csv | Css | Toml | Xml | Json | Js | Svg => Kind::Text,
if second == "toml" || second == "xml" || second == "json" { Ttf | Otf | Woff | Woff2 => Kind::Font,
Ok(Kind::Text) Ico | Jpeg | Png | Apng | Gif | Webp | Avif => Kind::Image,
} else if second == "pdf" Pdf | Epub | Unknown => Kind::Blob,
|| second == "epub"
|| second == "epub+zip"
|| second == "octet-stream"
{
Ok(Kind::Blob)
} else {
Err(format!(
"Unexpected application kind for mimetype {string}"
))
}
} else if first == "text" {
Ok(Kind::Text)
} else if first == "font" {
Ok(Kind::Font)
} else if first == "image" {
Ok(Kind::Image)
} else {
Err(format!("Could not determine a kind for mimetype {string}"))
}
} else {
Err(format!("Mimetype {string} couldn't be split on a slash"))
} }
} }
} }

View file

@ -286,7 +286,7 @@ mod tests {
fn first_segment() { fn first_segment() {
let payload = "nhNc fGev QnGW E4hj ExyZ"; let payload = "nhNc fGev QnGW E4hj ExyZ";
let lexeme = Lexeme::new(payload, "", ""); let lexeme = Lexeme::new(payload, "", "");
assert_eq!(lexeme.clone().first_segment(), Some(String::from("nhNc"))); assert_eq!(lexeme.first_segment(), Some(String::from("nhNc")));
} }
#[test] #[test]
@ -381,8 +381,8 @@ mod tests {
let lexemes = Lexeme::collect(&input); let lexemes = Lexeme::collect(&input);
let first = lexemes.first().unwrap(); let first = lexemes.first().unwrap();
let second = lexemes.get(1).unwrap(); let second = &lexemes[1];
let third = lexemes.get(2).unwrap(); let third = &lexemes[2];
let last = lexemes.last().unwrap(); let last = lexemes.last().unwrap();
assert_eq!( assert_eq!(

View file

@ -216,7 +216,7 @@ mod tests {
anchor.external = true; anchor.external = true;
assert_eq!( assert_eq!(
format!("{}", Token::Anchor(Box::new(anchor.clone()))), format!("{}", Token::Anchor(Box::new(anchor))),
"Tk:Anchor 'wPVo1 0OmYm' -> \"M1UEp 1gbfr\" \ "Tk:Anchor 'wPVo1 0OmYm' -> \"M1UEp 1gbfr\" \
+Leading +Balanced +External", +Leading +Balanced +External",
); );

View file

@ -60,10 +60,7 @@ mod tests {
assert_eq!(format!("{}", Token::Bold(bold.clone())), "Tk:Bold [open]"); assert_eq!(format!("{}", Token::Bold(bold.clone())), "Tk:Bold [open]");
bold.open = false; bold.open = false;
assert_eq!( assert_eq!(format!("{}", Token::Bold(bold)), "Tk:Bold [closed]");
format!("{}", Token::Bold(bold.clone())),
"Tk:Bold [closed]"
);
} }
#[test] #[test]

View file

@ -64,7 +64,7 @@ mod tests {
checkbox.checked = false; checkbox.checked = false;
assert_eq!( assert_eq!(
format!("{}", Token::CheckBox(checkbox.clone())), format!("{}", Token::CheckBox(checkbox)),
"Tk:CheckBox [empty]" "Tk:CheckBox [empty]"
); );
} }

View file

@ -60,9 +60,6 @@ mod tests {
assert_eq!(format!("{}", Token::Code(code.clone())), "Tk:Code [open]"); assert_eq!(format!("{}", Token::Code(code.clone())), "Tk:Code [open]");
code.open = false; code.open = false;
assert_eq!( assert_eq!(format!("{}", Token::Code(code)), "Tk:Code [closed]");
format!("{}", Token::Code(code.clone())),
"Tk:Code [closed]"
);
} }
} }

View file

@ -80,7 +80,7 @@ mod tests {
); );
item.depth = None; item.depth = None;
assert_eq!( assert_eq!(
format!("{}", Token::Item(item.clone())), format!("{}", Token::Item(item)),
"Tk:Item [<unknown>] dRMy4" "Tk:Item [<unknown>] dRMy4"
); );
} }

View file

@ -28,7 +28,6 @@ mod tests {
#[test] #[test]
fn token_display() { fn token_display() {
let linebreak = LineBreak::default(); assert_eq!(format!("{}", Token::LineBreak(LineBreak)), "Tk:LineBreak");
assert_eq!(format!("{}", Token::LineBreak(linebreak)), "Tk:LineBreak");
} }
} }

View file

@ -43,9 +43,6 @@ mod tests {
); );
literal.text = String::from("TjY02"); literal.text = String::from("TjY02");
assert_eq!( assert_eq!(format!("{}", Token::Literal(literal)), "Tk:Literal TjY02");
format!("{}", Token::Literal(literal.clone())),
"Tk:Literal TjY02"
);
} }
} }

View file

@ -64,7 +64,7 @@ mod tests {
oblique.open = false; oblique.open = false;
assert_eq!( assert_eq!(
format!("{}", Token::Oblique(oblique.clone())), format!("{}", Token::Oblique(oblique)),
"Tk:Oblique [closed]" "Tk:Oblique [closed]"
); );
} }

View file

@ -89,7 +89,7 @@ mod tests {
paragraph.open = None; paragraph.open = None;
assert_eq!( assert_eq!(
format!("{}", Token::Paragraph(paragraph.clone())), format!("{}", Token::Paragraph(paragraph)),
"Tk:Paragraph [unknown]" "Tk:Paragraph [unknown]"
); );
} }

View file

@ -85,7 +85,7 @@ mod tests {
preformat.open = None; preformat.open = None;
assert_eq!( assert_eq!(
format!("{}", Token::PreFormat(preformat.clone())), format!("{}", Token::PreFormat(preformat)),
"Tk:PreFormat [unknown]" "Tk:PreFormat [unknown]"
); );
} }

View file

@ -62,10 +62,7 @@ mod tests {
); );
strike.open = false; strike.open = false;
assert_eq!( assert_eq!(format!("{}", Token::Strike(strike)), "Tk:Strike [closed]");
format!("{}", Token::Strike(strike.clone())),
"Tk:Strike [closed]"
);
} }
#[test] #[test]

View file

@ -66,7 +66,7 @@ mod tests {
underline.open = false; underline.open = false;
assert_eq!( assert_eq!(
format!("{}", Token::Underline(underline.clone())), format!("{}", Token::Underline(underline)),
"Tk:Underline [closed]" "Tk:Underline [closed]"
); );
} }