@@ -68,14 +68,23 @@ impl<'a, 'b> LintVisitor<'a, 'b> {
68
68
69
69
fn finish ( mut self ) -> ( FxHashSet < RuleFilter < ' a > > , FxHashSet < RuleFilter < ' a > > ) {
70
70
let has_only_filter = !self . only . is_empty ( ) ;
71
+
71
72
if !has_only_filter {
72
73
let enabled_rules = self
73
74
. settings
74
75
. as_linter_rules ( )
75
76
. map ( |rules| rules. as_enabled_rules ( ) )
76
77
. unwrap_or_default ( ) ;
77
78
self . enabled_rules . extend ( enabled_rules) ;
79
+
80
+ let disabled_rules = self
81
+ . settings
82
+ . as_linter_rules ( )
83
+ . map ( |rules| rules. as_disabled_rules ( ) )
84
+ . unwrap_or_default ( ) ;
85
+ self . disabled_rules . extend ( disabled_rules) ;
78
86
}
87
+
79
88
( self . enabled_rules , self . disabled_rules )
80
89
}
81
90
@@ -127,3 +136,42 @@ impl RegistryVisitor for LintVisitor<'_, '_> {
127
136
self . push_rule :: < R > ( )
128
137
}
129
138
}
139
+
140
+ #[ cfg( test) ]
141
+ mod tests {
142
+ use pgt_analyse:: RuleFilter ;
143
+ use pgt_configuration:: { RuleConfiguration , Rules , analyser:: Safety } ;
144
+
145
+ use crate :: {
146
+ settings:: { LinterSettings , Settings } ,
147
+ workspace:: server:: analyser:: AnalyserVisitorBuilder ,
148
+ } ;
149
+
150
+ #[ test]
151
+ fn recognizes_disabled_rules ( ) {
152
+ let settings = Settings {
153
+ linter : LinterSettings {
154
+ rules : Some ( Rules {
155
+ safety : Some ( Safety {
156
+ ban_drop_column : Some ( RuleConfiguration :: Plain (
157
+ pgt_configuration:: RulePlainConfiguration :: Off ,
158
+ ) ) ,
159
+ ..Default :: default ( )
160
+ } ) ,
161
+ ..Default :: default ( )
162
+ } ) ,
163
+ ..Default :: default ( )
164
+ } ,
165
+ ..Default :: default ( )
166
+ } ;
167
+
168
+ let ( _, disabled_rules) = AnalyserVisitorBuilder :: new ( & settings)
169
+ . with_linter_rules ( & [ ] , & [ ] )
170
+ . finish ( ) ;
171
+
172
+ assert_eq ! (
173
+ disabled_rules,
174
+ vec![ RuleFilter :: Rule ( "safety" , "banDropColumn" ) ]
175
+ )
176
+ }
177
+ }
0 commit comments