feat: improve graphical diagnostic spacing

This commit is contained in:
Dandaedre 2026-09-29 23:17:48 +02:00
parent d49363e80e
commit cf21ff1b9b
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
8 changed files with 56 additions and 10 deletions

View File

@ -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"

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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::<Vec<_>>();
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]

View File

@ -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.

View File

@ -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::<Vec<_>>();
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], "");
}
}
}
}