diff --git a/Cargo.lock b/Cargo.lock index a12d245..2730875 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,9 +83,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "autocfg" @@ -170,9 +170,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" dependencies = [ "clap_builder", "clap_derive", @@ -180,9 +180,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" dependencies = [ "anstream", "anstyle", @@ -192,9 +192,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck", "proc-macro2", @@ -340,9 +340,9 @@ checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "indexmap" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", @@ -615,18 +615,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -635,9 +635,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "indexmap", "itoa", @@ -694,18 +694,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.4" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.4" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", @@ -724,9 +724,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -736,9 +736,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -925,9 +925,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index c5958a4..5c966aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ members = [ ] [workspace.dependencies] -thiserror = "2.0.4" -serde_json = { features = ["preserve_order", "unbounded_depth"], version = "1.0.133" } +thiserror = "2.0.11" +serde_json = { features = ["preserve_order", "unbounded_depth"], version = "1.0.138" } [workspace.package] authors = ["Davy Duperron "] diff --git a/crates/jql-parser/Cargo.toml b/crates/jql-parser/Cargo.toml index 8c54579..21d3c21 100644 --- a/crates/jql-parser/Cargo.toml +++ b/crates/jql-parser/Cargo.toml @@ -12,7 +12,7 @@ version.workspace = true [dependencies] thiserror.workspace = true -winnow = { version = "0.6.20", features = ["simd"] } +winnow = { version = "0.7.0", features = ["simd"] } [lib] path = "src/lib.rs" diff --git a/crates/jql-parser/src/combinators.rs b/crates/jql-parser/src/combinators.rs index 70e2cae..eefddb0 100644 --- a/crates/jql-parser/src/combinators.rs +++ b/crates/jql-parser/src/combinators.rs @@ -1,6 +1,6 @@ use winnow::{ - PResult, Parser, + Result, ascii::{ digit1, multispace0, @@ -82,12 +82,12 @@ where } /// A combinator which parses a stringified number as an `Index`. -pub(crate) fn parse_number(input: &mut &str) -> PResult { +pub(crate) fn parse_number(input: &mut &str) -> Result { digit1.parse_to().parse_next(input) } /// A combinator which parses a key surrounded by double quotes. -pub(crate) fn parse_key<'a>(input: &mut &'a str) -> PResult<&'a str> { +pub(crate) fn parse_key<'a>(input: &mut &'a str) -> Result<&'a str> { trim(delimited( DOUBLE_QUOTE, take_until(0.., r#"""#), @@ -97,22 +97,22 @@ pub(crate) fn parse_key<'a>(input: &mut &'a str) -> PResult<&'a str> { } /// A combinator which parses a list of `Index`. -pub(crate) fn parse_indexes(input: &mut &str) -> PResult> { +pub(crate) fn parse_indexes(input: &mut &str) -> Result> { separated(1.., parse_number, trim(COMMA)).parse_next(input) } /// A combinator which parses a list of keys. -fn parse_keys<'a>(input: &mut &'a str) -> PResult> { +fn parse_keys<'a>(input: &mut &'a str) -> Result> { trim(separated(1.., parse_key, trim(COMMA))).parse_next(input) } /// A combinator which parses a list of keys surrounded by curly braces. -pub(crate) fn parse_multi_key<'a>(input: &mut &'a str) -> PResult> { +pub(crate) fn parse_multi_key<'a>(input: &mut &'a str) -> Result> { delimited(CURLY_BRACKET_OPEN, parse_keys, CURLY_BRACKET_CLOSE).parse_next(input) } /// A combinator which parses an array of `Index`. -pub(crate) fn parse_array_index(input: &mut &str) -> PResult> { +pub(crate) fn parse_array_index(input: &mut &str) -> Result> { delimited( trim(SQUARE_BRACKET_OPEN), parse_indexes, @@ -122,7 +122,7 @@ pub(crate) fn parse_array_index(input: &mut &str) -> PResult> { } /// A combinator which parses an array range. -pub(crate) fn parse_array_range(input: &mut &str) -> PResult<(Option, Option)> { +pub(crate) fn parse_array_range(input: &mut &str) -> Result<(Option, Option)> { trim(delimited( SQUARE_BRACKET_OPEN, separated_pair(opt(parse_number), trim(COLON), opt(parse_number)), @@ -132,7 +132,7 @@ pub(crate) fn parse_array_range(input: &mut &str) -> PResult<(Option, Opt } /// A combinator which parses a list of index surrounded by curly braces. -pub(crate) fn parse_object_index(input: &mut &str) -> PResult> { +pub(crate) fn parse_object_index(input: &mut &str) -> Result> { delimited( trim(CURLY_BRACKET_OPEN), parse_indexes, @@ -142,7 +142,7 @@ pub(crate) fn parse_object_index(input: &mut &str) -> PResult> { } /// A combinator which parses an object range. -pub(crate) fn parse_object_range(input: &mut &str) -> PResult<(Option, Option)> { +pub(crate) fn parse_object_range(input: &mut &str) -> Result<(Option, Option)> { delimited( trim(CURLY_BRACKET_OPEN), separated_pair(opt(parse_number), trim(COLON), opt(parse_number)), @@ -152,7 +152,7 @@ pub(crate) fn parse_object_range(input: &mut &str) -> PResult<(Option, Op } /// A combinator which parses any lens value. -pub(crate) fn parse_lens_value<'a>(input: &mut &'a str) -> PResult> { +pub(crate) fn parse_lens_value<'a>(input: &mut &'a str) -> Result> { dispatch! {peek(any); 'f' => FALSE.value(LensValue::Bool(false)), 't' => TRUE.value(LensValue::Bool(true)), @@ -164,7 +164,7 @@ pub(crate) fn parse_lens_value<'a>(input: &mut &'a str) -> PResult } // /// A combinator which parses a lens key. -fn parse_lens_key<'a>(input: &mut &'a str) -> PResult> { +fn parse_lens_key<'a>(input: &mut &'a str) -> Result> { trim( dispatch! {peek(any); '[' => { @@ -188,14 +188,14 @@ fn parse_lens_key<'a>(input: &mut &'a str) -> PResult> { } /// A combinator which parses multiple lens keys. -fn parse_lens_keys<'a>(input: &mut &'a str) -> PResult>> { +fn parse_lens_keys<'a>(input: &mut &'a str) -> Result>> { repeat(1.., parse_lens_key).parse_next(input) } /// A combinator which parses a lens. pub(crate) fn parse_lens<'a>( input: &mut &'a str, -) -> PResult<(Vec>, Option>)> { +) -> Result<(Vec>, Option>)> { trim(( parse_lens_keys, opt(preceded(trim(EQUAL), parse_lens_value)), @@ -206,7 +206,7 @@ pub(crate) fn parse_lens<'a>( /// A combinator which parses a list of lenses. pub(crate) fn parse_lenses<'a>( input: &mut &'a str, -) -> PResult>, Option>)>> { +) -> Result>, Option>)>> { delimited( trim(LENSES_START), separated(1.., parse_lens, trim(COMMA)), @@ -216,32 +216,32 @@ pub(crate) fn parse_lenses<'a>( } /// A combinator which parses a keys operator. -pub(crate) fn parse_keys_operator<'a>(input: &mut &'a str) -> PResult<&'a str> { +pub(crate) fn parse_keys_operator<'a>(input: &mut &'a str) -> Result<&'a str> { literal(KEYS).parse_next(input) } /// A combinator which parses a flatten operator. -pub(crate) fn parse_flatten_operator<'a>(input: &mut &'a str) -> PResult<&'a str> { +pub(crate) fn parse_flatten_operator<'a>(input: &mut &'a str) -> Result<&'a str> { literal(FLATTEN).parse_next(input) } /// A combinator which parses a pipe in operator. -pub(crate) fn parse_pipe_in_operator<'a>(input: &mut &'a str) -> PResult<&'a str> { +pub(crate) fn parse_pipe_in_operator<'a>(input: &mut &'a str) -> Result<&'a str> { literal(PIPE_IN).parse_next(input) } /// A combinator which parses a pipe out operator. -pub(crate) fn parse_pipe_out_operator<'a>(input: &mut &'a str) -> PResult<&'a str> { +pub(crate) fn parse_pipe_out_operator<'a>(input: &mut &'a str) -> Result<&'a str> { literal(PIPE_OUT).parse_next(input) } /// A combinator which parses a truncate operator. -pub(crate) fn parse_truncate_operator<'a>(input: &mut &'a str) -> PResult<&'a str> { +pub(crate) fn parse_truncate_operator<'a>(input: &mut &'a str) -> Result<&'a str> { trim(TRUNCATE).parse_next(input) } /// A combinator which parses a group separator. -pub(crate) fn parse_group_separator<'a>(input: &mut &'a str) -> PResult<&'a str> { +pub(crate) fn parse_group_separator<'a>(input: &mut &'a str) -> Result<&'a str> { literal(GROUP_SEP).parse_next(input) } diff --git a/crates/jql-parser/src/group.rs b/crates/jql-parser/src/group.rs index 418c00a..c36d580 100644 --- a/crates/jql-parser/src/group.rs +++ b/crates/jql-parser/src/group.rs @@ -37,9 +37,10 @@ mod tests { #[test] fn check_split() { assert!(split(&[Token::GroupSeparator,]).is_empty()); - assert_eq!(split(&[Token::KeySelector("abc")]), vec![vec![ - &Token::KeySelector("abc") - ]]); + assert_eq!( + split(&[Token::KeySelector("abc")]), + vec![vec![&Token::KeySelector("abc")]] + ); assert_eq!( split(&[ Token::GroupSeparator, @@ -54,9 +55,10 @@ mod tests { Token::GroupSeparator, Token::KeySelector("abc") ]), - vec![vec![&Token::KeySelector("abc")], vec![&Token::KeySelector( - "abc" - )],] + vec![ + vec![&Token::KeySelector("abc")], + vec![&Token::KeySelector("abc")], + ] ); } } diff --git a/crates/jql-parser/src/parser.rs b/crates/jql-parser/src/parser.rs index 3f9cdd0..65fa772 100644 --- a/crates/jql-parser/src/parser.rs +++ b/crates/jql-parser/src/parser.rs @@ -1,6 +1,6 @@ use winnow::{ - PResult, Parser, + Result, combinator::{ alt, dispatch, @@ -38,7 +38,7 @@ use crate::{ }; /// Parses the provided input and map it to the first matching token. -fn parse_fragment<'a>(input: &mut &'a str) -> PResult> { +fn parse_fragment<'a>(input: &mut &'a str) -> Result> { trim( dispatch! {peek(any); '[' => { @@ -87,7 +87,7 @@ fn parse_fragment<'a>(input: &mut &'a str) -> PResult> { pub fn parse(input: &str) -> Result, JqlParserError> { let mut parser_iterator = iterator(input, parse_fragment); let tokens = parser_iterator.collect::>(); - let result: PResult<_, _> = parser_iterator.finish(); + let result: Result<_, _> = parser_iterator.finish(); match result { Ok((unparsed, ())) => { diff --git a/crates/jql-parser/src/tokens.rs b/crates/jql-parser/src/tokens.rs index 932875f..424afab 100644 --- a/crates/jql-parser/src/tokens.rs +++ b/crates/jql-parser/src/tokens.rs @@ -103,12 +103,17 @@ impl<'a> Lens<'a> { impl fmt::Display for Lens<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}{}", self.0.stringify(), match &self.1 { - Some(lens_value) => { - lens_value.to_string() + write!( + f, + "{}{}", + self.0.stringify(), + match &self.1 { + Some(lens_value) => { + lens_value.to_string() + } + None => String::new(), } - None => String::new(), - }) + ) } } diff --git a/crates/jql-runner/Cargo.toml b/crates/jql-runner/Cargo.toml index 6e3fab6..24dcd93 100644 --- a/crates/jql-runner/Cargo.toml +++ b/crates/jql-runner/Cargo.toml @@ -11,7 +11,7 @@ repository.workspace = true version.workspace = true [dependencies] -indexmap = { version = "2.7.0", features = ["rayon"] } +indexmap = { version = "2.7.1", features = ["rayon"] } jql-parser = { path = "../jql-parser", version = "8.0.2" } rayon = "1.10.0" serde_json.workspace = true diff --git a/crates/jql/Cargo.toml b/crates/jql/Cargo.toml index 4786e01..06c151d 100644 --- a/crates/jql/Cargo.toml +++ b/crates/jql/Cargo.toml @@ -11,14 +11,14 @@ repository.workspace = true version.workspace = true [dependencies] -anyhow = "1.0.94" -clap = { version = "4.5.23", features = ["derive"] } +anyhow = "1.0.95" +clap = { version = "4.5.27", features = ["derive"] } colored_json = { version = "5.0.0" } jql-runner = { path = "../jql-runner", version = "8.0.2" } -serde = "1.0.215" +serde = "1.0.217" serde_stacker = "0.1.11" serde_json.workspace = true -tokio = { version = "1.42.0", features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread"] } +tokio = { version = "1.43.0", features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread"] } [package.metadata.binstall] pkg-url = "{ repo }/releases/download/{ name }-v{ version }/{ name }-v{ version }-{ target }{ archive-suffix }" diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 35e22fe..78f063d 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -10,25 +10,27 @@ checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" [[package]] name = "cc" -version = "1.0.79" +version = "1.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" dependencies = [ "jobserver", + "libc", + "shlex", ] [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] [[package]] name = "jql-parser" -version = "8.0.1" +version = "8.0.2" dependencies = [ "thiserror", "winnow", @@ -50,9 +52,9 @@ checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "libfuzzer-sys" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b9569d2f74e257076d8c6bfa73fb505b46b851e51ddaecc825944aa3bed17fa" +checksum = "cf78f52d400cf2d84a3a973a78a592b4adc535739e0a5597a0da6f0c357adc75" dependencies = [ "arbitrary", "cc", @@ -82,6 +84,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "syn" version = "2.0.90" @@ -95,18 +103,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.4" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.4" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", @@ -121,9 +129,9 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "winnow" -version = "0.6.20" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" dependencies = [ "memchr", ] diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 622bc5a..e12434d 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -7,7 +7,7 @@ version = "0.0.0" cargo-fuzz = true [dependencies] -libfuzzer-sys = "0.4.8" +libfuzzer-sys = "0.4.9" [dependencies.jql-parser] path = "../crates/jql-parser" diff --git a/justfile b/justfile index ba82ce2..35843e2 100644 --- a/justfile +++ b/justfile @@ -6,6 +6,10 @@ audit: clippy: cargo clippy +# Format. +fmt: + cargo fmt --all + # Fuzz parser. fuzz: cargo fuzz run fuzz_parser