@@ -6,7 +6,7 @@ pub mod rule;
66pub mod rules;
77
88use pgls_analyse:: { AnalysisFilter , RegistryVisitor , RuleMeta } ;
9- use pgls_configuration:: splinter:: Rules ;
9+ use pgls_configuration:: splinter:: SplinterConfiguration ;
1010use pgls_schema_cache:: SchemaCache ;
1111use sqlx:: PgPool ;
1212
@@ -18,8 +18,8 @@ pub use rule::SplinterRule;
1818pub struct SplinterParams < ' a > {
1919 pub conn : & ' a PgPool ,
2020 pub schema_cache : Option < & ' a SchemaCache > ,
21- /// Optional rules configuration for per-rule database object filtering
22- pub rules_config : Option < & ' a Rules > ,
21+ /// Optional splinter configuration for global and per-rule database object filtering
22+ pub config : Option < & ' a SplinterConfiguration > ,
2323}
2424
2525/// Visitor that collects enabled splinter rules based on filter
@@ -138,24 +138,36 @@ pub async fn run_splinter(
138138
139139 let mut diagnostics: Vec < SplinterDiagnostic > = results. into_iter ( ) . map ( Into :: into) . collect ( ) ;
140140
141- if let Some ( rules_config) = params. rules_config {
142- let rule_matchers = rules_config. get_ignore_matchers ( ) ;
141+ if let Some ( config) = params. config {
142+ // Build global ignore matcher if patterns exist
143+ let global_ignore_matcher = config. get_global_ignore_matcher ( ) ;
143144
144- if !rule_matchers. is_empty ( ) {
145+ // Get per-rule ignore matchers
146+ let rule_matchers = config. rules . get_ignore_matchers ( ) ;
147+
148+ // Filter diagnostics based on global and per-rule ignore patterns
149+ if global_ignore_matcher. is_some ( ) || !rule_matchers. is_empty ( ) {
145150 diagnostics. retain ( |diag| {
146- let rule_name = diag. category . name ( ) . split ( '/' ) . next_back ( ) . unwrap_or ( "" ) ;
151+ let object_identifier = match ( & diag. advices . schema , & diag. advices . object_name ) {
152+ ( Some ( schema) , Some ( name) ) => format ! ( "{schema}.{name}" ) ,
153+ _ => return true , // Keep diagnostics without schema.name
154+ } ;
155+
156+ // Check global ignore first
157+ if let Some ( ref matcher) = global_ignore_matcher {
158+ if matcher. matches ( & object_identifier) {
159+ return false ;
160+ }
161+ }
147162
163+ // Then check per-rule ignore
164+ let rule_name = diag. category . name ( ) . split ( '/' ) . next_back ( ) . unwrap_or ( "" ) ;
148165 if let Some ( matcher) = rule_matchers. get ( rule_name) {
149- if let ( Some ( schema) , Some ( name) ) =
150- ( & diag. advices . schema , & diag. advices . object_name )
151- {
152- let object_identifier = format ! ( "{schema}.{name}" ) ;
153-
154- if matcher. matches ( & object_identifier) {
155- return false ;
156- }
166+ if matcher. matches ( & object_identifier) {
167+ return false ;
157168 }
158169 }
170+
159171 true
160172 } ) ;
161173 }
0 commit comments