Skip to content

Commit 0f406ec

Browse files
authored
linter: remove prefer-big-int (#449)
it's been deprecated for a while also fix the playground, wasm -> squawk_wasm it was referencing the old builds
1 parent a1dc69a commit 0f406ec

18 files changed

+90
-311
lines changed

crates/cli/src/reporter.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,9 @@ SELECT 1;
376376
assert_snapshot!(String::from_utf8_lossy(&buff), @r###"
377377
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.
378378
main.sql:1:29: warning: prefer-robust-stmts Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.
379-
main.sql:1:46: warning: prefer-big-int Using 32-bit integer fields can result in hitting the max `int` limit.
380379
main.sql:1:46: warning: prefer-bigint-over-int Using 32-bit integer fields can result in hitting the max `int` limit.
381380
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.
382381
main.sql:2:23: warning: prefer-robust-stmts Missing `IF NOT EXISTS`, the migration can't be rerun if it fails part way through.
383-
main.sql:2:40: warning: prefer-big-int Using 32-bit integer fields can result in hitting the max `int` limit.
384382
main.sql:2:40: warning: prefer-bigint-over-int Using 32-bit integer fields can result in hitting the max `int` limit.
385383
"###);
386384
}
@@ -438,7 +436,7 @@ SELECT 1;
438436
);
439437

440438
assert!(res.is_ok());
441-
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"}]"###);
439+
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"}]"###);
442440
}
443441

444442
#[test]

crates/cli/src/snapshots/squawk__reporter__test_reporter__display_violations_tty.snap

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ warning[prefer-robust-stmts]: Missing `IF NOT EXISTS`, the migration can't be re
1515
2 | ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717
|
18-
warning[prefer-big-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
19-
--> main.sql:2:47
20-
|
21-
2 | ALTER TABLE "core_recipe" ADD COLUMN "foo" integer NOT NULL;
22-
| ^^^^^^^
23-
|
24-
= help: Use 64-bit integer values instead to prevent hitting this limit.
2518
warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
2619
--> main.sql:2:47
2720
|
@@ -42,13 +35,6 @@ warning[prefer-robust-stmts]: Missing `IF NOT EXISTS`, the migration can't be re
4235
3 | ALTER TABLE "core_foo" ADD COLUMN "bar" integer NOT NULL;
4336
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4437
|
45-
warning[prefer-big-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
46-
--> main.sql:3:41
47-
|
48-
3 | ALTER TABLE "core_foo" ADD COLUMN "bar" integer NOT NULL;
49-
| ^^^^^^^
50-
|
51-
= help: Use 64-bit integer values instead to prevent hitting this limit.
5238
warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitting the max `int` limit.
5339
--> main.sql:3:41
5440
|
@@ -58,4 +44,4 @@ warning[prefer-bigint-over-int]: Using 32-bit integer fields can result in hitti
5844
= help: Use 64-bit integer values instead to prevent hitting this limit.
5945

6046
Find detailed examples and solutions for each rule at https://squawkhq.com/docs/rules
61-
Found 8 issues in 1 file (checked 1 source file)
47+
Found 6 issues in 1 file (checked 1 source file)

crates/cli/src/snapshots/squawk__reporter__test_reporter__span_offsets.snap

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ CheckReport {
2828
help: None,
2929
rule_name: "prefer-robust-stmts",
3030
},
31-
ReportViolation {
32-
file: "main.sql",
33-
line: 2,
34-
column: 46,
35-
range: 48..55,
36-
level: Warning,
37-
message: "Using 32-bit integer fields can result in hitting the max `int` limit.",
38-
help: Some(
39-
"Use 64-bit integer values instead to prevent hitting this limit.",
40-
),
41-
rule_name: "prefer-big-int",
42-
},
4331
ReportViolation {
4432
file: "main.sql",
4533
line: 2,
@@ -74,18 +62,6 @@ CheckReport {
7462
help: None,
7563
rule_name: "prefer-robust-stmts",
7664
},
77-
ReportViolation {
78-
file: "main.sql",
79-
line: 3,
80-
column: 40,
81-
range: 106..113,
82-
level: Warning,
83-
message: "Using 32-bit integer fields can result in hitting the max `int` limit.",
84-
help: Some(
85-
"Use 64-bit integer values instead to prevent hitting this limit.",
86-
),
87-
rule_name: "prefer-big-int",
88-
},
8965
ReportViolation {
9066
file: "main.sql",
9167
line: 3,

crates/squawk_linter/src/lib.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub use version::Version;
1717
mod ignore;
1818
mod ignore_index;
1919
mod version;
20+
mod visitors;
2021

2122
mod rules;
2223
mod text;
@@ -36,7 +37,6 @@ use rules::ban_drop_table;
3637
use rules::changing_column_type;
3738
use rules::constraint_missing_not_valid;
3839
use rules::disallow_unique_constraint;
39-
use rules::prefer_big_int;
4040
use rules::prefer_bigint_over_int;
4141
use rules::prefer_bigint_over_smallint;
4242
use rules::prefer_identity;
@@ -75,8 +75,6 @@ pub enum Rule {
7575
DisallowedUniqueConstraint,
7676
#[serde(rename = "ban-drop-database")]
7777
BanDropDatabase,
78-
#[serde(rename = "prefer-big-int")]
79-
PreferBigInt,
8078
#[serde(rename = "prefer-bigint-over-int")]
8179
PreferBigintOverInt,
8280
#[serde(rename = "prefer-bigint-over-smallint")]
@@ -129,7 +127,6 @@ impl TryFrom<&str> for Rule {
129127
"renaming-table" => Ok(Rule::RenamingTable),
130128
"disallowed-unique-constraint" => Ok(Rule::DisallowedUniqueConstraint),
131129
"ban-drop-database" => Ok(Rule::BanDropDatabase),
132-
"prefer-big-int" => Ok(Rule::PreferBigInt),
133130
"prefer-bigint-over-int" => Ok(Rule::PreferBigintOverInt),
134131
"prefer-bigint-over-smallint" => Ok(Rule::PreferBigintOverSmallint),
135132
"prefer-identity" => Ok(Rule::PreferIdentity),
@@ -186,7 +183,6 @@ impl fmt::Display for Rule {
186183
Rule::RenamingTable => "renaming-table",
187184
Rule::DisallowedUniqueConstraint => "disallowed-unique-constraint",
188185
Rule::BanDropDatabase => "ban-drop-database",
189-
Rule::PreferBigInt => "prefer-big-int",
190186
Rule::PreferBigintOverInt => "prefer-bigint-over-int",
191187
Rule::PreferBigintOverSmallint => "prefer-bigint-over-smallint",
192188
Rule::PreferIdentity => "prefer-identity",
@@ -308,9 +304,6 @@ impl Linter {
308304
if self.rules.contains(&Rule::DisallowedUniqueConstraint) {
309305
disallow_unique_constraint(self, &file);
310306
}
311-
if self.rules.contains(&Rule::PreferBigInt) {
312-
prefer_big_int(self, &file);
313-
}
314307
if self.rules.contains(&Rule::PreferBigintOverInt) {
315308
prefer_bigint_over_int(self, &file);
316309
}

crates/squawk_linter/src/rules/ban_char_field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use squawk_syntax::{
33
Parse, SourceFile, TokenText,
44
};
55

6-
use crate::prefer_big_int::check_not_allowed_types;
6+
use crate::visitors::check_not_allowed_types;
77
use crate::{Linter, Rule, Violation};
88

99
fn is_char_type(x: TokenText<'_>) -> bool {

crates/squawk_linter/src/rules/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub(crate) mod ban_drop_table;
1414
pub(crate) mod changing_column_type;
1515
pub(crate) mod constraint_missing_not_valid;
1616
pub(crate) mod disallow_unique_constraint;
17-
pub(crate) mod prefer_big_int;
1817
pub(crate) mod prefer_bigint_over_int;
1918
pub(crate) mod prefer_bigint_over_smallint;
2019
pub(crate) mod prefer_identity;
@@ -43,7 +42,6 @@ pub(crate) use ban_drop_table::ban_drop_table;
4342
pub(crate) use changing_column_type::changing_column_type;
4443
pub(crate) use constraint_missing_not_valid::constraint_missing_not_valid;
4544
pub(crate) use disallow_unique_constraint::disallow_unique_constraint;
46-
pub(crate) use prefer_big_int::prefer_big_int;
4745
pub(crate) use prefer_bigint_over_int::prefer_bigint_over_int;
4846
pub(crate) use prefer_bigint_over_smallint::prefer_bigint_over_smallint;
4947
pub(crate) use prefer_identity::prefer_identity;

0 commit comments

Comments
 (0)