Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions crates/squawk/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ fn render_lint_error<W: std::io::Write>(

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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
Loading