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
23 changes: 12 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ wasm-bindgen-test = "0.3.50"
web-sys = "0.3.91"
console_error_panic_hook = "0.1.7"
console_log = "1.0.0"
annotate-snippets = "0.12.4"
annotate-snippets = "0.12.16"
anyhow = "1.0.94"
either = "1.15.0"
convert_case = "0.7.1"
Expand Down
2 changes: 2 additions & 0 deletions crates/squawk/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ fn render_lint_error<W: std::io::Write>(
.fold(true)
.annotation(AnnotationKind::Primary.span(err.range.into()));

let rule_url = format!("https://squawkhq.com/docs/{}", err.rule_name);
let mut group = level
.primary_title(&err.message)
.id(&err.rule_name)
.id_url(&rule_url)
.element(snippet);

if let Some(help) = &err.help {
Expand Down
16 changes: 8 additions & 8 deletions crates/squawk/src/snapshots/example.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SELECT 1;


```
warning[adding-not-nullable-field]: Adding a NOT NULL field requires exclusive locks and table rewrites.
warning[]8;;https://squawkhq.com/docs/adding-not-nullable-field\adding-not-nullable-field]8;;\]: Adding a NOT NULL field requires exclusive locks and table rewrites.
╭▸ alpha.sql:1:8
1 │ SELECT 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/squawk/src/reporter.rs
expression: "strip_ansi_codes(&String::from_utf8_lossy(&buff))"
---
warning[require-timeout-settings]: Missing `set lock_timeout` before potentially slow operations
warning[]8;;https://squawkhq.com/docs/require-timeout-settings\require-timeout-settings]8;;\]: Missing `set lock_timeout` before potentially slow operations
╭▸ main.sql:2:4
2 │ ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
Expand All @@ -12,7 +12,7 @@ warning[require-timeout-settings]: Missing `set lock_timeout` before potentially
╭╴
2 + set lock_timeout = '1s';
╰╴
warning[require-timeout-settings]: Missing `set statement_timeout` before potentially slow operations
warning[]8;;https://squawkhq.com/docs/require-timeout-settings\require-timeout-settings]8;;\]: Missing `set statement_timeout` before potentially slow operations
╭▸ main.sql:2:4
2 │ ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
Expand All @@ -22,22 +22,22 @@ warning[require-timeout-settings]: Missing `set statement_timeout` before potent
╭╴
2 + set statement_timeout = '5s';
╰╴
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.
warning[]8;;https://squawkhq.com/docs/adding-required-field\adding-required-field]8;;\]: 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.
warning[]8;;https://squawkhq.com/docs/prefer-robust-stmts\prefer-robust-stmts]8;;\]: 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;
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╭╴
2 │ ALTER TABLE "core_recipe" ADD COLUMN if not exists "foo" integer NOT NULL;
╰╴ +++++++++++++
warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
warning[]8;;https://squawkhq.com/docs/prefer-bigint-over-int\prefer-bigint-over-int]8;;\]: 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;
Expand All @@ -48,22 +48,22 @@ warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitti
2 - ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
2 + ALTER TABLE "core_recipe" ADD COLUMN "foo" bigint NOT NULL;
╰╴
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.
warning[]8;;https://squawkhq.com/docs/adding-required-field\adding-required-field]8;;\]: 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.
warning[]8;;https://squawkhq.com/docs/prefer-robust-stmts\prefer-robust-stmts]8;;\]: 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;
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╭╴
3 │ ALTER TABLE "core_foo" ADD COLUMN if not exists "bar" integer NOT NULL;
╰╴ +++++++++++++
warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
warning[]8;;https://squawkhq.com/docs/prefer-bigint-over-int\prefer-bigint-over-int]8;;\]: 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ expression: "strip_ansi_codes(&String::from_utf8_lossy(&buff))"
::warning file=main.sql,line=5,col=2,endLine=6,endColumn=20,title=adding-required-field::Adding a new column that is `NOT NULL` and has no default value to an existing table effectively makes it required.
::warning file=main.sql,line=5,col=2,endLine=6,endColumn=20,title=prefer-robust-stmts::Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.
::warning file=main.sql,line=6,col=4,endLine=6,endColumn=11,title=prefer-bigint-over-int::Using 32-bit integer fields can result in hitting the max `int` limit.
warning[require-timeout-settings]: Missing `set lock_timeout` before potentially slow operations
warning[]8;;https://squawkhq.com/docs/require-timeout-settings\require-timeout-settings]8;;\]: Missing `set lock_timeout` before potentially slow operations
╭▸ main.sql:2:4
2 │ ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
Expand All @@ -20,7 +20,7 @@ warning[require-timeout-settings]: Missing `set lock_timeout` before potentially
╭╴
2 + set lock_timeout = '1s';
╰╴
warning[require-timeout-settings]: Missing `set statement_timeout` before potentially slow operations
warning[]8;;https://squawkhq.com/docs/require-timeout-settings\require-timeout-settings]8;;\]: Missing `set statement_timeout` before potentially slow operations
╭▸ main.sql:2:4
2 │ ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
Expand All @@ -30,22 +30,22 @@ warning[require-timeout-settings]: Missing `set statement_timeout` before potent
╭╴
2 + set statement_timeout = '5s';
╰╴
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.
warning[]8;;https://squawkhq.com/docs/adding-required-field\adding-required-field]8;;\]: 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.
warning[]8;;https://squawkhq.com/docs/prefer-robust-stmts\prefer-robust-stmts]8;;\]: 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;
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
╭╴
2 │ ALTER TABLE "core_recipe" ADD COLUMN if not exists "foo" integer NOT NULL;
╰╴ +++++++++++++
warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
warning[]8;;https://squawkhq.com/docs/prefer-bigint-over-int\prefer-bigint-over-int]8;;\]: 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;
Expand All @@ -56,15 +56,15 @@ warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitti
2 - ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
2 + ALTER TABLE "core_recipe" ADD COLUMN "foo" bigint NOT NULL;
╰╴
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.
warning[]8;;https://squawkhq.com/docs/adding-required-field\adding-required-field]8;;\]: Adding a new column that is `NOT NULL` and has no default value to an existing table effectively makes it required.
╭▸ main.sql:5:3
5 │ ┏ ADD COLUMN "bar"
6 │ ┃ 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.
warning[]8;;https://squawkhq.com/docs/prefer-robust-stmts\prefer-robust-stmts]8;;\]: Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.
╭▸ main.sql:5:3
5 │ ┏ ADD COLUMN "bar"
Expand All @@ -73,7 +73,7 @@ warning[prefer-robust-stmts]: Missing `IF NOT EXISTS`, the migration can't be re
╭╴
5 │ ADD COLUMN if not exists "bar"
╰╴ +++++++++++++
warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
warning[]8;;https://squawkhq.com/docs/prefer-bigint-over-int\prefer-bigint-over-int]8;;\]: Using 32-bit integer fields can result in hitting the max `int` limit.
╭▸ main.sql:6:5
6 │ integer NOT NULL;
Expand Down
Loading
Loading