diff --git a/.justfile b/.justfile index d4c94c6..6ac8864 100644 --- a/.justfile +++ b/.justfile @@ -19,6 +19,13 @@ test-watch: alias tw := test-watch +# Run cargo check on changes +[group('dev')] +check-watch: + bacon --job check + +alias cw := check-watch + # Format check on changes [group('dev')] format-watch: @@ -26,6 +33,13 @@ format-watch: alias fw := format-watch +# Lint on changes +[group('dev')] +lint-watch: + bacon --job clippy-all + +alias lw := lint-watch + # Check before push [group('dev')] push: check diff --git a/Cargo.toml b/Cargo.toml index 1c1a46f..173a0cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,7 +102,6 @@ mismatching_type_param_order = "warn" missing_errors_doc = "warn" missing_fields_in_debug = "warn" missing_panics_doc = "warn" -must_use_candidate = "warn" mut_mut = "warn" naive_bytecount = "warn" needless_continue = "warn" @@ -202,7 +201,6 @@ shadow_unrelated = "warn" single_char_lifetime_names = "warn" string_add = "warn" string_lit_chars_any = "warn" -tests_outside_test_module = "warn" unnecessary_self_imports = "warn" unneeded_field_pattern = "warn" unseparated_literal_suffix = "warn" diff --git a/src/formats.rs b/src/formats.rs index 28eff67..6620fec 100644 --- a/src/formats.rs +++ b/src/formats.rs @@ -124,3 +124,12 @@ pub fn deserialize_graph(in_format: &Format, serial: &str) -> Graph { }, } } + +#[cfg(test)] +mod tests { + #[test] + fn smoke() { + let n = true; + assert!(n); + } +} diff --git a/src/handlers/error.rs b/src/handlers/error.rs index 0aaa543..a475d23 100644 --- a/src/handlers/error.rs +++ b/src/handlers/error.rs @@ -45,6 +45,7 @@ fn make_body(code: Option, message: Option<&str>) -> String { .0 } +#[expect(clippy::unused_async)] pub async fn not_found() -> Response { by_code( Some(404), diff --git a/src/handlers/fixed.rs b/src/handlers/fixed.rs index 0c969f9..a9c2300 100644 --- a/src/handlers/fixed.rs +++ b/src/handlers/fixed.rs @@ -8,6 +8,8 @@ use crate::{ }; use crate::handlers; +/// # Panics +/// Will panic if file read fails. pub async fn file(file_path: &str, content_type: &str) -> Response { let content = match std::fs::read(file_path) { Ok(s) => s, diff --git a/src/handlers/graph.rs b/src/handlers/graph.rs index 8b16b69..209e9b6 100644 --- a/src/handlers/graph.rs +++ b/src/handlers/graph.rs @@ -2,6 +2,7 @@ use axum::{body::Body, extract::Path, http::Response}; use crate::{formats::populate_graph, handlers, types::Node}; +#[expect(clippy::unused_async)] pub async fn node(Path(id): Path) -> Response { let mut context = tera::Context::new(); diff --git a/src/handlers/navigation.rs b/src/handlers/navigation.rs index cdfdec7..fb4444a 100644 --- a/src/handlers/navigation.rs +++ b/src/handlers/navigation.rs @@ -20,6 +20,7 @@ pub async fn nexus(template: &str) -> Response { handlers::template::by_filename(template, &context, 500, None, false) } +#[expect(clippy::unused_async)] pub async fn search(Form(query): Form) -> Redirect { Redirect::permanent(format!("/node/{}", query.node).as_str()) } diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..a284a81 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,10 @@ +use std::{sync, time}; + +pub mod formats; +pub mod types; +pub mod handlers; +pub mod syntax; +pub mod dev; + +pub static ONSET: sync::LazyLock = + sync::LazyLock::new(time::Instant::now); diff --git a/src/main.rs b/src/main.rs index 1d637e8..a0e128a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,8 @@ -use std::{backtrace, io, panic, sync, time}; +use std::{backtrace, io, panic}; use axum::{routing::get, Router}; -use formats::Format; - -mod formats; -mod types; -mod handlers; -mod syntax; -mod dev; - -static ONSET: sync::LazyLock = - sync::LazyLock::new(time::Instant::now); +use en::{ONSET, handlers, syntax, dev, formats::Format}; #[tokio::main] async fn main() -> io::Result<()> { @@ -99,3 +90,12 @@ async fn main() -> io::Result<()> { Ok(()) } + +#[cfg(test)] +mod tests { + #[test] + fn smoke() { + let e = true; + assert!(e); + } +} diff --git a/src/syntax/arguments.rs b/src/syntax/arguments.rs index c92dd48..7ae13e7 100644 --- a/src/syntax/arguments.rs +++ b/src/syntax/arguments.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct Arguments { pub hostname: String, pub port: u16, @@ -20,6 +20,7 @@ impl Arguments { } } + #[must_use] pub fn parse(&self) -> Arguments { let args: Vec = std::env::args().collect(); parse(self, &args) diff --git a/tests/smoke.rs b/tests/smoke.rs new file mode 100644 index 0000000..70e3018 --- /dev/null +++ b/tests/smoke.rs @@ -0,0 +1,6 @@ +#[test] +fn add() { + let e = 0_i32; + let n = 0_i32; + assert_eq!(e, n); +}