Skip to content

Commit 7c428f7

Browse files
fix(ssg): 🐛 fix lint issues
1 parent dd6768e commit 7c428f7

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

benches/bench_file.rs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,55 @@
11
// Copyright © 2023-2025 Shokunin Static Site Generator. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

4+
//! Benchmark suite for the Shokunin Static Site Generator.
5+
//!
6+
//! This module contains performance benchmarks for critical operations
7+
//! in the static site generator, including file operations and content processing.
8+
49
use criterion::{black_box, Criterion};
510
use staticdatagen::utilities::file::add;
611
use std::path::PathBuf;
712

813
/// Runs a benchmark that measures the performance of the `add` function.
914
///
15+
/// This benchmark measures file addition performance by repeatedly calling
16+
/// the `add` function with a test path and measuring execution time.
17+
///
1018
/// # Arguments
1119
///
12-
/// * `c` - A reference to a `Criterion` instance.
13-
#[allow(dead_code)]
20+
/// * `c` - A reference to a `Criterion` instance used for benchmark configuration
21+
/// and measurement.
22+
///
23+
/// # Example Output
24+
///
25+
/// ```text
26+
/// add function time: [10.123 µs 10.234 µs 10.345 µs]
27+
/// ```
1428
pub(crate) fn bench_file(c: &mut Criterion) {
1529
let path = PathBuf::from("content");
16-
let _ = c.bench_function("add function", |b| {
30+
c.bench_function("add function", |b| {
1731
b.iter(|| {
1832
let result = add(&path);
1933
if let Err(e) = result {
2034
eprintln!("Error: {}", e);
2135
} else {
22-
let _ = black_box(result.unwrap());
36+
black_box(result.unwrap());
2337
}
2438
})
2539
});
2640
}
41+
42+
#[cfg(test)]
43+
mod tests {
44+
use super::*;
45+
use criterion::black_box;
46+
use std::path::PathBuf;
47+
48+
/// Tests the benchmark setup and basic functionality.
49+
#[test]
50+
fn test_bench_setup() {
51+
let path = PathBuf::from("content");
52+
let result = add(&path);
53+
assert!(result.is_ok() || result.is_err());
54+
}
55+
}

examples/multilingual_example.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() -> Result<()> {
1919

2020
// Root directory for public files
2121
let public_root = Path::new("./examples/public");
22-
fs::create_dir_all(&public_root)?;
22+
fs::create_dir_all(public_root)?;
2323

2424
// Generate sites for all languages
2525
for lang in &languages {
@@ -43,7 +43,7 @@ fn main() -> Result<()> {
4343
}
4444

4545
// Generate the root `index.html` with language links
46-
generate_language_selector(&public_root, &languages)?;
46+
generate_language_selector(public_root, &languages)?;
4747

4848
// Serve the root public directory
4949
let server =
@@ -61,7 +61,7 @@ fn generate_language_selector(
6161
) -> Result<()> {
6262
// Read the selector.html template
6363
let template_path = Path::new("./examples/templates/selector.html");
64-
let template = fs::read_to_string(&template_path)
64+
let template = fs::read_to_string(template_path)
6565
.context("Failed to read selector.html template")?;
6666

6767
// Replace the placeholder with the language links

0 commit comments

Comments
 (0)