@@ -3,12 +3,12 @@ use std::collections::HashSet;
33use rowan:: { NodeOrToken , TextRange , TextSize } ;
44use squawk_syntax:: { SyntaxKind , SyntaxNode , SyntaxToken } ;
55
6- use crate :: { ErrorCode , Linter , Violation } ;
6+ use crate :: { Linter , Rule , Violation } ;
77
88#[ derive( Debug ) ]
99pub struct Ignore {
1010 pub range : TextRange ,
11- pub violation_names : HashSet < ErrorCode > ,
11+ pub violation_names : HashSet < Rule > ,
1212}
1313
1414fn comment_body ( token : & SyntaxToken ) -> Option < ( & str , TextRange ) > {
@@ -71,7 +71,7 @@ pub(crate) fn find_ignores(ctx: &mut Linter, file: &SyntaxNode) {
7171 if x. is_empty ( ) {
7272 continue ;
7373 }
74- if let Ok ( violation_name) = ErrorCode :: try_from ( x. trim ( ) ) {
74+ if let Ok ( violation_name) = Rule :: try_from ( x. trim ( ) ) {
7575 set. insert ( violation_name) ;
7676 } else {
7777 let without_start = x. trim_start ( ) ;
@@ -85,10 +85,10 @@ pub(crate) fn find_ignores(ctx: &mut Linter, file: &SyntaxNode) {
8585 let range = TextRange :: new ( start, end) ;
8686
8787 ctx. report ( Violation :: new (
88- ErrorCode :: UnusedIgnore ,
88+ Rule :: UnusedIgnore ,
8989 format ! ( "unknown name {trimmed}" ) ,
9090 range,
91- vec ! [ ] ,
91+ None ,
9292 ) ) ;
9393 }
9494
@@ -108,7 +108,7 @@ pub(crate) fn find_ignores(ctx: &mut Linter, file: &SyntaxNode) {
108108#[ cfg( test) ]
109109mod test {
110110
111- use crate :: { find_ignores, ErrorCode , Linter , Violation } ;
111+ use crate :: { find_ignores, Linter , Rule } ;
112112
113113 #[ test]
114114 fn single_ignore ( ) {
@@ -123,7 +123,7 @@ alter table t drop column c cascade;
123123
124124 assert_eq ! ( linter. ignores. len( ) , 1 ) ;
125125 let ignore = & linter. ignores [ 0 ] ;
126- assert ! ( ignore. violation_names. contains( & ErrorCode :: BanDropColumn ) ) ;
126+ assert ! ( ignore. violation_names. contains( & Rule :: BanDropColumn ) ) ;
127127 }
128128
129129 #[ test]
@@ -140,7 +140,7 @@ alter table t drop column c cascade;
140140
141141 assert_eq ! ( linter. ignores. len( ) , 1 ) ;
142142 let ignore = & linter. ignores [ 0 ] ;
143- assert ! ( ignore. violation_names. contains( & ErrorCode :: BanDropColumn ) ) ;
143+ assert ! ( ignore. violation_names. contains( & Rule :: BanDropColumn ) ) ;
144144 }
145145
146146 #[ test]
@@ -157,9 +157,9 @@ alter table t drop column c cascade;
157157
158158 assert_eq ! ( linter. ignores. len( ) , 1 ) ;
159159 let ignore = & linter. ignores [ 0 ] ;
160- assert ! ( ignore. violation_names. contains( & ErrorCode :: BanDropColumn ) ) ;
161- assert ! ( ignore. violation_names. contains( & ErrorCode :: RenamingColumn ) ) ;
162- assert ! ( ignore. violation_names. contains( & ErrorCode :: BanDropDatabase ) ) ;
160+ assert ! ( ignore. violation_names. contains( & Rule :: BanDropColumn ) ) ;
161+ assert ! ( ignore. violation_names. contains( & Rule :: RenamingColumn ) ) ;
162+ assert ! ( ignore. violation_names. contains( & Rule :: BanDropDatabase ) ) ;
163163 }
164164
165165 #[ test]
@@ -176,9 +176,9 @@ alter table t drop column c cascade;
176176
177177 assert_eq ! ( linter. ignores. len( ) , 1 ) ;
178178 let ignore = & linter. ignores [ 0 ] ;
179- assert ! ( ignore. violation_names. contains( & ErrorCode :: BanDropColumn ) ) ;
180- assert ! ( ignore. violation_names. contains( & ErrorCode :: RenamingColumn ) ) ;
181- assert ! ( ignore. violation_names. contains( & ErrorCode :: BanDropDatabase ) ) ;
179+ assert ! ( ignore. violation_names. contains( & Rule :: BanDropColumn ) ) ;
180+ assert ! ( ignore. violation_names. contains( & Rule :: RenamingColumn ) ) ;
181+ assert ! ( ignore. violation_names. contains( & Rule :: BanDropDatabase ) ) ;
182182 }
183183
184184 #[ test]
@@ -199,7 +199,7 @@ create table users (
199199"# ;
200200
201201 let parse = squawk_syntax:: SourceFile :: parse ( sql) ;
202- let errors: Vec < & Violation > = linter. lint ( parse, sql) ;
202+ let errors = linter. lint ( parse, sql) ;
203203 assert_eq ! ( errors. len( ) , 0 ) ;
204204 }
205205
@@ -209,7 +209,7 @@ create table users (
209209 let sql = r#"alter table t add column c char;"# ;
210210
211211 let parse = squawk_syntax:: SourceFile :: parse ( sql) ;
212- let errors: Vec < & Violation > = linter. lint ( parse, sql) ;
212+ let errors = linter. lint ( parse, sql) ;
213213 assert_eq ! ( errors. len( ) , 1 ) ;
214214 }
215215}
0 commit comments