feat: default to colored miette diagnostics
Rust CI JohnSlop failed CI.
Gitea/john_slop/pipeline/head There was a failure building this commit
Details
Rust CI JohnSlop failed CI.
Gitea/john_slop/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
6743a2f373
commit
30445d7983
|
|
@ -1,8 +1,8 @@
|
|||
[last_run_clean]
|
||||
run_status = "Success"
|
||||
lines_parsed = 335
|
||||
lines_parsed = 337
|
||||
coverage = 92.16
|
||||
|
||||
[last_run_clean.run_duration]
|
||||
secs = 34
|
||||
nanos = 910199784
|
||||
secs = 29
|
||||
nanos = 214508516
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ cargo install --git https://git.dandaedre.com/idle-org/john_slop \
|
|||
--locked --all-features
|
||||
|
||||
cargo run --bin john-slop -- path/to/document path/to/source-directory
|
||||
cargo run --bin john-slop -- --output miette path/to/document
|
||||
cargo run --bin john-slop-fmt -- path/to/document
|
||||
cargo run --bin john-slop-fmt -- --check path/to/document
|
||||
cargo run --bin john-slop-lsp
|
||||
|
|
@ -43,6 +42,10 @@ Formatter file mode prints transformed text without modifying the source. Use
|
|||
`--write` explicitly for atomic in-place replacement, or pipe editor buffers
|
||||
through `john-slop-fmt` over stdin/stdout.
|
||||
|
||||
The detector defaults to colored graphical Miette diagnostics. Select
|
||||
`--output human`, `--output concise`, or `--output json` for uncolored plain or
|
||||
machine-readable output.
|
||||
|
||||
Editors start `john-slop-lsp` over stdio. It tracks open snapshots with full
|
||||
document synchronization, reports configured ASCII replacements, and offers
|
||||
quick fixes whose result matches the formatter. See the editor guide for Helix
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ cargo audit --deny warnings
|
|||
cargo deny --locked check
|
||||
```
|
||||
|
||||
The default `fancy-diagnostics` feature enables `miette`'s rich terminal
|
||||
renderer. The no-default-features test run ensures the shared library and all
|
||||
binaries remain valid without that optional renderer. Focused unit and
|
||||
integration tests cover domain invariants, input failures, archives, CLI exit
|
||||
behavior, and feature configurations.
|
||||
The default `fancy-diagnostics` feature enables the detector's colored Miette
|
||||
renderer and default output mode. The no-default-features test run ensures the
|
||||
shared library and all binaries remain valid with the plain fallback. Focused
|
||||
unit and integration tests cover domain invariants, input failures, archives,
|
||||
CLI exit behavior, and feature configurations.
|
||||
|
||||
CI runs the executable fixture manifest and Insta CLI snapshots explicitly in
|
||||
addition to the full suite. `cargo-audit` rejects RustSec advisories and yanked
|
||||
|
|
|
|||
|
|
@ -7,19 +7,20 @@ container, and findings are sorted by byte span and rule ID.
|
|||
|
||||
## Human
|
||||
|
||||
`--output human` is the default. Every finding is rendered as a plain
|
||||
`miette` diagnostic with the source name, exact excerpt and primary span,
|
||||
severity, stable rule code, message, and remediation help. A final line per
|
||||
document reports the confidence score/band and advice, warning, and error
|
||||
counts. The narratable renderer deliberately avoids ANSI escapes.
|
||||
`--output human` renders every finding as a plain `miette` diagnostic with the
|
||||
source name, exact excerpt and primary span, severity, stable rule code,
|
||||
message, and remediation help. A final line per document reports the confidence
|
||||
score/band and advice, warning, and error counts. The narratable renderer
|
||||
deliberately avoids ANSI escapes.
|
||||
|
||||
## Miette
|
||||
|
||||
`--output miette` renders the same typed diagnostics with Miette's graphical
|
||||
Unicode source annotations and a deterministic no-color theme, followed by the
|
||||
same 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.
|
||||
`--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`
|
||||
accept the option but fall back to the plain human renderer. Select `human`,
|
||||
`concise`, or `json` when ANSI escapes are not appropriate.
|
||||
|
||||
## Concise
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ limits can be overridden with `--max-document-bytes`, `--max-archive-bytes`,
|
|||
`--max-compression-ratio`, and `--max-walk-depth`.
|
||||
|
||||
Select output with `--output human`, `--output miette`, `--output concise`, or
|
||||
`--output json`. Human mode renders plain source excerpts, exact labels,
|
||||
remediation help, and a summary. Miette mode uses Unicode graphical source
|
||||
annotations when the default `fancy-diagnostics` feature is enabled and falls
|
||||
back to human mode without that feature. Concise mode emits stable single-line
|
||||
finding and summary records. JSON mode emits one object per analyzed document
|
||||
with `schema_version: 1`, summary fields, exact byte spans, and every finding.
|
||||
Machine modes never emit ANSI escapes or logs on stdout.
|
||||
`--output json`. Miette is the default and uses colored Unicode graphical source
|
||||
annotations when the default `fancy-diagnostics` feature is enabled; 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
|
||||
per analyzed document with `schema_version: 1`, summary fields, exact byte spans,
|
||||
and every finding. Machine modes never emit ANSI escapes or logs on stdout.
|
||||
|
||||
Findings cover the embedded or overridden heuristic catalog and retain exact
|
||||
UTF-8 byte spans through every output mode. See [Output contracts](output.md)
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ struct Cli {
|
|||
#[arg(long, value_name = "GLOB", action = clap::ArgAction::Append)]
|
||||
ignore: Vec<String>,
|
||||
|
||||
/// Select plain human, graphical Miette, concise, or versioned JSON output.
|
||||
/// Select colored graphical Miette, plain human, concise, or versioned JSON output.
|
||||
#[arg(
|
||||
long,
|
||||
value_enum,
|
||||
|
|
@ -340,6 +340,7 @@ mod tests {
|
|||
|
||||
assert_eq!(cli.fail_confidence, 42);
|
||||
assert_eq!(cli.fail_level, None);
|
||||
assert_eq!(cli.output, OutputFormat::Miette);
|
||||
assert_eq!(cli.config_name, None);
|
||||
assert!(cli.command.is_none());
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ use serde::Serialize;
|
|||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum)]
|
||||
pub enum OutputFormat {
|
||||
/// Plain source-highlighted diagnostics followed by a document summary.
|
||||
#[default]
|
||||
Human,
|
||||
/// Graphical Unicode diagnostics (falls back to plain output without the fancy feature).
|
||||
/// Colored graphical Unicode diagnostics (plain fallback without the fancy feature).
|
||||
#[default]
|
||||
Miette,
|
||||
/// One stable single-line record per finding plus one summary record.
|
||||
Concise,
|
||||
|
|
@ -79,7 +79,7 @@ fn render_human(source_id: &SourceId, source: &str, analysis: &Analysis) -> Stri
|
|||
#[cfg(feature = "fancy-diagnostics")]
|
||||
fn render_miette(source_id: &SourceId, source: &str, analysis: &Analysis) -> String {
|
||||
let mut rendered = String::new();
|
||||
let handler = GraphicalReportHandler::new_themed(GraphicalTheme::unicode_nocolor())
|
||||
let handler = GraphicalReportHandler::new_themed(GraphicalTheme::unicode())
|
||||
.without_cause_chain()
|
||||
.with_links(false);
|
||||
for finding in &analysis.findings {
|
||||
|
|
@ -281,6 +281,22 @@ mod tests {
|
|||
assert!(!output.contains('\u{1b}'));
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "fancy-diagnostics"))]
|
||||
#[test]
|
||||
fn miette_output_falls_back_to_plain_human_without_the_feature() {
|
||||
let (source, analysis) = analysis();
|
||||
let output = render_analysis(
|
||||
OutputFormat::Miette,
|
||||
&SourceId::File("article.md".into()),
|
||||
&source,
|
||||
&analysis,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(output.contains("article.md"));
|
||||
assert!(!output.contains('\u{1b}'));
|
||||
}
|
||||
|
||||
#[cfg(feature = "fancy-diagnostics")]
|
||||
#[test]
|
||||
fn miette_output_has_graphical_source_labels_and_summary() {
|
||||
|
|
@ -294,11 +310,12 @@ mod tests {
|
|||
.unwrap();
|
||||
|
||||
assert!(output.contains("typography-non-ascii-hyphen"));
|
||||
assert!(output.contains("╭─[article.md:"));
|
||||
assert!(output.contains("╰────"));
|
||||
assert!(output.contains("article.md"));
|
||||
assert!(output.contains('╭'));
|
||||
assert!(output.contains('╰'));
|
||||
assert!(output.contains("help:"));
|
||||
assert!(output.contains("confidence"));
|
||||
assert!(!output.contains('\u{1b}'));
|
||||
assert!(output.contains('\u{1b}'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
9
tasks.md
9
tasks.md
|
|
@ -260,6 +260,15 @@ raised to 90%. Remaining misses are primarily hard-to-inject OS/I/O failures,
|
|||
malformed dependency internals, overflow guards, and asynchronous LSP error
|
||||
plumbing; pursuing them would add test-only seams or backend-sensitive checks.
|
||||
|
||||
## Milestone 9 — Terminal-first diagnostics
|
||||
|
||||
- [x] Make colored graphical Miette diagnostics the detector default while
|
||||
retaining explicit plain-human, concise, JSON, and no-feature fallback modes.
|
||||
|
||||
Acceptance: a default detector invocation renders graphical Unicode diagnostics
|
||||
with ANSI severity colors; explicit machine modes remain stable and uncolored,
|
||||
and builds without `fancy-diagnostics` retain the plain human fallback.
|
||||
|
||||
## Deferred by design
|
||||
|
||||
- Statistical or model-based authorship classification.
|
||||
|
|
|
|||
17
tests/cli.rs
17
tests/cli.rs
|
|
@ -58,6 +58,23 @@ fn invalid_confidence_is_a_usage_error() {
|
|||
insta::assert_snapshot!(String::from_utf8(output.stderr).expect("UTF-8 stderr"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_output_is_colored_graphical_miette_with_a_plain_feature_fallback() {
|
||||
let output = detector_with_stdin(&["--stdin"], "suspicious—dash".as_bytes());
|
||||
let stdout = String::from_utf8(output.stdout).expect("UTF-8 detector output");
|
||||
|
||||
assert!(output.status.success());
|
||||
assert!(output.stderr.is_empty());
|
||||
assert!(stdout.contains("typography-non-ascii-hyphen"));
|
||||
#[cfg(feature = "fancy-diagnostics")]
|
||||
{
|
||||
assert!(stdout.contains('\u{1b}'));
|
||||
assert!(stdout.contains('╭'));
|
||||
}
|
||||
#[cfg(not(feature = "fancy-diagnostics"))]
|
||||
assert!(!stdout.contains('\u{1b}'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn findings_control_the_threshold_exit_code() {
|
||||
let directory = tempdir().expect("temp dir");
|
||||
|
|
|
|||
|
|
@ -163,7 +163,10 @@ fn diagnostic_showcase_is_an_expected_threshold_failure() {
|
|||
assert!(stdout.contains("warning"));
|
||||
assert!(stdout.contains("error"));
|
||||
#[cfg(feature = "fancy-diagnostics")]
|
||||
assert!(stdout.contains("╭─["));
|
||||
{
|
||||
assert!(stdout.contains('\u{1b}'));
|
||||
assert!(stdout.contains('╭'));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: tests/cli.rs
|
||||
assertion_line: 18
|
||||
expression: "String::from_utf8(output.stdout).expect(\"UTF-8 stdout\")"
|
||||
---
|
||||
Inspect files, directories, or ZIP-based documents for low-care signals
|
||||
|
|
@ -39,7 +38,7 @@ Options:
|
|||
--ignore <GLOB>
|
||||
Skip source paths matching a glob; may be supplied more than once
|
||||
--output <human|miette|concise|json>
|
||||
Select plain human, graphical Miette, concise, or versioned JSON output [default: human]
|
||||
Select colored graphical Miette, plain human, concise, or versioned JSON output [default: miette]
|
||||
--fail-confidence <FAIL_CONFIDENCE>
|
||||
Return exit code 1 when a document reaches this evidence-confidence score [default: 100]
|
||||
--fail-level <FAIL_LEVEL>
|
||||
|
|
|
|||
Loading…
Reference in New Issue