@@ -12,6 +12,10 @@ use super::Rule;
1212pub const MAX_LENGTH_DEFAULT : u32 = 80 ;
1313pub const INDENTATION_LEVEL_DEFAULT : u32 = 4 ;
1414
15+ fn default_indentation_spaces ( ) -> u32 {
16+ INDENTATION_LEVEL_DEFAULT
17+ }
18+
1519#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
1620pub struct LongLineOptions {
1721 pub max_length : u32 ,
@@ -29,7 +33,7 @@ impl LongLinesRule {
2933 enabled : true ,
3034 max_length : long_lines. max_length ,
3135 } ,
32- None => LongLinesRule {
36+ None => LongLinesRule {
3337 enabled : false ,
3438 max_length : MAX_LENGTH_DEFAULT ,
3539 } ,
@@ -59,15 +63,22 @@ impl Rule for LongLinesRule {
5963 }
6064}
6165
66+ #[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
67+ pub struct IN1Options {
68+ pub indentation_spaces : u32 ,
69+ }
70+
6271pub struct IN3Rule {
6372 pub enabled : bool ,
6473 indentation_spaces : u32
6574}
6675
6776#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
6877pub struct IN3Options {
78+ #[ serde( default = "default_indentation_spaces" ) ]
6979 pub indentation_spaces : u32 ,
7080}
81+
7182pub struct IN3Args < ' a > {
7283 members_ranges : Vec < ZeroRange > ,
7384 lbrace : ZeroRange ,
@@ -164,25 +175,26 @@ impl Rule for IN3Rule {
164175
165176// IN6: Continuation Line
166177#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
167- pub struct ContinuationLineOptions {
178+ pub struct IN6Options {
179+ #[ serde( default = "default_indentation_spaces" ) ]
168180 pub indentation_spaces : u32 ,
169181}
170182
171- pub struct ContinuationLineRule {
183+ pub struct IN6Rule {
172184 pub enabled : bool ,
173185 pub indentation_spaces : u32 ,
174186}
175187
176- impl ContinuationLineRule {
177- pub fn from_options ( options : & Option < ContinuationLineOptions > ) -> ContinuationLineRule {
188+ impl IN6Rule {
189+ pub fn from_options ( options : & Option < IN6Options > ) -> IN6Rule {
178190 match options {
179- Some ( continuation_line ) => ContinuationLineRule {
191+ Some ( in6 ) => IN6Rule {
180192 enabled : true ,
181- indentation_spaces : continuation_line . indentation_spaces ,
193+ indentation_spaces : in6 . indentation_spaces ,
182194 } ,
183- None => ContinuationLineRule {
195+ None => IN6Rule {
184196 enabled : false ,
185- indentation_spaces : INDENTATION_LEVEL_DEFAULT ,
197+ indentation_spaces : 0 ,
186198 } ,
187199 }
188200 }
@@ -203,7 +215,7 @@ impl ContinuationLineRule {
203215 & logical_operators[ ..] ,
204216 & bitwise_operators[ ..] ,
205217 ] ;
206-
218+
207219 for ( i, line) in lines. iter ( ) . enumerate ( ) {
208220 if let Some ( last_char) = line. trim ( ) . chars ( ) . last ( ) {
209221 if operators. iter ( ) . any ( |ops| ops. contains ( & last_char. to_string ( ) . as_str ( ) ) ) {
@@ -212,7 +224,7 @@ impl ContinuationLineRule {
212224 let expected_indent = line. chars ( ) . take_while ( |c| c. is_whitespace ( ) ) . count ( ) + self . indentation_spaces as usize ;
213225 let actual_indent = next_line. chars ( ) . take_while ( |c| c. is_whitespace ( ) ) . count ( ) ;
214226 if actual_indent != expected_indent {
215- let msg = ContinuationLineRule :: description ( ) . to_owned ( ) ;
227+ let msg = IN6Rule :: description ( ) . to_owned ( ) ;
216228 let dmlerror = LocalDMLError {
217229 range : Range :: new (
218230 Row :: new_zero_indexed ( ( i + 1 ) as u32 ) ,
@@ -231,13 +243,13 @@ impl ContinuationLineRule {
231243 }
232244}
233245
234- impl Rule for ContinuationLineRule {
246+ impl Rule for IN6Rule {
235247 fn name ( ) -> & ' static str {
236- "CONTINUATION_LINE "
248+ "IN6_CONTINUATION_LINE "
237249 }
238250
239251 fn description ( ) -> & ' static str {
240- "Continuation line not indented correctly"
252+ "Continuation line not indented correctly. "
241253 }
242254}
243255
@@ -248,8 +260,10 @@ pub struct IN9Rule {
248260
249261#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
250262pub struct IN9Options {
263+ #[ serde( default = "default_indentation_spaces" ) ]
251264 pub indentation_spaces : u32 ,
252265}
266+
253267pub struct IN9Args < ' a > {
254268 case_range : ZeroRange ,
255269 expected_depth : & ' a mut u32 ,
0 commit comments