Skip to content

Commit 59ad629

Browse files
committed
Fix clippy reports
1 parent 06c848a commit 59ad629

File tree

8 files changed

+122
-115
lines changed

8 files changed

+122
-115
lines changed

src/analysis/parsing/expression.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl TreeElement for UnaryExpressionContent {
4242
create_subs!(&self.operation, &self.expr)
4343
}
4444
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
45-
rules.nsp_unary.check(acc, NspUnaryArgs::from_unary_expr(self));
45+
rules.nsp_unary.check(NspUnaryArgs::from_unary_expr(self), acc);
4646
}
4747
}
4848

@@ -76,7 +76,7 @@ impl TreeElement for PostUnaryExpressionContent {
7676
create_subs!(&self.expr, &self.operation)
7777
}
7878
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
79-
rules.nsp_unary.check(acc, NspUnaryArgs::from_postunary_expr(self));
79+
rules.nsp_unary.check(NspUnaryArgs::from_postunary_expr(self), acc);
8080
}
8181
}
8282

@@ -95,7 +95,7 @@ impl TreeElement for BinaryExpressionContent {
9595
create_subs!(&self.left, &self.operation, &self.right)
9696
}
9797
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
98-
rules.sp_binop.check(acc, SpBinopArgs::from_binary_expression_content(self));
98+
rules.sp_binop.check(SpBinopArgs::from_binary_expression_content(self), acc);
9999
}
100100
}
101101

@@ -157,7 +157,7 @@ impl TreeElement for TertiaryExpressionContent {
157157
&self.middle, &self.right_operation, &self.right)
158158
}
159159
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
160-
rules.sp_ternary.check(acc, SpTernaryArgs::from_tertiary_expression_content(self));
160+
rules.sp_ternary.check(SpTernaryArgs::from_tertiary_expression_content(self), acc);
161161
}
162162
}
163163

@@ -176,7 +176,7 @@ impl TreeElement for ParenExpressionContent {
176176
create_subs!(&self.lparen, &self.expr, &self.rparen)
177177
}
178178
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
179-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_paren_expression(self));
179+
rules.indent_paren_expr.check(IndentParenExprArgs::from_paren_expression(self), acc);
180180
}
181181
}
182182

@@ -223,10 +223,10 @@ impl TreeElement for FunctionCallContent {
223223
}
224224
}
225225
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
226-
rules.nsp_funpar.check(acc, NspFunparArgs::from_function_call(self));
227-
rules.nsp_inparen.check(acc, NspInparenArgs::from_function_call(self));
228-
rules.sp_punct.check(acc, SpPunctArgs::from_function_call(self));
229-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_function_call(self));
226+
rules.nsp_funpar.check(NspFunparArgs::from_function_call(self), acc);
227+
rules.nsp_inparen.check(NspInparenArgs::from_function_call(self), acc);
228+
rules.sp_punct.check(SpPunctArgs::from_function_call(self), acc);
229+
rules.indent_paren_expr.check(IndentParenExprArgs::from_function_call(self), acc);
230230
}
231231
}
232232

@@ -341,7 +341,7 @@ impl TreeElement for CastContent {
341341
&self.comma, &self.to, &self.rparen)
342342
}
343343
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
344-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_cast(self));
344+
rules.indent_paren_expr.check(IndentParenExprArgs::from_cast(self), acc);
345345
}
346346
}
347347

@@ -438,7 +438,7 @@ impl TreeElement for IndexContent {
438438
create_subs!(&self.array, &self.lbracket, &self.index, &self.rbracket)
439439
}
440440
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
441-
rules.nsp_inparen.check(acc, NspInparenArgs::from_index(self));
441+
rules.nsp_inparen.check(NspInparenArgs::from_index(self), acc);
442442
}
443443
}
444444

src/analysis/parsing/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ impl TreeElement for CDeclContent {
594594
&self.modifiers, &self.decl)
595595
}
596596
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
597-
rules.sp_ptrdecl.check(acc, SpPtrDeclArgs::from_cdecl(self));
598-
rules.nsp_ptrdecl.check(acc, NspPtrDeclArgs::from_cdecl(self));
597+
rules.sp_ptrdecl.check(SpPtrDeclArgs::from_cdecl(self), acc);
598+
rules.nsp_ptrdecl.check(NspPtrDeclArgs::from_cdecl(self), acc);
599599
}
600600
}
601601

src/analysis/parsing/statement.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ impl TreeElement for CompoundContent {
146146
create_subs!(&self.lbrace, &self.statements, &self.rbrace)
147147
}
148148
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
149-
rules.sp_brace.check(acc, SpBracesArgs::from_compound(self));
150-
rules.indent_code_block.check(acc, IndentCodeBlockArgs::from_compound_content(self, aux.depth));
151-
rules.indent_closing_brace.check(acc, IndentClosingBraceArgs::from_compound_content(self, aux.depth));
149+
rules.sp_brace.check(SpBracesArgs::from_compound(self), acc);
150+
rules.indent_code_block.check(IndentCodeBlockArgs::from_compound_content(self, aux.depth), acc);
151+
rules.indent_closing_brace.check(IndentClosingBraceArgs::from_compound_content(self, aux.depth), acc);
152152
}
153153
fn should_increment_depth(&self) -> bool {
154154
true
@@ -204,7 +204,7 @@ impl TreeElement for VariableDeclContent {
204204
self.decls.ensure_named()
205205
}
206206
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
207-
rules.sp_punct.check(acc, SpPunctArgs::from_variable_decl(self));
207+
rules.sp_punct.check(SpPunctArgs::from_variable_decl(self), acc);
208208
}
209209
}
210210

@@ -436,9 +436,9 @@ impl TreeElement for IfContent {
436436
&self.elsebranch)
437437
}
438438
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
439-
rules.nsp_inparen.check(acc, NspInparenArgs::from_if(self));
440-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_if(self));
441-
rules.sp_reserved.check(acc, SpReservedArgs::from_if(self));
439+
rules.nsp_inparen.check(NspInparenArgs::from_if(self), acc);
440+
rules.indent_paren_expr.check(IndentParenExprArgs::from_if(self), acc);
441+
rules.sp_reserved.check(SpReservedArgs::from_if(self), acc);
442442
}
443443
}
444444

@@ -550,9 +550,9 @@ impl TreeElement for WhileContent {
550550
&self.statement)
551551
}
552552
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
553-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_while(self));
554-
rules.indent_empty_loop.check(acc, IndentEmptyLoopArgs::from_while_content(self, aux.depth));
555-
rules.sp_reserved.check(acc, SpReservedArgs::from_while(self));
553+
rules.indent_paren_expr.check(IndentParenExprArgs::from_while(self), acc);
554+
rules.indent_empty_loop.check(IndentEmptyLoopArgs::from_while_content(self, aux.depth), acc);
555+
rules.sp_reserved.check(SpReservedArgs::from_while(self), acc);
556556
}
557557
}
558558

@@ -602,7 +602,7 @@ impl TreeElement for DoContent {
602602
&self.semi)
603603
}
604604
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
605-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_do_while(self));
605+
rules.indent_paren_expr.check(IndentParenExprArgs::from_do_while(self), acc);
606606
}
607607
}
608608

@@ -867,9 +867,9 @@ impl TreeElement for ForContent {
867867
&self.statement)
868868
}
869869
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
870-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_for(self));
871-
rules.indent_empty_loop.check(acc, IndentEmptyLoopArgs::from_for_content(self, aux.depth));
872-
rules.sp_reserved.check(acc, SpReservedArgs::from_for(self));
870+
rules.indent_paren_expr.check(IndentParenExprArgs::from_for(self), acc);
871+
rules.indent_empty_loop.check(IndentEmptyLoopArgs::from_for_content(self, aux.depth), acc);
872+
rules.sp_reserved.check(SpReservedArgs::from_for(self), acc);
873873
}
874874
}
875875

@@ -1028,7 +1028,7 @@ impl TreeElement for SwitchCase {
10281028
}
10291029
}
10301030
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
1031-
rules.indent_switch_case.check(acc, IndentSwitchCaseArgs::from_switch_case(self, aux.depth));
1031+
rules.indent_switch_case.check(IndentSwitchCaseArgs::from_switch_case(self, aux.depth), acc);
10321032
}
10331033
fn should_increment_depth(&self) -> bool {
10341034
matches!(self, SwitchCase::Statement(statement)
@@ -1118,8 +1118,8 @@ impl TreeElement for SwitchContent {
11181118
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>,
11191119
rules: &CurrentRules, aux: AuxParams)
11201120
{
1121-
rules.indent_closing_brace.check(acc, IndentClosingBraceArgs::from_switch_content(self, aux.depth));
1122-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_switch(self));
1121+
rules.indent_closing_brace.check(IndentClosingBraceArgs::from_switch_content(self, aux.depth), acc);
1122+
rules.indent_paren_expr.check(IndentParenExprArgs::from_switch(self), acc);
11231123
}
11241124
}
11251125

@@ -1290,7 +1290,7 @@ impl TreeElement for AfterContent {
12901290
&self.semi)
12911291
}
12921292
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
1293-
rules.sp_reserved.check(acc, SpReservedArgs::from_after_content(self));
1293+
rules.sp_reserved.check(SpReservedArgs::from_after_content(self), acc);
12941294
}
12951295
}
12961296

@@ -1618,7 +1618,7 @@ impl TreeElement for ForeachContent {
16181618
&self.statement)
16191619
}
16201620
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
1621-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_foreach(self));
1621+
rules.indent_paren_expr.check(IndentParenExprArgs::from_foreach(self), acc);
16221622
}
16231623
}
16241624

@@ -1757,7 +1757,7 @@ impl TreeElement for ExpressionStmtContent {
17571757
create_subs!(&self.expression, &self.semi)
17581758
}
17591759
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
1760-
rules.sp_punct.check(acc, SpPunctArgs::from_expression_stmt(self));
1760+
rules.sp_punct.check(SpPunctArgs::from_expression_stmt(self), acc);
17611761
}
17621762
}
17631763

src/analysis/parsing/structure.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ impl TreeElement for MethodContent {
233233
errors
234234
}
235235
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
236-
rules.nsp_funpar.check(acc, NspFunparArgs::from_method(self));
237-
rules.nsp_inparen.check(acc, NspInparenArgs::from_method(self));
238-
rules.sp_punct.check(acc, SpPunctArgs::from_method(self));
239-
rules.indent_paren_expr.check(acc, IndentParenExprArgs::from_method(self));
236+
rules.nsp_funpar.check(NspFunparArgs::from_method(self), acc);
237+
rules.nsp_inparen.check(NspInparenArgs::from_method(self), acc);
238+
rules.sp_punct.check(SpPunctArgs::from_method(self), acc);
239+
rules.indent_paren_expr.check(IndentParenExprArgs::from_method(self), acc);
240240
}
241241
}
242242

@@ -703,9 +703,9 @@ impl TreeElement for ObjectStatementsContent {
703703
}
704704
}
705705
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
706-
rules.sp_brace.check(acc, SpBracesArgs::from_obj_stmts(self));
707-
rules.indent_code_block.check(acc, IndentCodeBlockArgs::from_obj_stmts_content(self, aux.depth));
708-
rules.indent_closing_brace.check(acc, IndentClosingBraceArgs::from_obj_stmts_content(self, aux.depth));
706+
rules.sp_brace.check(SpBracesArgs::from_obj_stmts(self), acc);
707+
rules.indent_code_block.check(IndentCodeBlockArgs::from_obj_stmts_content(self, aux.depth), acc);
708+
rules.indent_closing_brace.check(IndentClosingBraceArgs::from_obj_stmts_content(self, aux.depth), acc);
709709
}
710710
fn should_increment_depth(&self) -> bool {
711711
matches!(self, ObjectStatementsContent::List(lbrace, list, rbrace)

src/analysis/parsing/types.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ impl TreeElement for StructTypeContent {
5555
errors
5656
}
5757
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
58-
rules.indent_code_block.check(acc, IndentCodeBlockArgs::from_struct_type_content(self, aux.depth));
59-
rules.indent_closing_brace.check(acc, IndentClosingBraceArgs::from_struct_type_content(self, aux.depth));
60-
rules.sp_brace.check(acc, SpBracesArgs::from_struct_type_content(self));
58+
rules.indent_code_block.check(IndentCodeBlockArgs::from_struct_type_content(self, aux.depth), acc);
59+
rules.indent_closing_brace.check(IndentClosingBraceArgs::from_struct_type_content(self, aux.depth), acc);
60+
rules.sp_brace.check(SpBracesArgs::from_struct_type_content(self), acc);
6161
}
6262
fn should_increment_depth(&self) -> bool {
6363
true
@@ -138,9 +138,9 @@ impl TreeElement for LayoutContent {
138138
errors
139139
}
140140
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
141-
rules.indent_code_block.check(acc, IndentCodeBlockArgs::from_layout_content(self, aux.depth));
142-
rules.indent_closing_brace.check(acc, IndentClosingBraceArgs::from_layout_content(self, aux.depth));
143-
rules.sp_brace.check(acc, SpBracesArgs::from_layout_content(self));
141+
rules.indent_code_block.check(IndentCodeBlockArgs::from_layout_content(self, aux.depth), acc);
142+
rules.indent_closing_brace.check(IndentClosingBraceArgs::from_layout_content(self, aux.depth), acc);
143+
rules.sp_brace.check(SpBracesArgs::from_layout_content(self), acc);
144144
}
145145
fn should_increment_depth(&self) -> bool {
146146
true
@@ -315,9 +315,9 @@ impl TreeElement for BitfieldsContent {
315315
errors
316316
}
317317
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
318-
rules.sp_brace.check(acc, SpBracesArgs::from_bitfields_content(self));
319-
rules.indent_code_block.check(acc, IndentCodeBlockArgs::from_bitfields_content(self, aux.depth));
320-
rules.indent_closing_brace.check(acc, IndentClosingBraceArgs::from_bitfields_content(self, aux.depth));
318+
rules.sp_brace.check(SpBracesArgs::from_bitfields_content(self), acc);
319+
rules.indent_code_block.check(IndentCodeBlockArgs::from_bitfields_content(self, aux.depth), acc);
320+
rules.indent_closing_brace.check(IndentClosingBraceArgs::from_bitfields_content(self, aux.depth), acc);
321321
}
322322
fn should_increment_depth(&self) -> bool {
323323
true

src/lint/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ pub fn begin_style_check(ast: TopAst, file: String, rules: &CurrentRules) -> Res
185185
// Per line checks
186186
let lines: Vec<&str> = file.lines().collect();
187187
for (row, line) in lines.iter().enumerate() {
188-
rules.indent_no_tabs.check(&mut linting_errors, row, line);
189-
rules.long_lines.check(&mut linting_errors, row, line);
190-
rules.nsp_trailing.check(&mut linting_errors, row, line);
188+
rules.indent_no_tabs.check(row, line, &mut linting_errors);
189+
rules.long_lines.check(row, line, &mut linting_errors);
190+
rules.nsp_trailing.check(row, line, &mut linting_errors);
191191
}
192192

193193
post_process_linting_errors(&mut linting_errors);

src/lint/rules/indentation.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl LongLinesRule {
5959
},
6060
}
6161
}
62-
pub fn check(&self, acc: &mut Vec<DMLStyleError>, row: usize, line: &str) {
62+
pub fn check(&self, row: usize, line: &str, acc: &mut Vec<DMLStyleError>) {
6363
if !self.enabled { return; }
6464
let len = line.len().try_into().unwrap();
6565
if len > self.max_length {
@@ -95,7 +95,7 @@ pub struct IndentNoTabRule {
9595
}
9696

9797
impl IndentNoTabRule {
98-
pub fn check(&self, acc: &mut Vec<DMLStyleError>, row: usize, line: &str) {
98+
pub fn check(&self, row: usize, line: &str, acc: &mut Vec<DMLStyleError>) {
9999
if !self.enabled { return; }
100100
let rowu32 = row.try_into().unwrap();
101101

@@ -197,9 +197,9 @@ impl IndentCodeBlockRule {
197197
}
198198
}
199199
}
200-
pub fn check(&self, acc: &mut Vec<DMLStyleError>,
201-
args: Option<IndentCodeBlockArgs>)
202-
{
200+
pub fn check(&self,
201+
args: Option<IndentCodeBlockArgs>,
202+
acc: &mut Vec<DMLStyleError>) {
203203
if !self.enabled { return; }
204204
let Some(args) = args else { return; };
205205
if args.members_ranges.is_empty() { return; }
@@ -340,7 +340,9 @@ impl IndentClosingBraceRule {
340340
}
341341
}
342342

343-
pub fn check(&self, acc: &mut Vec<DMLStyleError>, args: Option<IndentClosingBraceArgs>) {
343+
pub fn check(&self,
344+
args: Option<IndentClosingBraceArgs>,
345+
acc: &mut Vec<DMLStyleError>) {
344346
if !self.enabled { return; }
345347
let Some(args) = args else { return; };
346348

@@ -489,8 +491,9 @@ impl IndentParenExprArgs {
489491
}
490492

491493
impl IndentParenExprRule {
492-
pub fn check(&self, acc: &mut Vec<DMLStyleError>,
493-
args: Option<IndentParenExprArgs>) {
494+
pub fn check(&self,
495+
args: Option<IndentParenExprArgs>,
496+
acc: &mut Vec<DMLStyleError>) {
494497
if !self.enabled { return; }
495498
let Some(args) = args else { return; };
496499
let expected_line_start = args.lparen.col_start.0 + 1;
@@ -573,9 +576,9 @@ impl IndentSwitchCaseRule {
573576
}
574577
}
575578
}
576-
pub fn check(&self, acc: &mut Vec<DMLStyleError>,
577-
args: Option<IndentSwitchCaseArgs>)
578-
{
579+
pub fn check(&self,
580+
args: Option<IndentSwitchCaseArgs>,
581+
acc: &mut Vec<DMLStyleError>) {
579582
if !self.enabled { return; }
580583
let Some(args) = args else { return; };
581584
if self.indentation_is_not_aligned(args.case_range, args.expected_depth) {
@@ -659,9 +662,9 @@ impl IndentEmptyLoopRule {
659662
}
660663
}
661664
}
662-
pub fn check(&self, acc: &mut Vec<DMLStyleError>,
663-
args: Option<IndentEmptyLoopArgs>)
664-
{
665+
pub fn check(&self,
666+
args: Option<IndentEmptyLoopArgs>,
667+
acc: &mut Vec<DMLStyleError>) {
665668
if !self.enabled { return; }
666669
let Some(args) = args else { return; };
667670
if self.indentation_is_not_aligned(args.semicolon_range, args.expected_depth) ||

0 commit comments

Comments
 (0)