@@ -8,7 +8,7 @@ use crate::analysis::LocalDMLError;
88use crate :: analysis:: parsing:: tree:: { ZeroRange , Content , TreeElement } ;
99use serde:: { Deserialize , Serialize } ;
1010use super :: Rule ;
11- use crate :: lint:: LintCfg ;
11+ use crate :: lint:: { LintCfg , DMLStyleError } ;
1212
1313pub const MAX_LENGTH_DEFAULT : u32 = 80 ;
1414pub const INDENTATION_LEVEL_DEFAULT : u32 = 4 ;
@@ -56,16 +56,19 @@ impl LongLinesRule {
5656 } ,
5757 }
5858 }
59- pub fn check ( & self , acc : & mut Vec < LocalDMLError > , row : usize , line : & str ) {
59+ pub fn check ( & self , acc : & mut Vec < DMLStyleError > , row : usize , line : & str ) {
6060 if !self . enabled { return ; }
6161 let len = line. len ( ) . try_into ( ) . unwrap ( ) ;
6262 if len > self . max_length {
6363 let rowu32 = row. try_into ( ) . unwrap ( ) ;
6464 let msg = LongLinesRule :: description ( ) . to_owned ( )
6565 + format ! ( " of {} characters" , self . max_length) . as_str ( ) ;
66- let dmlerror = LocalDMLError {
67- range : Range :: < ZeroIndexed > :: from_u32 ( rowu32, rowu32, self . max_length , len) ,
68- description : msg,
66+ let dmlerror = DMLStyleError {
67+ error : LocalDMLError {
68+ range : Range :: < ZeroIndexed > :: from_u32 ( rowu32, rowu32, self . max_length , len) ,
69+ description : msg,
70+ } ,
71+ rule_name : Self :: name ( ) . to_string ( ) ,
6972 } ;
7073 acc. push ( dmlerror) ;
7174 }
@@ -93,16 +96,19 @@ pub struct IN2Rule {
9396}
9497
9598impl IN2Rule {
96- pub fn check ( & self , acc : & mut Vec < LocalDMLError > , row : usize , line : & str ) {
99+ pub fn check ( & self , acc : & mut Vec < DMLStyleError > , row : usize , line : & str ) {
97100 if !self . enabled { return ; }
98101 let rowu32 = row. try_into ( ) . unwrap ( ) ;
99102
100103 for ( col, _) in line. match_indices ( '\t' ) {
101104 let colu32 = col. try_into ( ) . unwrap ( ) ;
102105 let msg = IN2Rule :: description ( ) . to_owned ( ) ;
103- let dmlerror = LocalDMLError {
104- range : Range :: < ZeroIndexed > :: from_u32 ( rowu32, rowu32, colu32, colu32 + 1 ) ,
105- description : msg,
106+ let dmlerror = DMLStyleError {
107+ error : LocalDMLError {
108+ range : Range :: < ZeroIndexed > :: from_u32 ( rowu32, rowu32, colu32, colu32 + 1 ) ,
109+ description : msg,
110+ } ,
111+ rule_name : Self :: name ( ) . to_string ( ) ,
106112 } ;
107113 acc. push ( dmlerror) ;
108114 }
@@ -187,7 +193,7 @@ impl IN3Rule {
187193 }
188194 }
189195 }
190- pub fn check < ' a > ( & self , acc : & mut Vec < LocalDMLError > ,
196+ pub fn check < ' a > ( & self , acc : & mut Vec < DMLStyleError > ,
191197 args : Option < IN3Args < ' a > > )
192198 {
193199 if !self . enabled { return ; }
@@ -197,9 +203,12 @@ impl IN3Rule {
197203 * args. expected_depth += 1 ;
198204 for member_range in args. members_ranges {
199205 if self . indentation_is_not_aligned ( member_range, * args. expected_depth ) {
200- let dmlerror = LocalDMLError {
201- range : member_range,
202- description : Self :: description ( ) . to_string ( ) ,
206+ let dmlerror = DMLStyleError {
207+ error : LocalDMLError {
208+ range : member_range,
209+ description : Self :: description ( ) . to_string ( ) ,
210+ } ,
211+ rule_name : Self :: name ( ) . to_string ( ) ,
203212 } ;
204213 acc. push ( dmlerror) ;
205214 }
@@ -248,7 +257,7 @@ impl IN6Rule {
248257 }
249258 }
250259
251- pub fn check ( & self , acc : & mut Vec < LocalDMLError > , lines : & [ & str ] ) {
260+ pub fn check ( & self , acc : & mut Vec < DMLStyleError > , lines : & [ & str ] ) {
252261 if !self . enabled {
253262 return ;
254263 }
@@ -274,14 +283,17 @@ impl IN6Rule {
274283 let actual_indent = next_line. chars ( ) . take_while ( |c| c. is_whitespace ( ) ) . count ( ) ;
275284 if actual_indent != expected_indent {
276285 let msg = IN6Rule :: description ( ) . to_owned ( ) ;
277- let dmlerror = LocalDMLError {
278- range : Range :: new (
279- Row :: new_zero_indexed ( ( i + 1 ) as u32 ) ,
280- Row :: new_zero_indexed ( ( i + 1 ) as u32 ) ,
281- Column :: new_zero_indexed ( 0 ) ,
282- Column :: new_zero_indexed ( next_line. len ( ) as u32 )
283- ) ,
284- description : msg,
286+ let dmlerror = DMLStyleError {
287+ error : LocalDMLError {
288+ range : Range :: new (
289+ Row :: new_zero_indexed ( ( i + 1 ) as u32 ) ,
290+ Row :: new_zero_indexed ( ( i + 1 ) as u32 ) ,
291+ Column :: new_zero_indexed ( 0 ) ,
292+ Column :: new_zero_indexed ( next_line. len ( ) as u32 )
293+ ) ,
294+ description : msg,
295+ } ,
296+ rule_name : Self :: name ( ) . to_string ( ) ,
285297 } ;
286298 acc. push ( dmlerror) ;
287299 }
@@ -357,15 +369,18 @@ impl IN9Rule {
357369 }
358370 }
359371 }
360- pub fn check < ' a > ( & self , acc : & mut Vec < LocalDMLError > ,
372+ pub fn check < ' a > ( & self , acc : & mut Vec < DMLStyleError > ,
361373 args : Option < IN9Args < ' a > > )
362374 {
363375 if !self . enabled { return ; }
364376 let Some ( args) = args else { return ; } ;
365377 if self . indentation_is_not_aligned ( args. case_range , * args. expected_depth ) {
366- let dmlerror = LocalDMLError {
367- range : args. case_range ,
368- description : Self :: description ( ) . to_string ( ) ,
378+ let dmlerror = DMLStyleError {
379+ error : LocalDMLError {
380+ range : args. case_range ,
381+ description : Self :: description ( ) . to_string ( ) ,
382+ } ,
383+ rule_name : Self :: name ( ) . to_string ( ) ,
369384 } ;
370385 acc. push ( dmlerror) ;
371386 }
0 commit comments