Skip to content

Commit a3e5c23

Browse files
committed
Merge the lint port landing into the Postgres depth guard
2 parents d2e4c95 + 746d6e3 commit a3e5c23

74 files changed

Lines changed: 13353 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ members = [
1616
"crates/sqlquack-syntax-postgres",
1717
"crates/sqlquack-format",
1818
"crates/sqlquack-format-check",
19+
"crates/sqlquack-lint",
1920
"crates/sqlquack-syntax-bigquery",
2021
"crates/sqlquack-fingerprint",
2122
"crates/sqlquack-python",
@@ -51,6 +52,7 @@ polyglot-sql = { git = "https://github.com/sqlstack-io/polyglot.git", rev = "7d5
5152
proc-macro2 = "1"
5253
quote = "1"
5354
rayon = "1"
55+
rustc-hash = "2"
5456
serde = { version = "1", features = ["derive"] }
5557
serde_json = "1"
5658
# The Python module; abi3, so one build loads into every CPython from 3.12.
@@ -63,6 +65,7 @@ sqlquack-duckdb = { path = "crates/sqlquack-duckdb", default-features = false }
6365
sqlquack-evidence = { path = "crates/sqlquack-evidence" }
6466
sqlquack-format = { path = "crates/sqlquack-format" }
6567
sqlquack-fingerprint = { path = "crates/sqlquack-fingerprint" }
68+
sqlquack-lint = { path = "crates/sqlquack-lint" }
6669
sqlquack-policy = { path = "crates/sqlquack-policy" }
6770
sqlquack-rules = { path = "crates/sqlquack-rules" }
6871
sqlquack-semantics = { path = "crates/sqlquack-semantics" }

‎THIRD_PARTY_NOTICES‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ SQLQuack's DuckDB result-type rules, in crates/sqlquack-semantics/src/lineage/_h
6363
and duckdb_types.rs, are ported from polyglot's engine type rules, and the fixture
6464
crates/sqlquack-semantics/src/lineage/tests/fixtures/duckdb_engine_types.json is polyglot's
6565
tests/fixtures/engine_types/duckdb.json, the result types DuckDB bound for its synthetic cases.
66+
The lint Rules' scope walk and aggregate classifier, in crates/sqlquack-lint/src/tree, are ported
67+
from polyglot's scope.rs and traversal.rs.
6668

6769
polyglot is distributed under the following licence:
6870

‎crates/sqlquack-lint/Cargo.toml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "sqlquack-lint"
3+
version.workspace = true
4+
description = "SQL lint Rules over SQLQuack's tokens and syntax trees, ported from SQLClean."
5+
edition.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
homepage.workspace = true
9+
publish.workspace = true
10+
rust-version.workspace = true
11+
12+
[dependencies]
13+
rayon.workspace = true
14+
rustc-hash.workspace = true
15+
serde.workspace = true
16+
serde_json.workspace = true
17+
sqlquack-syntax.workspace = true
18+
19+
[lints]
20+
workspace = true
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//! Constants shared by the engine modules, and the placeholders hosts write for template code.
2+
3+
pub(crate) const SQL_WILDCARD: &str = "*";
4+
pub(crate) const OPEN_PAREN: &str = "(";
5+
pub(crate) const CLOSE_PAREN: &str = ")";
6+
pub(crate) const EMPTY_FIXTURE_QUERY_TOKEN_COUNT: usize = 6;
7+
pub(crate) const ENCLOSING_CTE_TOKEN_COUNT: usize = 3;
8+
/// The indent of each line of a configuration snippet printed in remediation text.
9+
pub(crate) const SETTING_SNIPPET_INDENT: &str = " ";
10+
/// The configuration file remediation text names when the request does not name one.
11+
pub const DEFAULT_CONFIG_FILE: &str = "sqlclean.toml";
12+
/// The identifier prefix a host writes in place of each template interpolation.
13+
pub const INTERPOLATION_PLACEHOLDER_PREFIX: &str = "__sqlclean_interpolation_";
14+
/// The identifier prefix a host writes in place of a SQL macro parameter.
15+
pub const MACRO_PARAMETER_PLACEHOLDER_PREFIX: &str = "__sqlclean_macro_parameter_";
16+
/// The prefix of a relation parameter placeholder, written `<prefix><index>__`.
17+
pub const RELATION_PARAMETER_PLACEHOLDER_PREFIX: &str = "__sqlclean_relation_parameter_";
18+
/// The identifier prefix a host writes in place of a value parameter.
19+
pub const VALUE_PARAMETER_PLACEHOLDER_PREFIX: &str = "__sqlclean_value_parameter_";
20+
/// Placeholders standing for names the host generates, which Rules never judge as authored names.
21+
pub(crate) const GENERATED_PLACEHOLDER_PREFIXES: [&str; 3] = [
22+
INTERPOLATION_PLACEHOLDER_PREFIX,
23+
RELATION_PARAMETER_PLACEHOLDER_PREFIX,
24+
VALUE_PARAMETER_PLACEHOLDER_PREFIX,
25+
];

‎crates/sqlquack-lint/src/lib.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! SQL lint Rules over SQLQuack's tokens and syntax trees, ported from SQLClean's lint engine.
2+
3+
#![forbid(unsafe_code)]
4+
5+
pub mod constants;
6+
pub mod lint;
7+
pub mod quality;
8+
pub(crate) mod tree;
9+
10+
pub use crate::lint::main::batch_engine::lint_batch_json;
11+
pub use crate::lint::main::catalogue::catalogue;
12+
pub use crate::lint::main::cross_join_subject::cross_join_subject;
13+
pub use crate::lint::main::default_rules::default_rules;
14+
pub use crate::lint::main::engine::lint_json;
15+
pub use crate::lint::main::fill_finding_path::fill_finding_path;
16+
pub use crate::lint::main::lint::lint;
17+
pub use crate::lint::main::parse_sql::parse_sql;
18+
pub use crate::lint::main::validate_dialect::validate_dialect;

0 commit comments

Comments
 (0)