@@ -3,7 +3,7 @@ use std::convert::TryInto;
33use serde:: { Deserialize , Serialize } ;
44use crate :: analysis:: parsing:: types:: { BitfieldsContent , LayoutContent ,
55 StructTypeContent } ;
6- use crate :: lint:: { rules:: Rule ,
6+ use crate :: lint:: { rules:: { Rule , RuleType } ,
77 DMLStyleError } ;
88use crate :: analysis:: LocalDMLError ;
99use crate :: analysis:: parsing:: tree:: { TreeElement , ZeroRange } ;
@@ -109,7 +109,7 @@ impl SpBracesRule {
109109 range : location. lbrace ,
110110 description : Self :: description ( ) . to_string ( ) ,
111111 } ,
112- rule_name : Self :: name ( ) . to_string ( ) ,
112+ rule_type : Self :: get_rule_type ( ) ,
113113 } ;
114114 acc. push ( dmlerror) ;
115115 }
@@ -120,7 +120,7 @@ impl SpBracesRule {
120120 range : location. rbrace ,
121121 description : Self :: description ( ) . to_string ( ) ,
122122 } ,
123- rule_name : Self :: name ( ) . to_string ( ) ,
123+ rule_type : Self :: get_rule_type ( ) ,
124124 } ;
125125 acc. push ( dmlerror) ;
126126 }
@@ -135,6 +135,9 @@ impl Rule for SpBracesRule {
135135 fn description ( ) -> & ' static str {
136136 "Missing space around brace"
137137 }
138+ fn get_rule_type ( ) -> RuleType {
139+ RuleType :: SpBraces
140+ }
138141}
139142
140143#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
@@ -256,7 +259,7 @@ impl SpPunctRule {
256259 range : error_range,
257260 description : Self :: description ( ) . to_string ( ) ,
258261 } ,
259- rule_name : Self :: name ( ) . to_string ( ) ,
262+ rule_type : Self :: get_rule_type ( ) ,
260263 } ;
261264 acc. push ( dmlerror) ;
262265 }
@@ -274,7 +277,7 @@ impl SpPunctRule {
274277 range : error_range,
275278 description : Self :: description ( ) . to_string ( ) ,
276279 } ,
277- rule_name : Self :: name ( ) . to_string ( ) ,
280+ rule_type : Self :: get_rule_type ( ) ,
278281 } ;
279282 acc. push ( dmlerror) ;
280283 }
@@ -290,6 +293,9 @@ impl Rule for SpPunctRule {
290293 fn description ( ) -> & ' static str {
291294 "Missing space after punctuation mark"
292295 }
296+ fn get_rule_type ( ) -> RuleType {
297+ RuleType :: SpPunct
298+ }
293299}
294300#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
295301pub struct NspFunparOptions { }
@@ -331,7 +337,7 @@ impl NspFunparRule {
331337 range : gap,
332338 description : Self :: description ( ) . to_string ( ) ,
333339 } ,
334- rule_name : Self :: name ( ) . to_string ( ) ,
340+ rule_type : Self :: get_rule_type ( ) ,
335341 } ;
336342 acc. push ( dmlerror) ;
337343 }
@@ -344,6 +350,9 @@ impl Rule for NspFunparRule {
344350 fn description ( ) -> & ' static str {
345351 "There should be no space between a method/function name and its opening parenthesis."
346352 }
353+ fn get_rule_type ( ) -> RuleType {
354+ RuleType :: NspFunpar
355+ }
347356}
348357
349358
@@ -428,7 +437,7 @@ impl NspInparenRule {
428437 range : gap,
429438 description : Self :: description ( ) . to_string ( ) ,
430439 } ,
431- rule_name : Self :: name ( ) . to_string ( ) ,
440+ rule_type : Self :: get_rule_type ( ) ,
432441 } ;
433442 acc. push ( dmlerror) ;
434443 }
@@ -442,7 +451,7 @@ impl NspInparenRule {
442451 range : gap,
443452 description : Self :: description ( ) . to_string ( ) ,
444453 } ,
445- rule_name : Self :: name ( ) . to_string ( ) ,
454+ rule_type : Self :: get_rule_type ( ) ,
446455 } ;
447456 acc. push ( dmlerror) ;
448457 }
@@ -456,6 +465,9 @@ impl Rule for NspInparenRule {
456465 fn description ( ) -> & ' static str {
457466 "There should be no space after opening or before closing () / []"
458467 }
468+ fn get_rule_type ( ) -> RuleType {
469+ RuleType :: NspInparen
470+ }
459471}
460472
461473#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
@@ -497,7 +509,7 @@ impl NspUnaryRule {
497509 range : gap,
498510 description : Self :: description ( ) . to_string ( ) ,
499511 } ,
500- rule_name : Self :: name ( ) . to_string ( ) ,
512+ rule_type : Self :: get_rule_type ( ) ,
501513 } ;
502514 acc. push ( dmlerror) ;
503515 }
@@ -510,6 +522,9 @@ impl Rule for NspUnaryRule {
510522 fn description ( ) -> & ' static str {
511523 "There should be no space between unary operator and its operand"
512524 }
525+ fn get_rule_type ( ) -> RuleType {
526+ RuleType :: NspUnary
527+ }
513528}
514529
515530#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
@@ -533,7 +548,7 @@ impl NspTrailingRule {
533548 len) ,
534549 description : Self :: description ( ) . to_string ( ) ,
535550 } ,
536- rule_name : Self :: name ( ) . to_string ( ) ,
551+ rule_type : Self :: get_rule_type ( ) ,
537552 } ;
538553 acc. push ( dmlerror) ;
539554 }
@@ -546,4 +561,7 @@ impl Rule for NspTrailingRule {
546561 fn description ( ) -> & ' static str {
547562 "Found trailing whitespace on row"
548563 }
564+ fn get_rule_type ( ) -> RuleType {
565+ RuleType :: NspTrailing
566+ }
549567}
0 commit comments