diff --git a/Cargo.lock b/Cargo.lock index ae1bacae..b2c00ea6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,7 +106,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 1.0.109", "which", ] @@ -213,7 +213,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c0994e656bba7b922d8dd1245db90672ffb701e684e45be58f20719d69abc5a" dependencies = [ - "encode_unicode", + "encode_unicode 0.3.6", "lazy_static", "libc", "regex", @@ -224,6 +224,18 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "console" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +dependencies = [ + "encode_unicode 1.0.0", + "libc", + "once_cell", + "windows-sys 0.59.0", +] + [[package]] name = "cookie" version = "0.12.0" @@ -325,12 +337,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "difference" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" - [[package]] name = "dtoa" version = "0.4.8" @@ -349,6 +355,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + [[package]] name = "encoding_rs" version = "0.8.31" @@ -386,7 +398,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] @@ -653,16 +665,13 @@ dependencies = [ [[package]] name = "insta" -version = "0.16.1" +version = "1.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617e921abc813f96a3b00958c079e7bf1e2db998f8a04f1546dd967373a418ee" +checksum = "154934ea70c58054b556dd430b99a98c2a7ff5309ac9891597e339b5c28f4371" dependencies = [ - "console", - "difference", - "lazy_static", - "serde", - "serde_json", - "serde_yaml", + "console 0.15.11", + "once_cell", + "similar", ] [[package]] @@ -730,9 +739,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lazycell" @@ -768,12 +777,6 @@ dependencies = [ "make-cmd", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -791,12 +794,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if 1.0.0", -] +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "make-cmd" @@ -992,9 +992,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.13.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "openssl" @@ -1019,7 +1019,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1119,7 +1119,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1136,9 +1136,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -1461,22 +1461,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.138" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.138" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.101", ] [[package]] @@ -1507,7 +1507,7 @@ checksum = "a2ad84e47328a31223de7fed7a4f5087f2d6ddfe586cf3ca25b7a165bc0a5aed" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1522,24 +1522,18 @@ dependencies = [ "url 1.7.2", ] -[[package]] -name = "serde_yaml" -version = "0.8.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc" -dependencies = [ - "indexmap", - "ryu", - "serde", - "yaml-rust", -] - [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + [[package]] name = "simple_asn1" version = "0.6.2" @@ -1590,7 +1584,7 @@ version = "1.6.1" dependencies = [ "atty", "base64 0.12.3", - "console", + "console 0.11.3", "glob", "insta", "log", @@ -1675,7 +1669,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1689,6 +1683,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -1697,7 +1702,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "unicode-xid", ] @@ -1769,7 +1774,7 @@ checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2115,7 +2120,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -2137,7 +2142,7 @@ checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2356,12 +2361,3 @@ dependencies = [ "winapi 0.2.8", "winapi-build", ] - -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] diff --git a/Cargo.toml b/Cargo.toml index c3df6bc1..bfa13eb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,24 +3,24 @@ members = ["crates/*"] [workspace.dependencies] # third party -serde_json = "1.0" -tempfile = "3.2.0" -serde = { version = "1.0", features = ["derive"] } -structopt = "0.3" -console = "0.11.3" atty = "0.2" base64 = "0.12.2" -simplelog = "0.12.0" -log = "0.4.8" -toml = "0.5.9" +console = "0.11.3" glob = "0.3.1" -insta = "0.16.0" +insta = "1.39.0" jsonwebtoken = "8.1.1" +lazy_static = "1.5.0" +libpg_query-sys = { git = "https://github.com/chdsbd/libpg_query-sys.git", rev = "ac223c7b197459d657d166449ccf99883f23bbcb" } +log = "0.4.25" reqwest = { version = "0.9.18", features = ["default-tls-vendored"]} +serde = { version = "1.0.215", features = ["derive"] } +serde_json = "1.0" serde_plain = "1.0" -lazy_static = "1.4.0" serde_repr = "0.1" -libpg_query-sys = { git = "https://github.com/chdsbd/libpg_query-sys.git", rev = "ac223c7b197459d657d166449ccf99883f23bbcb" } +simplelog = "0.12.0" +structopt = "0.3" +tempfile = "3.2.0" +toml = "0.5.9" # local squawk-parser = { version = "0.0.0", path = "./crates/parser" } diff --git a/crates/cli/src/reporter.rs b/crates/cli/src/reporter.rs index cfe882d3..ff829e15 100644 --- a/crates/cli/src/reporter.rs +++ b/crates/cli/src/reporter.rs @@ -562,7 +562,7 @@ pub fn get_comment_body(files: &[ViolationContent], version: &str) -> String { mod test_github_comment { use super::*; - use insta::assert_display_snapshot; + use insta::assert_snapshot; /// Most cases, hopefully, will be a single migration for a given PR, but /// let's check the case of multiple migrations @@ -593,7 +593,7 @@ SELECT 1; let body = get_comment_body(&violations, "0.2.3"); - assert_display_snapshot!(body); + assert_snapshot!(body); } /// Even when we don't have violations we still want to output the SQL for @@ -628,7 +628,7 @@ ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10; let body = get_comment_body(&violations, "0.2.3"); - assert_display_snapshot!(body); + assert_snapshot!(body); } /// Ideally the logic won't leave a comment when there are no migrations but @@ -639,13 +639,13 @@ ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10; let body = get_comment_body(&violations, "0.2.3"); - assert_display_snapshot!(body); + assert_snapshot!(body); } } #[cfg(test)] mod test_check_files { - use insta::assert_yaml_snapshot; + use insta::assert_snapshot; use serde_json::Value; use crate::reporter::fmt_json; @@ -662,7 +662,7 @@ select \; fmt_json(&mut buff, vec![res]).unwrap(); let val: Value = serde_json::from_slice(&buff).unwrap(); - assert_yaml_snapshot!(val); + assert_snapshot!(val); } } @@ -671,7 +671,7 @@ mod test_reporter { use crate::reporter::{pretty_violations, print_violations, Reporter}; use console::strip_ansi_codes; - use insta::{assert_debug_snapshot, assert_display_snapshot}; + use insta::{assert_debug_snapshot, assert_snapshot}; use squawk_linter::{ check_sql_with_rule, @@ -703,7 +703,7 @@ SELECT 1; ); assert!(res.is_ok()); - assert_display_snapshot!(String::from_utf8_lossy(&buff), @r" + assert_snapshot!(String::from_utf8_lossy(&buff), @r" main.sql:1:0: warning: adding-required-field Adding a NOT NULL field without a DEFAULT will fail for a populated table. Make the field nullable or add a non-VOLATILE DEFAULT (Postgres 11+). main.sql:3:1: warning: adding-required-field Adding a NOT NULL field without a DEFAULT will fail for a populated table. Make the field nullable or add a non-VOLATILE DEFAULT (Postgres 11+). "); @@ -728,7 +728,7 @@ SELECT 1; assert!(res.is_ok()); // remove the color codes so tests behave in CI as they do locally - assert_display_snapshot!(strip_ansi_codes(&String::from_utf8_lossy(&buff))); + assert_snapshot!(strip_ansi_codes(&String::from_utf8_lossy(&buff))); } #[test] fn display_no_violations_tty() { @@ -742,7 +742,7 @@ SELECT 1; assert!(res.is_ok()); // remove the color codes so tests behave in CI as they do locally - assert_display_snapshot!(strip_ansi_codes(&String::from_utf8_lossy(&buff))); + assert_snapshot!(strip_ansi_codes(&String::from_utf8_lossy(&buff))); } #[test] @@ -763,7 +763,7 @@ SELECT 1; ); assert!(res.is_ok()); - assert_display_snapshot!(String::from_utf8_lossy(&buff), @r#" + assert_snapshot!(String::from_utf8_lossy(&buff), @r#" [{"file":"main.sql","line":1,"column":0,"level":"Warning","messages":[{"Note":"Adding a NOT NULL field without a DEFAULT will fail for a populated table."},{"Help":"Make the field nullable or add a non-VOLATILE DEFAULT (Postgres 11+)."}],"rule_name":"adding-required-field"},{"file":"main.sql","line":3,"column":1,"level":"Warning","messages":[{"Note":"Adding a NOT NULL field without a DEFAULT will fail for a populated table."},{"Help":"Make the field nullable or add a non-VOLATILE DEFAULT (Postgres 11+)."}],"rule_name":"adding-required-field"}] "#); } @@ -872,6 +872,6 @@ SELECT 1; .iter() .map(|v| v.sql.clone()) .collect::(); - assert_display_snapshot!(columns); + assert_snapshot!(columns); } } diff --git a/crates/cli/src/snapshots/squawk__reporter__test_check_files__check_files_invalid_syntax.snap b/crates/cli/src/snapshots/squawk__reporter__test_check_files__check_files_invalid_syntax.snap index 2d13956e..07262d89 100644 --- a/crates/cli/src/snapshots/squawk__reporter__test_check_files__check_files_invalid_syntax.snap +++ b/crates/cli/src/snapshots/squawk__reporter__test_check_files__check_files_invalid_syntax.snap @@ -2,12 +2,4 @@ source: cli/src/reporter.rs expression: val --- -- column: 0 - file: test.sql - level: Error - line: 0 - messages: - - Note: "Postgres failed to parse query: syntax error at or near \"\\\"" - - Help: Modify your Postgres statement to use valid syntax. - rule_name: invalid-statement - +[{"column":0,"file":"test.sql","level":"Error","line":0,"messages":[{"Note":"Postgres failed to parse query: syntax error at or near \"\\\""},{"Help":"Modify your Postgres statement to use valid syntax."}],"rule_name":"invalid-statement"}] diff --git a/crates/linter/src/lib.rs b/crates/linter/src/lib.rs index 33db56a7..0cb57775 100644 --- a/crates/linter/src/lib.rs +++ b/crates/linter/src/lib.rs @@ -432,7 +432,7 @@ pub fn check_sql_with_rule( #[cfg(test)] mod test_rules { use super::*; - use insta::{assert_debug_snapshot, assert_display_snapshot}; + use insta::{assert_debug_snapshot, assert_snapshot}; use std::convert::TryFrom; use std::str::FromStr; @@ -462,7 +462,7 @@ mod test_rules { #[test] fn rule_names_display_snap() { let rule_names: Vec = RULES.iter().map(|r| r.name.to_string()).collect(); - assert_display_snapshot!(rule_names.join("\n")); + assert_snapshot!(rule_names.join("\n")); } /// Ensure we stort the resulting violations by where they occur in the file.