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
4 changes: 1 addition & 3 deletions crates/cli/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,9 @@ SELECT 1;
assert_snapshot!(String::from_utf8_lossy(&buff), @r###"
main.sql:1:29: 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:1:29: warning: prefer-robust-stmts Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.
main.sql:1:46: warning: prefer-big-int Using 32-bit integer fields can result in hitting the max `int` limit.
main.sql:1:46: warning: prefer-bigint-over-int Using 32-bit integer fields can result in hitting the max `int` limit.
main.sql:2:23: 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:23: warning: prefer-robust-stmts Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.
main.sql:2:40: warning: prefer-big-int Using 32-bit integer fields can result in hitting the max `int` limit.
main.sql:2:40: warning: prefer-bigint-over-int Using 32-bit integer fields can result in hitting the max `int` limit.
"###);
}
Expand Down Expand Up @@ -438,7 +436,7 @@ SELECT 1;
);

assert!(res.is_ok());
assert_snapshot!(String::from_utf8_lossy(&buff), @r###"[{"file":"main.sql","line":1,"column":29,"level":"Warning","message":"Adding a new column that is `NOT NULL` and has no default value to an existing table effectively makes it required.","help":"Make the field nullable or add a non-VOLATILE DEFAULT","rule_name":"adding-required-field"},{"file":"main.sql","line":1,"column":29,"level":"Warning","message":"Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.","help":null,"rule_name":"prefer-robust-stmts"},{"file":"main.sql","line":1,"column":46,"level":"Warning","message":"Using 32-bit integer fields can result in hitting the max `int` limit.","help":"Use 64-bit integer values instead to prevent hitting this limit.","rule_name":"prefer-big-int"},{"file":"main.sql","line":1,"column":46,"level":"Warning","message":"Using 32-bit integer fields can result in hitting the max `int` limit.","help":"Use 64-bit integer values instead to prevent hitting this limit.","rule_name":"prefer-bigint-over-int"},{"file":"main.sql","line":2,"column":23,"level":"Warning","message":"Adding a new column that is `NOT NULL` and has no default value to an existing table effectively makes it required.","help":"Make the field nullable or add a non-VOLATILE DEFAULT","rule_name":"adding-required-field"},{"file":"main.sql","line":2,"column":23,"level":"Warning","message":"Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.","help":null,"rule_name":"prefer-robust-stmts"},{"file":"main.sql","line":2,"column":40,"level":"Warning","message":"Using 32-bit integer fields can result in hitting the max `int` limit.","help":"Use 64-bit integer values instead to prevent hitting this limit.","rule_name":"prefer-big-int"},{"file":"main.sql","line":2,"column":40,"level":"Warning","message":"Using 32-bit integer fields can result in hitting the max `int` limit.","help":"Use 64-bit integer values instead to prevent hitting this limit.","rule_name":"prefer-bigint-over-int"}]"###);
assert_snapshot!(String::from_utf8_lossy(&buff), @r###"[{"file":"main.sql","line":1,"column":29,"level":"Warning","message":"Adding a new column that is `NOT NULL` and has no default value to an existing table effectively makes it required.","help":"Make the field nullable or add a non-VOLATILE DEFAULT","rule_name":"adding-required-field"},{"file":"main.sql","line":1,"column":29,"level":"Warning","message":"Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.","help":null,"rule_name":"prefer-robust-stmts"},{"file":"main.sql","line":1,"column":46,"level":"Warning","message":"Using 32-bit integer fields can result in hitting the max `int` limit.","help":"Use 64-bit integer values instead to prevent hitting this limit.","rule_name":"prefer-bigint-over-int"},{"file":"main.sql","line":2,"column":23,"level":"Warning","message":"Adding a new column that is `NOT NULL` and has no default value to an existing table effectively makes it required.","help":"Make the field nullable or add a non-VOLATILE DEFAULT","rule_name":"adding-required-field"},{"file":"main.sql","line":2,"column":23,"level":"Warning","message":"Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.","help":null,"rule_name":"prefer-robust-stmts"},{"file":"main.sql","line":2,"column":40,"level":"Warning","message":"Using 32-bit integer fields can result in hitting the max `int` limit.","help":"Use 64-bit integer values instead to prevent hitting this limit.","rule_name":"prefer-bigint-over-int"}]"###);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ warning[prefer-robust-stmts]: Missing `IF NOT EXISTS`, the migration can't be re
2 | ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
warning[prefer-big-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[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
--> main.sql:2:47
|
Expand All @@ -42,13 +35,6 @@ warning[prefer-robust-stmts]: Missing `IF NOT EXISTS`, the migration can't be re
3 | ALTER TABLE "core_foo" ADD COLUMN "bar" integer NOT NULL;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
warning[prefer-big-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.
warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
--> main.sql:3:41
|
Expand All @@ -58,4 +44,4 @@ warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitti
= help: Use 64-bit integer values instead to prevent hitting this limit.

Find detailed examples and solutions for each rule at https://squawkhq.com/docs/rules
Found 8 issues in 1 file (checked 1 source file)
Found 6 issues in 1 file (checked 1 source file)
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ CheckReport {
help: None,
rule_name: "prefer-robust-stmts",
},
ReportViolation {
file: "main.sql",
line: 2,
column: 46,
range: 48..55,
level: Warning,
message: "Using 32-bit integer fields can result in hitting the max `int` limit.",
help: Some(
"Use 64-bit integer values instead to prevent hitting this limit.",
),
rule_name: "prefer-big-int",
},
ReportViolation {
file: "main.sql",
line: 2,
Expand Down Expand Up @@ -74,18 +62,6 @@ CheckReport {
help: None,
rule_name: "prefer-robust-stmts",
},
ReportViolation {
file: "main.sql",
line: 3,
column: 40,
range: 106..113,
level: Warning,
message: "Using 32-bit integer fields can result in hitting the max `int` limit.",
help: Some(
"Use 64-bit integer values instead to prevent hitting this limit.",
),
rule_name: "prefer-big-int",
},
ReportViolation {
file: "main.sql",
line: 3,
Expand Down
9 changes: 1 addition & 8 deletions crates/squawk_linter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub use version::Version;
mod ignore;
mod ignore_index;
mod version;
mod visitors;

mod rules;
mod text;
Expand All @@ -36,7 +37,6 @@ use rules::ban_drop_table;
use rules::changing_column_type;
use rules::constraint_missing_not_valid;
use rules::disallow_unique_constraint;
use rules::prefer_big_int;
use rules::prefer_bigint_over_int;
use rules::prefer_bigint_over_smallint;
use rules::prefer_identity;
Expand Down Expand Up @@ -75,8 +75,6 @@ pub enum Rule {
DisallowedUniqueConstraint,
#[serde(rename = "ban-drop-database")]
BanDropDatabase,
#[serde(rename = "prefer-big-int")]
PreferBigInt,
#[serde(rename = "prefer-bigint-over-int")]
PreferBigintOverInt,
#[serde(rename = "prefer-bigint-over-smallint")]
Expand Down Expand Up @@ -129,7 +127,6 @@ impl TryFrom<&str> for Rule {
"renaming-table" => Ok(Rule::RenamingTable),
"disallowed-unique-constraint" => Ok(Rule::DisallowedUniqueConstraint),
"ban-drop-database" => Ok(Rule::BanDropDatabase),
"prefer-big-int" => Ok(Rule::PreferBigInt),
"prefer-bigint-over-int" => Ok(Rule::PreferBigintOverInt),
"prefer-bigint-over-smallint" => Ok(Rule::PreferBigintOverSmallint),
"prefer-identity" => Ok(Rule::PreferIdentity),
Expand Down Expand Up @@ -186,7 +183,6 @@ impl fmt::Display for Rule {
Rule::RenamingTable => "renaming-table",
Rule::DisallowedUniqueConstraint => "disallowed-unique-constraint",
Rule::BanDropDatabase => "ban-drop-database",
Rule::PreferBigInt => "prefer-big-int",
Rule::PreferBigintOverInt => "prefer-bigint-over-int",
Rule::PreferBigintOverSmallint => "prefer-bigint-over-smallint",
Rule::PreferIdentity => "prefer-identity",
Expand Down Expand Up @@ -308,9 +304,6 @@ impl Linter {
if self.rules.contains(&Rule::DisallowedUniqueConstraint) {
disallow_unique_constraint(self, &file);
}
if self.rules.contains(&Rule::PreferBigInt) {
prefer_big_int(self, &file);
}
if self.rules.contains(&Rule::PreferBigintOverInt) {
prefer_bigint_over_int(self, &file);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/squawk_linter/src/rules/ban_char_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use squawk_syntax::{
Parse, SourceFile, TokenText,
};

use crate::prefer_big_int::check_not_allowed_types;
use crate::visitors::check_not_allowed_types;
use crate::{Linter, Rule, Violation};

fn is_char_type(x: TokenText<'_>) -> bool {
Expand Down
2 changes: 0 additions & 2 deletions crates/squawk_linter/src/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub(crate) mod ban_drop_table;
pub(crate) mod changing_column_type;
pub(crate) mod constraint_missing_not_valid;
pub(crate) mod disallow_unique_constraint;
pub(crate) mod prefer_big_int;
pub(crate) mod prefer_bigint_over_int;
pub(crate) mod prefer_bigint_over_smallint;
pub(crate) mod prefer_identity;
Expand Down Expand Up @@ -43,7 +42,6 @@ pub(crate) use ban_drop_table::ban_drop_table;
pub(crate) use changing_column_type::changing_column_type;
pub(crate) use constraint_missing_not_valid::constraint_missing_not_valid;
pub(crate) use disallow_unique_constraint::disallow_unique_constraint;
pub(crate) use prefer_big_int::prefer_big_int;
pub(crate) use prefer_bigint_over_int::prefer_bigint_over_int;
pub(crate) use prefer_bigint_over_smallint::prefer_bigint_over_smallint;
pub(crate) use prefer_identity::prefer_identity;
Expand Down
Loading
Loading