From 7a6a34a7983b109c3cec368ae3c3a6222e027736 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sun, 25 May 2025 18:40:44 -0400 Subject: [PATCH 1/3] cli: display syntax errors as errors, not warnings --- crates/squawk/src/debug.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/squawk/src/debug.rs b/crates/squawk/src/debug.rs index 5c34442a..a2104232 100644 --- a/crates/squawk/src/debug.rs +++ b/crates/squawk/src/debug.rs @@ -86,7 +86,7 @@ fn render_syntax_errors( for err in errors { let text = err.message(); let span = err.range().into(); - let message = Level::Warning.title(text).id("syntax-error").snippet( + let message = Level::Error.title(text).id("syntax-error").snippet( Snippet::source(sql) .origin(filename) .fold(true) From 1863f60b4ae0671b53eb69b195410ea438ca40b9 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sun, 25 May 2025 18:45:21 -0400 Subject: [PATCH 2/3] fix reporter --- crates/squawk/src/reporter.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/squawk/src/reporter.rs b/crates/squawk/src/reporter.rs index a85fddf8..10ab444b 100644 --- a/crates/squawk/src/reporter.rs +++ b/crates/squawk/src/reporter.rs @@ -86,11 +86,16 @@ fn render_lint_error( let title = &err.message; - let mut message = Level::Warning.title(title).id(error_name).snippet( + let level = match err.level { + ViolationLevel::Warning => Level::Warning, + ViolationLevel::Error => Level::Error, + }; + + let mut message = level.title(title).id(error_name).snippet( Snippet::source(sql) .origin(filename) .fold(true) - .annotation(Level::Error.span(err.range.into())), + .annotation(level.span(err.range.into())), ); if let Some(help) = &err.help { message = message.footer(Level::Help.title(help)); From a9d1d952f5c0322d673d1883248f2487e05ef0d4 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sun, 25 May 2025 18:50:42 -0400 Subject: [PATCH 3/3] fix snap --- ...ter__test_reporter__display_violations_tty.snap | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/squawk/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap b/crates/squawk/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap index 5acb277d..3ec8bd1a 100644 --- a/crates/squawk/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap +++ b/crates/squawk/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap @@ -1,45 +1,45 @@ --- -source: crates/cli/src/reporter.rs +source: crates/squawk/src/reporter.rs expression: "strip_ansi_codes(&String::from_utf8_lossy(&buff))" --- warning[adding-required-field]: Adding a new column that is `NOT NULL` and has no default value to an existing table effectively makes it required. --> main.sql:2:30 | 2 | ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | --------------------------------- | = help: Make the field nullable or add a non-VOLATILE DEFAULT warning[prefer-robust-stmts]: Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through. --> main.sql:2:30 | 2 | ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | --------------------------------- | warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit. --> main.sql:2:47 | 2 | ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL; - | ^^^^^^^ + | ------- | = help: Use 64-bit integer values instead to prevent hitting this limit. warning[adding-required-field]: Adding a new column that is `NOT NULL` and has no default value to an existing table effectively makes it required. --> main.sql:3:24 | 3 | ALTER TABLE "core_foo" ADD COLUMN "bar" integer NOT NULL; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | --------------------------------- | = help: Make the field nullable or add a non-VOLATILE DEFAULT warning[prefer-robust-stmts]: Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through. --> main.sql:3:24 | 3 | ALTER TABLE "core_foo" ADD COLUMN "bar" integer NOT NULL; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | --------------------------------- | warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit. --> main.sql:3:41 | 3 | ALTER TABLE "core_foo" ADD COLUMN "bar" integer NOT NULL; - | ^^^^^^^ + | ------- | = help: Use 64-bit integer values instead to prevent hitting this limit.