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
single-char-binding-names-threshold = 2
upper-case-acronyms-aggressive = true
allow-indexing-slicing-in-tests = true

View file

@ -96,7 +96,7 @@ alias f := format
# Lint
[group: 'develop']
lint:
cargo +nightly clippy
cargo +nightly clippy --timings --all-targets
alias l := lint
@ -228,9 +228,10 @@ alias fc := format-assess
# Assess production lints
[group: 'assess']
lint-assess:
cargo +nightly clippy -- \
-D clippy::dbg_macro -D clippy::use_debug \
cargo +nightly clippy --timings -- \
-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
alias la := lint-assess

View file

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

View file

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

View file

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

View file

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

View file

@ -286,7 +286,7 @@ mod tests {
fn first_segment() {
let payload = "nhNc fGev QnGW E4hj ExyZ";
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]
@ -381,8 +381,8 @@ mod tests {
let lexemes = Lexeme::collect(&input);
let first = lexemes.first().unwrap();
let second = lexemes.get(1).unwrap();
let third = lexemes.get(2).unwrap();
let second = &lexemes[1];
let third = &lexemes[2];
let last = lexemes.last().unwrap();
assert_eq!(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -28,7 +28,6 @@ mod tests {
#[test]
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");
assert_eq!(
format!("{}", Token::Literal(literal.clone())),
"Tk:Literal TjY02"
);
assert_eq!(format!("{}", Token::Literal(literal)), "Tk:Literal TjY02");
}
}

View file

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

View file

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

View file

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

View file

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

View file

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