From cf21ff1b9b365e915f896ea5a9eda8b792ab6e03 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 29 Sep 2026 23:17:48 +0200 Subject: [PATCH] feat: improve graphical diagnostic spacing --- .run_status.toml | 6 +++--- CHANGELOG.md | 2 ++ docs/development.md | 4 ++-- docs/output.md | 7 +++++-- docs/usage.md | 4 +++- src/bin/john-slop/output.rs | 26 +++++++++++++++++++++++++- tasks.md | 7 ++++++- tests/example_fixtures.rs | 10 ++++++++++ 8 files changed, 56 insertions(+), 10 deletions(-) diff --git a/.run_status.toml b/.run_status.toml index 0e656ed..3734079 100644 --- a/.run_status.toml +++ b/.run_status.toml @@ -1,11 +1,11 @@ [last_run_clean] run_status = "Success" lines_parsed = 375 -coverage = 92.19 +coverage = 92.23 [last_run_clean.run_duration] -secs = 38 -nanos = 218186395 +secs = 31 +nanos = 435206141 [last_run_incremental] run_status = "Success" diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bb5571..f74091f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ All notable changes to John Slop are recorded here. The format follows ### Changed +- Made graphical Miette output easier to scan with marked rule-code titles, + attached diagnostic bodies, and spacing between complete findings. - Adopted the measured three-package Cargo workspace. Shared package metadata, dependency requirements, and lint policy now use workspace inheritance while the reusable core remains isolated from CLI, async, and LSP dependencies. diff --git a/docs/development.md b/docs/development.md index b3ef2f0..0617152 100644 --- a/docs/development.md +++ b/docs/development.md @@ -56,8 +56,8 @@ Run line coverage with Cargo Tarpaulin: cargo tarpaulin --config tarpaulin.toml ``` -The configuration enforces a 90% floor. The current suite measured 92.19% -(1,334/1,447 lines) on 2026-09-29. The remaining lines are dominated by +The configuration enforces a 90% floor. The current suite measured 92.23% +(1,342/1,455 lines) on 2026-09-29. The remaining lines are dominated by platform/I/O failure injection, malformed archive internals, coordinate overflow, LSP logging/reload failures, and subprocess attribution. Do not add brittle tests or production seams solely to make Tarpaulin count those paths. diff --git a/docs/output.md b/docs/output.md index 626b149..132cf57 100644 --- a/docs/output.md +++ b/docs/output.md @@ -17,8 +17,11 @@ deliberately avoids ANSI escapes. `--output miette` is the default. It renders the same typed diagnostics with Miette's graphical Unicode source annotations and ANSI severity colors, -followed by the same summary. This mode requires the default -`fancy-diagnostics` Cargo feature; builds made with `--no-default-features` +followed by the same summary. Each diagnostic starts with a `◆`-marked rule-code +title immediately followed by its severity/message, and ends with an empty line +that separates it from the next diagnostic or summary. This mode requires the +default `fancy-diagnostics` Cargo feature; builds made with +`--no-default-features` accept the option but fall back to the plain human renderer. Select `human`, `concise`, or `json` when ANSI escapes are not appropriate. diff --git a/docs/usage.md b/docs/usage.md index e467a41..7098a3d 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -24,7 +24,9 @@ limits can be overridden with `--max-document-bytes`, `--max-archive-bytes`, Select output with `--output human`, `--output miette`, `--output concise`, or `--output json`. Miette is the default and uses colored Unicode graphical source -annotations when the default `fancy-diagnostics` feature is enabled; it falls +annotations when the default `fancy-diagnostics` feature is enabled. Its marked +rule-code titles stay attached to their messages, while an empty line separates +complete diagnostics; it falls back to human mode without that feature. Human mode renders uncolored plain source excerpts, exact labels, remediation help, and a summary. Concise mode emits stable single-line finding and summary records. JSON mode emits one object diff --git a/src/bin/john-slop/output.rs b/src/bin/john-slop/output.rs index c9d74f3..e3e32c0 100644 --- a/src/bin/john-slop/output.rs +++ b/src/bin/john-slop/output.rs @@ -76,6 +76,17 @@ fn render_human(source_id: &SourceId, source: &str, analysis: &Analysis) -> Stri rendered } +#[cfg(feature = "fancy-diagnostics")] +fn append_graphical_diagnostic(rendered: &mut String, mut diagnostic: String) { + if let Some(title_break) = diagnostic.find("\n\n") { + diagnostic.replace_range(title_break..title_break + 2, "\n"); + } + + rendered.push_str("◆ "); + rendered.push_str(diagnostic.trim_end_matches('\n')); + rendered.push_str("\n\n"); +} + #[cfg(feature = "fancy-diagnostics")] fn render_miette(source_id: &SourceId, source: &str, analysis: &Analysis) -> String { let mut rendered = String::new(); @@ -84,9 +95,11 @@ fn render_miette(source_id: &SourceId, source: &str, analysis: &Analysis) -> Str .with_links(false); for finding in &analysis.findings { let diagnostic = FindingDiagnostic::new(source_id, source, finding); + let mut diagnostic_rendered = String::new(); handler - .render_report(&mut rendered, &diagnostic) + .render_report(&mut diagnostic_rendered, &diagnostic) .expect("writing a diagnostic to a String cannot fail"); + append_graphical_diagnostic(&mut rendered, diagnostic_rendered); } append_summary(&mut rendered, source_id, analysis); rendered @@ -316,6 +329,17 @@ mod tests { assert!(output.contains("help:")); assert!(output.contains("low-care evidence score")); assert!(output.contains('\u{1b}')); + + let lines = output.lines().collect::>(); + assert!(lines[0].starts_with("◆ ")); + assert!(lines[0].contains("typography-non-ascii-hyphen")); + assert!(!lines[1].is_empty(), "title and message must stay adjacent"); + let help_line = lines + .iter() + .position(|line| line.contains("help:")) + .expect("graphical diagnostic must retain help"); + assert_eq!(lines[help_line + 1], ""); + assert!(lines[help_line + 2].contains("low-care evidence score")); } #[test] diff --git a/tasks.md b/tasks.md index 50f638a..87a1174 100644 --- a/tasks.md +++ b/tasks.md @@ -375,7 +375,7 @@ measurable source coverage. ## Milestone 14 — Readable graphical diagnostics -- [ ] Give each graphical Miette diagnostic a visible title marker, remove the +- [x] Give each graphical Miette diagnostic a visible title marker, remove the empty line between its rule-code title and message, and add one empty line after the complete diagnostic. Pin the layout in unit and showcase tests, document it, and leave human, concise, JSON, and minimal-feature fallback @@ -386,6 +386,11 @@ message remain visually connected; stable rule IDs, severity symbols, colors, source annotations, help, summaries, and machine-output contracts are preserved; all quality and coverage gates pass. +Accepted on 2026-09-29 after graphical unit/showcase layout tests, the +minimal-feature fallback test, both complete feature matrices, formatting, +Clippy, rustdoc, and Tarpaulin passed. Coverage is 92.23% (1,342/1,455 lines) +against the 90% floor. + ## Deferred by design - Statistical or model-based authorship classification. diff --git a/tests/example_fixtures.rs b/tests/example_fixtures.rs index 469d1a5..b30d570 100644 --- a/tests/example_fixtures.rs +++ b/tests/example_fixtures.rs @@ -167,6 +167,16 @@ fn diagnostic_showcase_is_an_expected_threshold_failure() { { assert!(stdout.contains('\u{1b}')); assert!(stdout.contains('╭')); + assert_eq!(stdout.matches("◆ ").count(), 12); + let lines = stdout.lines().collect::>(); + for (index, line) in lines.iter().enumerate() { + if line.starts_with("◆ ") { + assert!(!lines[index + 1].is_empty()); + } + if line.contains("help:") { + assert_eq!(lines[index + 1], ""); + } + } } }