From 5e6903586dd9effb9d9b34a0c3dfb39b390a9197 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Mon, 15 Sep 2025 21:07:15 -0400 Subject: [PATCH 1/2] squawk_syntax: refactor identifier out of squawk_linter also change how we version the crates --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 13 +++++++------ PLAN.md | 4 ++++ crates/squawk/Cargo.toml | 2 +- crates/squawk/src/github.rs | 12 ++++++++---- crates/squawk_github/Cargo.toml | 2 +- crates/squawk_lexer/Cargo.toml | 2 +- crates/squawk_linter/Cargo.toml | 2 +- crates/squawk_linter/src/lib.rs | 1 - .../src/rules/adding_field_with_default.rs | 3 +-- crates/squawk_linter/src/rules/ban_char_field.rs | 3 ++- .../src/rules/constraint_missing_not_valid.rs | 3 ++- .../src/rules/disallow_unique_constraint.rs | 3 ++- .../src/rules/prefer_bigint_over_int.rs | 3 +-- .../src/rules/prefer_bigint_over_smallint.rs | 3 +-- .../squawk_linter/src/rules/prefer_identity.rs | 3 ++- .../src/rules/prefer_robust_stmts.rs | 3 ++- .../squawk_linter/src/rules/prefer_text_field.rs | 3 ++- .../src/rules/prefer_timestamptz.rs | 3 ++- .../rules/require_concurrent_index_creation.rs | 3 ++- crates/squawk_linter/src/visitors.rs | 4 ++-- crates/squawk_parser/Cargo.toml | 2 +- crates/squawk_server/Cargo.toml | 2 +- crates/squawk_syntax/Cargo.toml | 2 +- .../src/identifier.rs | 2 +- crates/squawk_syntax/src/lib.rs | 1 + crates/squawk_wasm/Cargo.toml | 2 +- crates/xtask/Cargo.toml | 2 +- s/update-version | 6 +++--- 29 files changed, 62 insertions(+), 48 deletions(-) rename crates/{squawk_linter => squawk_syntax}/src/identifier.rs (96%) diff --git a/Cargo.lock b/Cargo.lock index e5eb9805..d98c0cef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1861,7 +1861,7 @@ dependencies = [ [[package]] name = "squawk_github" -version = "0.0.0" +version = "2.25.0" dependencies = [ "jsonwebtoken", "log", @@ -1872,14 +1872,14 @@ dependencies = [ [[package]] name = "squawk_lexer" -version = "0.0.0" +version = "2.25.0" dependencies = [ "insta", ] [[package]] name = "squawk_linter" -version = "0.0.0" +version = "2.25.0" dependencies = [ "enum-iterator", "insta", @@ -1893,7 +1893,7 @@ dependencies = [ [[package]] name = "squawk_parser" -version = "0.0.0" +version = "2.25.0" dependencies = [ "camino", "dir-test", @@ -1906,7 +1906,7 @@ dependencies = [ [[package]] name = "squawk_server" -version = "0.0.0" +version = "2.25.0" dependencies = [ "anyhow", "insta", @@ -1924,7 +1924,7 @@ dependencies = [ [[package]] name = "squawk_syntax" -version = "0.0.0" +version = "2.25.0" dependencies = [ "camino", "dir-test", @@ -1936,7 +1936,7 @@ dependencies = [ [[package]] name = "squawk_wasm" -version = "0.1.0" +version = "2.25.0" dependencies = [ "console_error_panic_hook", "console_log", @@ -2800,7 +2800,7 @@ checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547" [[package]] name = "xtask" -version = "0.1.0" +version = "2.25.0" dependencies = [ "anyhow", "camino", diff --git a/Cargo.toml b/Cargo.toml index 288f978a..030c4550 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] +version = "2.25.0" edition = "2024" rust-version = "1.88.0" authors = ["Squawk Team & Contributors"] @@ -53,12 +54,12 @@ xshell = "0.2.7" proc-macro2 = "1.0.95" # local -squawk_github = { version = "0.0.0", path = "./crates/squawk_github" } -squawk_lexer = { version = "0.0.0", path = "./crates/squawk_lexer" } -squawk_parser = { version = "0.0.0", path = "./crates/squawk_parser" } -squawk_syntax = { version = "0.0.0", path = "./crates/squawk_syntax" } -squawk_linter = { version = "0.0.0", path = "./crates/squawk_linter" } -squawk_server = { version = "0.0.0", path = "./crates/squawk_server" } +squawk_github = { path = "./crates/squawk_github" } +squawk_lexer = { path = "./crates/squawk_lexer" } +squawk_parser = { path = "./crates/squawk_parser" } +squawk_syntax = { path = "./crates/squawk_syntax" } +squawk_linter = { path = "./crates/squawk_linter" } +squawk_server = { path = "./crates/squawk_server" } [workspace.lints.clippy] collapsible_else_if = "allow" diff --git a/PLAN.md b/PLAN.md index 1f535bb3..474b0ff9 100644 --- a/PLAN.md +++ b/PLAN.md @@ -120,6 +120,10 @@ sql for benchmarks maybe? https://github.com/pgvector/pgvector/blob/master/sql/vector.sql +- doomql + + https://github.com/cedardb/DOOMQL + ### CLI from `deno` diff --git a/crates/squawk/Cargo.toml b/crates/squawk/Cargo.toml index f371b8d0..0b6daf1f 100644 --- a/crates/squawk/Cargo.toml +++ b/crates/squawk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk" -version = "2.25.0" +version.workspace = true default-run = "squawk" authors.workspace = true diff --git a/crates/squawk/src/github.rs b/crates/squawk/src/github.rs index 0f280870..ea4b815c 100644 --- a/crates/squawk/src/github.rs +++ b/crates/squawk/src/github.rs @@ -235,8 +235,10 @@ fn get_summary_comment_body( file_summaries.push(summary); } - let summary_notice = Some("⚠️ **Large Report**: This report was summarized due to size constraints. SQL content has been omitted but all violations were analyzed."); - + let summary_notice = Some( + "⚠️ **Large Report**: This report was summarized due to size constraints. SQL content has been omitted but all violations were analyzed.", + ); + format_comment( violations_emoji, violations_count, @@ -293,8 +295,10 @@ fn truncate_sql_if_needed(sql: &str) -> (String, bool) { if lines.len() <= MAX_SQL_PREVIEW_LINES { (sql.to_string(), false) } else { - let truncated_lines = lines[..MAX_SQL_PREVIEW_LINES].join(" -"); + let truncated_lines = lines[..MAX_SQL_PREVIEW_LINES].join( + " +", + ); let remaining_lines = lines.len() - MAX_SQL_PREVIEW_LINES; ( format!( diff --git a/crates/squawk_github/Cargo.toml b/crates/squawk_github/Cargo.toml index b4363f37..69d2e672 100644 --- a/crates/squawk_github/Cargo.toml +++ b/crates/squawk_github/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk_github" -version = "0.0.0" +version.workspace = true authors.workspace = true edition.workspace = true license.workspace = true diff --git a/crates/squawk_lexer/Cargo.toml b/crates/squawk_lexer/Cargo.toml index fc64e5ce..0d973ff5 100644 --- a/crates/squawk_lexer/Cargo.toml +++ b/crates/squawk_lexer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk_lexer" -version = "0.0.0" +version.workspace = true description = "TBD" authors.workspace = true diff --git a/crates/squawk_linter/Cargo.toml b/crates/squawk_linter/Cargo.toml index 6121ab2b..5f1a79eb 100644 --- a/crates/squawk_linter/Cargo.toml +++ b/crates/squawk_linter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk_linter" -version = "0.0.0" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true diff --git a/crates/squawk_linter/src/lib.rs b/crates/squawk_linter/src/lib.rs index d9479497..710ae4f2 100644 --- a/crates/squawk_linter/src/lib.rs +++ b/crates/squawk_linter/src/lib.rs @@ -20,7 +20,6 @@ mod ignore_index; mod version; mod visitors; -mod identifier; mod rules; #[cfg(test)] diff --git a/crates/squawk_linter/src/rules/adding_field_with_default.rs b/crates/squawk_linter/src/rules/adding_field_with_default.rs index 3936ff20..e837bfab 100644 --- a/crates/squawk_linter/src/rules/adding_field_with_default.rs +++ b/crates/squawk_linter/src/rules/adding_field_with_default.rs @@ -1,11 +1,10 @@ use lazy_static::lazy_static; use std::collections::HashSet; -use squawk_syntax::ast; use squawk_syntax::ast::AstNode; use squawk_syntax::{Parse, SourceFile}; +use squawk_syntax::{ast, identifier::Identifier}; -use crate::identifier::Identifier; use crate::{Linter, Rule, Version, Violation}; fn is_const_expr(expr: &ast::Expr) -> bool { diff --git a/crates/squawk_linter/src/rules/ban_char_field.rs b/crates/squawk_linter/src/rules/ban_char_field.rs index 4f51629a..f03088b2 100644 --- a/crates/squawk_linter/src/rules/ban_char_field.rs +++ b/crates/squawk_linter/src/rules/ban_char_field.rs @@ -4,10 +4,11 @@ use rowan::TextRange; use squawk_syntax::{ Parse, SourceFile, TokenText, ast::{self, AstNode}, + identifier::Identifier, }; use crate::visitors::check_not_allowed_types; -use crate::{Edit, Fix, Linter, Rule, Violation, identifier::Identifier}; +use crate::{Edit, Fix, Linter, Rule, Violation}; use lazy_static::lazy_static; diff --git a/crates/squawk_linter/src/rules/constraint_missing_not_valid.rs b/crates/squawk_linter/src/rules/constraint_missing_not_valid.rs index 1a77e3d1..cc687035 100644 --- a/crates/squawk_linter/src/rules/constraint_missing_not_valid.rs +++ b/crates/squawk_linter/src/rules/constraint_missing_not_valid.rs @@ -3,9 +3,10 @@ use std::collections::HashSet; use squawk_syntax::{ Parse, SourceFile, ast::{self, AstNode}, + identifier::Identifier, }; -use crate::{Linter, Rule, Violation, identifier::Identifier}; +use crate::{Linter, Rule, Violation}; pub fn tables_created_in_transaction( assume_in_transaction: bool, diff --git a/crates/squawk_linter/src/rules/disallow_unique_constraint.rs b/crates/squawk_linter/src/rules/disallow_unique_constraint.rs index 7debe07a..c556f093 100644 --- a/crates/squawk_linter/src/rules/disallow_unique_constraint.rs +++ b/crates/squawk_linter/src/rules/disallow_unique_constraint.rs @@ -1,9 +1,10 @@ use squawk_syntax::{ Parse, SourceFile, ast::{self, AstNode}, + identifier::Identifier, }; -use crate::{Linter, Rule, Violation, identifier::Identifier}; +use crate::{Linter, Rule, Violation}; use super::constraint_missing_not_valid::tables_created_in_transaction; diff --git a/crates/squawk_linter/src/rules/prefer_bigint_over_int.rs b/crates/squawk_linter/src/rules/prefer_bigint_over_int.rs index feb11ade..c1aae298 100644 --- a/crates/squawk_linter/src/rules/prefer_bigint_over_int.rs +++ b/crates/squawk_linter/src/rules/prefer_bigint_over_int.rs @@ -1,9 +1,8 @@ use std::collections::HashSet; use squawk_syntax::ast::AstNode; -use squawk_syntax::{Parse, SourceFile, ast}; +use squawk_syntax::{Parse, SourceFile, ast, identifier::Identifier}; -use crate::identifier::Identifier; use crate::{Edit, Fix, Linter, Rule, Violation}; use crate::visitors::check_not_allowed_types; diff --git a/crates/squawk_linter/src/rules/prefer_bigint_over_smallint.rs b/crates/squawk_linter/src/rules/prefer_bigint_over_smallint.rs index 0ddd7ea2..8555a8c8 100644 --- a/crates/squawk_linter/src/rules/prefer_bigint_over_smallint.rs +++ b/crates/squawk_linter/src/rules/prefer_bigint_over_smallint.rs @@ -1,9 +1,8 @@ use std::collections::HashSet; use squawk_syntax::ast::AstNode; -use squawk_syntax::{Parse, SourceFile, ast}; +use squawk_syntax::{Parse, SourceFile, ast, identifier::Identifier}; -use crate::identifier::Identifier; use crate::{Edit, Fix, Linter, Rule, Violation}; use crate::visitors::check_not_allowed_types; diff --git a/crates/squawk_linter/src/rules/prefer_identity.rs b/crates/squawk_linter/src/rules/prefer_identity.rs index 7c33ac0e..60ce0a3c 100644 --- a/crates/squawk_linter/src/rules/prefer_identity.rs +++ b/crates/squawk_linter/src/rules/prefer_identity.rs @@ -3,9 +3,10 @@ use std::collections::HashSet; use squawk_syntax::{ Parse, SourceFile, ast::{self, AstNode}, + identifier::Identifier, }; -use crate::{Edit, Fix, Linter, Rule, Violation, identifier::Identifier}; +use crate::{Edit, Fix, Linter, Rule, Violation}; use lazy_static::lazy_static; diff --git a/crates/squawk_linter/src/rules/prefer_robust_stmts.rs b/crates/squawk_linter/src/rules/prefer_robust_stmts.rs index 7b05e5c3..db677049 100644 --- a/crates/squawk_linter/src/rules/prefer_robust_stmts.rs +++ b/crates/squawk_linter/src/rules/prefer_robust_stmts.rs @@ -3,9 +3,10 @@ use std::collections::HashMap; use squawk_syntax::{ Parse, SourceFile, ast::{self, AstNode}, + identifier::Identifier, }; -use crate::{Edit, Fix, Linter, Rule, Violation, identifier::Identifier}; +use crate::{Edit, Fix, Linter, Rule, Violation}; #[derive(PartialEq)] enum Constraint { diff --git a/crates/squawk_linter/src/rules/prefer_text_field.rs b/crates/squawk_linter/src/rules/prefer_text_field.rs index 32cd0d58..4c52baa5 100644 --- a/crates/squawk_linter/src/rules/prefer_text_field.rs +++ b/crates/squawk_linter/src/rules/prefer_text_field.rs @@ -3,9 +3,10 @@ use std::collections::HashSet; use squawk_syntax::{ Parse, SourceFile, ast::{self, AstNode}, + identifier::Identifier, }; -use crate::{Edit, Fix, Linter, Rule, Violation, identifier::Identifier}; +use crate::{Edit, Fix, Linter, Rule, Violation}; use crate::visitors::check_not_allowed_types; diff --git a/crates/squawk_linter/src/rules/prefer_timestamptz.rs b/crates/squawk_linter/src/rules/prefer_timestamptz.rs index 8409708e..b886c97a 100644 --- a/crates/squawk_linter/src/rules/prefer_timestamptz.rs +++ b/crates/squawk_linter/src/rules/prefer_timestamptz.rs @@ -1,10 +1,11 @@ use squawk_syntax::{ Parse, SourceFile, ast::{self, AstNode}, + identifier::Identifier, }; +use crate::visitors::check_not_allowed_types; use crate::{Edit, Fix, Linter, Rule, Violation}; -use crate::{identifier::Identifier, visitors::check_not_allowed_types}; pub fn is_not_allowed_timestamp(ty: &ast::Type) -> bool { match ty { diff --git a/crates/squawk_linter/src/rules/require_concurrent_index_creation.rs b/crates/squawk_linter/src/rules/require_concurrent_index_creation.rs index 1f7de9e7..3fd5df05 100644 --- a/crates/squawk_linter/src/rules/require_concurrent_index_creation.rs +++ b/crates/squawk_linter/src/rules/require_concurrent_index_creation.rs @@ -1,9 +1,10 @@ use squawk_syntax::{ Parse, SourceFile, ast::{self, AstNode}, + identifier::Identifier, }; -use crate::{Edit, Fix, Linter, Rule, Violation, identifier::Identifier}; +use crate::{Edit, Fix, Linter, Rule, Violation}; use super::constraint_missing_not_valid::tables_created_in_transaction; diff --git a/crates/squawk_linter/src/visitors.rs b/crates/squawk_linter/src/visitors.rs index cd6676dc..184d1fe2 100644 --- a/crates/squawk_linter/src/visitors.rs +++ b/crates/squawk_linter/src/visitors.rs @@ -1,8 +1,8 @@ use std::collections::HashSet; -use squawk_syntax::ast; +use squawk_syntax::{ast, identifier::Identifier}; -use crate::{Linter, identifier::Identifier}; +use crate::Linter; pub(crate) fn is_not_valid_int_type( ty: &ast::Type, diff --git a/crates/squawk_parser/Cargo.toml b/crates/squawk_parser/Cargo.toml index f4ee0af8..f63ad830 100644 --- a/crates/squawk_parser/Cargo.toml +++ b/crates/squawk_parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk_parser" -version = "0.0.0" +version.workspace = true description = "TBD" authors.workspace = true diff --git a/crates/squawk_server/Cargo.toml b/crates/squawk_server/Cargo.toml index f96cd790..00a06f63 100644 --- a/crates/squawk_server/Cargo.toml +++ b/crates/squawk_server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk_server" -version = "0.0.0" +version.workspace = true authors.workspace = true edition.workspace = true diff --git a/crates/squawk_syntax/Cargo.toml b/crates/squawk_syntax/Cargo.toml index 9378f0e1..fc3cb5e4 100644 --- a/crates/squawk_syntax/Cargo.toml +++ b/crates/squawk_syntax/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk_syntax" -version = "0.0.0" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true diff --git a/crates/squawk_linter/src/identifier.rs b/crates/squawk_syntax/src/identifier.rs similarity index 96% rename from crates/squawk_linter/src/identifier.rs rename to crates/squawk_syntax/src/identifier.rs index 873a9d68..0c3cd6fa 100644 --- a/crates/squawk_linter/src/identifier.rs +++ b/crates/squawk_syntax/src/identifier.rs @@ -2,7 +2,7 @@ /// /// This type handles the casing rules for us to make comparisions easier. #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub(crate) struct Identifier(String); +pub struct Identifier(String); impl Identifier { // TODO: we need to handle more advanced identifiers like: diff --git a/crates/squawk_syntax/src/lib.rs b/crates/squawk_syntax/src/lib.rs index 294c5dec..f0a332dc 100644 --- a/crates/squawk_syntax/src/lib.rs +++ b/crates/squawk_syntax/src/lib.rs @@ -25,6 +25,7 @@ // DEALINGS IN THE SOFTWARE. pub mod ast; +pub mod identifier; mod parsing; pub mod syntax_error; mod syntax_node; diff --git a/crates/squawk_wasm/Cargo.toml b/crates/squawk_wasm/Cargo.toml index 18685497..2ee672cc 100644 --- a/crates/squawk_wasm/Cargo.toml +++ b/crates/squawk_wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "squawk_wasm" -version = "0.1.0" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml index 209a92ef..90b123b0 100644 --- a/crates/xtask/Cargo.toml +++ b/crates/xtask/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xtask" -version = "0.1.0" +version.workspace = true authors.workspace = true edition.workspace = true diff --git a/s/update-version b/s/update-version index f1ee23d5..763f8f4c 100755 --- a/s/update-version +++ b/s/update-version @@ -7,9 +7,9 @@ main() { NEW_VERSION="$1" if [ -z "$NEW_VERSION" ]; then - NEW_VERSION=$(awk -F'[".]' '/^version = / {print $2 "." ($3+1) ".0"}' crates/squawk/Cargo.toml) + NEW_VERSION=$(awk -F'[".]' '/^version = / {print $2 "." ($3+1) ".0"}' Cargo.toml) if [ -z "$NEW_VERSION" ]; then - echo "Error: Could not determine current version" + echo "Error: Could not determine current version from workspace Cargo.toml" exit 1 fi @@ -25,7 +25,7 @@ main() { echo "Creating new release branch: release-$NEW_VERSION" git checkout -b "release-$NEW_VERSION" echo "updating version to '$NEW_VERSION'..." - fastmod --accept-all '^version = ".*"' 'version = "'$NEW_VERSION'"' crates/squawk/Cargo.toml + fastmod --accept-all '^version = ".*"' 'version = "'$NEW_VERSION'"' Cargo.toml fastmod --accept-all -m '(name = "squawk"\n)version = ".*?"' '${1}version = "'$NEW_VERSION'"' Cargo.lock fastmod --accept-all '"version": ".*"' '"version": "'$NEW_VERSION'"' package.json fastmod --accept-all '"version": ".*"' '"version": "'$NEW_VERSION'"' squawk-vscode/package.json From 1a85a16c2085953a7716ddfabd70f6d66933776d Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Mon, 15 Sep 2025 21:10:28 -0400 Subject: [PATCH 2/2] fix version check --- s/check-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s/check-version b/s/check-version index 32ee71c4..8106fe53 100755 --- a/s/check-version +++ b/s/check-version @@ -38,7 +38,7 @@ CLI_VERSION_PATTERN = r"version = \"(?P\d+\.\d+\.\d+)\"" def find_cli_version() -> str: - cargo_toml = squawk_root() / "crates/squawk/Cargo.toml" + cargo_toml = squawk_root() / "Cargo.toml" for line in cargo_toml.read_text().split("\n"): match = re.match(CLI_VERSION_PATTERN, line) if match is not None: