Skip to content

Commit d9825d1

Browse files
committed
Apply consistent naming convention for linelength rules
1 parent 6b44a59 commit d9825d1

File tree

13 files changed

+120
-120
lines changed

13 files changed

+120
-120
lines changed

example_files/example_lint_cfg.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"indent_switch_case": {},
2020
"indent_empty_loop": {},
2121
"indent_continuation_line": {},
22-
"func_call_break_on_open_paren": {},
23-
"method_output_break": {},
24-
"conditional_expression_break_before_op": {},
22+
"break_func_call_open_paren": {},
23+
"break_method_output": {},
24+
"break_conditional_expression": {},
2525
"break_before_binary_op": {},
2626
"annotate_lints": true
2727
}

src/analysis/parsing/expression.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ use crate::lint::{DMLStyleError,
2727
CurrentRules},
2828
AuxParams};
2929
use crate::lint::rules::indentation::IndentParenExprArgs;
30-
use crate::lint::rules::linebreaking::{BreakBeforeBinaryOpArgs,
31-
ConditionalExpressionBreakBeforeOperatorArgs,
32-
FuncCallBreakOnOpenParenArgs};
30+
use crate::lint::rules::linelength::{BreakBeforeBinaryOpArgs,
31+
BreakConditionalExpression,
32+
BreakFuncCallOpenParenArgs};
3333

3434
#[derive(Debug, Clone, PartialEq)]
3535
pub struct UnaryExpressionContent {
@@ -162,8 +162,8 @@ impl TreeElement for TertiaryExpressionContent {
162162
}
163163
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, _aux: AuxParams) {
164164
rules.sp_ternary.check(SpTernaryArgs::from_tertiary_expression_content(self), acc);
165-
rules.conditional_expression_break_before_op
166-
.check(ConditionalExpressionBreakBeforeOperatorArgs::from_tertiary_expression(self), acc);
165+
rules.break_conditional_expression
166+
.check(BreakConditionalExpression::from_tertiary_expression(self), acc);
167167
}
168168
}
169169

@@ -183,8 +183,8 @@ impl TreeElement for ParenExpressionContent {
183183
}
184184
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
185185
rules.indent_paren_expr.check(IndentParenExprArgs::from_paren_expression(self), acc);
186-
rules.func_call_break_on_open_paren.check(
187-
FuncCallBreakOnOpenParenArgs::from_paren_expression(self, aux.depth), acc);
186+
rules.break_func_call_open_paren.check(
187+
BreakFuncCallOpenParenArgs::from_paren_expression(self, aux.depth), acc);
188188
}
189189
}
190190

@@ -235,8 +235,8 @@ impl TreeElement for FunctionCallContent {
235235
rules.nsp_inparen.check(NspInparenArgs::from_function_call(self), acc);
236236
rules.sp_punct.check(SpPunctArgs::from_function_call(self), acc);
237237
rules.indent_paren_expr.check(IndentParenExprArgs::from_function_call(self), acc);
238-
rules.func_call_break_on_open_paren
239-
.check(FuncCallBreakOnOpenParenArgs::from_function_call(self, aux.depth), acc);
238+
rules.break_func_call_open_paren
239+
.check(BreakFuncCallOpenParenArgs::from_function_call(self, aux.depth), acc);
240240
}
241241
}
242242

@@ -352,8 +352,8 @@ impl TreeElement for CastContent {
352352
}
353353
fn evaluate_rules(&self, acc: &mut Vec<DMLStyleError>, rules: &CurrentRules, aux: AuxParams) {
354354
rules.indent_paren_expr.check(IndentParenExprArgs::from_cast(self), acc);
355-
rules.func_call_break_on_open_paren
356-
.check(FuncCallBreakOnOpenParenArgs::from_cast(self, aux.depth), acc);
355+
rules.break_func_call_open_paren
356+
.check(BreakFuncCallOpenParenArgs::from_cast(self, aux.depth), acc);
357357
}
358358
}
359359

src/analysis/parsing/structure.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::analysis::parsing::parser::{doesnt_understand_tokens,
1616
FileParser, Parse, ParseContext,
1717
FileInfo};
1818
use crate::analysis::LocalDMLError;
19-
use crate::lint::rules::linebreaking::{FuncCallBreakOnOpenParenArgs, MethodOutputBreakArgs};
19+
use crate::lint::rules::linelength::{BreakFuncCallOpenParenArgs, BreakMethodOutputArgs};
2020
use crate::lint::rules::spacing::{SpBracesArgs,
2121
NspInparenArgs,
2222
NspFunparArgs,
@@ -244,8 +244,8 @@ impl TreeElement for MethodContent {
244244
rules.nsp_inparen.check(NspInparenArgs::from_method(self), acc);
245245
rules.sp_punct.check(SpPunctArgs::from_method(self), acc);
246246
rules.indent_paren_expr.check(IndentParenExprArgs::from_method(self), acc);
247-
rules.func_call_break_on_open_paren.check(FuncCallBreakOnOpenParenArgs::from_method(self, aux.depth), acc);
248-
rules.method_output_break.check(MethodOutputBreakArgs::from_method(self), acc);
247+
rules.break_func_call_open_paren.check(BreakFuncCallOpenParenArgs::from_method(self, aux.depth), acc);
248+
rules.break_method_output.check(BreakMethodOutputArgs::from_method(self), acc);
249249
}
250250
}
251251

src/lint/features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Below are listed the currently supported rules for linting:
5353
+ another_very_long_expression)
5454
* a_third_long_expression;
5555
```
56-
- **LL3**, `conditional_expression_break`: Break conditional expressions before the ?, or both before the ? and before the :.
57-
- **LL5**, `method_output_break`: Break long method declarations with output parameters before the arrow.
56+
- **LL3**, `break_conditional_expression`: Break conditional expressions before the ?, or both before the ? and before the :.
57+
- **LL5**, `break_method_output`: Break long method declarations with output parameters before the arrow.
5858
```
5959
method inquiry_status(uint64 physical_address)
6060
-> (uint16 status) {

src/lint/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use std::path::{Path, PathBuf};
55
use std::str::FromStr;
66
use lazy_static::lazy_static;
77
use log::{debug, error, trace};
8-
use rules::linebreaking::{BreakBeforeBinaryOpOptions,
9-
FuncCallBreakOnOpenParenOptions,
10-
MethodOutputBreakOptions,
11-
ConditionalExpressionBreakBeforeOperatorOptions};
8+
use rules::linelength::{BreakBeforeBinaryOpOptions,
9+
BreakFuncCallOpenParenOptions,
10+
BreakMethodOutputOptions,
11+
BreakConditionalExpressionOptions};
1212
use serde::{Deserialize, Serialize};
1313
use regex::Regex;
1414
use rules::{instantiate_rules, CurrentRules, RuleType};
@@ -118,11 +118,11 @@ pub struct LintCfg {
118118
#[serde(default)]
119119
pub indent_continuation_line: Option<IndentContinuationLineOptions>,
120120
#[serde(default)]
121-
pub func_call_break_on_open_paren: Option<FuncCallBreakOnOpenParenOptions>,
121+
pub break_func_call_open_paren: Option<BreakFuncCallOpenParenOptions>,
122122
#[serde(default)]
123-
pub conditional_expression_break_before_op: Option<ConditionalExpressionBreakBeforeOperatorOptions>,
123+
pub break_conditional_expression: Option<BreakConditionalExpressionOptions>,
124124
#[serde(default)]
125-
pub method_output_break: Option<MethodOutputBreakOptions>,
125+
pub break_method_output: Option<BreakMethodOutputOptions>,
126126
#[serde(default)]
127127
pub break_before_binary_op: Option<BreakBeforeBinaryOpOptions>,
128128
#[serde(default = "get_true")]
@@ -171,9 +171,9 @@ impl Default for LintCfg {
171171
indent_switch_case: Some(IndentSwitchCaseOptions{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
172172
indent_empty_loop: Some(IndentEmptyLoopOptions{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
173173
indent_continuation_line: Some(IndentContinuationLineOptions{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
174-
func_call_break_on_open_paren: Some(FuncCallBreakOnOpenParenOptions{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
175-
method_output_break: Some(MethodOutputBreakOptions{}),
176-
conditional_expression_break_before_op: Some(ConditionalExpressionBreakBeforeOperatorOptions{}),
174+
break_func_call_open_paren: Some(BreakFuncCallOpenParenOptions{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
175+
break_method_output: Some(BreakMethodOutputOptions{}),
176+
break_conditional_expression: Some(BreakConditionalExpressionOptions{}),
177177
break_before_binary_op: Some(BreakBeforeBinaryOpOptions{}),
178178
annotate_lints: true,
179179
}

src/lint/rules/linebreaking.rs renamed to src/lint/rules/linelength.rs

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ fn default_indentation_spaces() -> u32 {
1616
INDENTATION_LEVEL_DEFAULT
1717
}
1818

19-
pub struct MethodOutputBreakRule {
19+
pub struct BreakMethodOutputRule {
2020
pub enabled: bool
2121
}
2222

23-
pub struct MethodOutputBreakArgs {
23+
pub struct BreakMethodOutputArgs {
2424
pub before_arrow_range: ZeroRange,
2525
pub arrow_range: ZeroRange,
2626
pub after_arrow_range: ZeroRange,
2727
}
2828

2929
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
30-
pub struct MethodOutputBreakOptions{
30+
pub struct BreakMethodOutputOptions{
3131
}
3232

33-
impl Rule for MethodOutputBreakRule {
33+
impl Rule for BreakMethodOutputRule {
3434
fn name() -> &'static str {
35-
"method_output_break"
35+
"break_method_output"
3636
}
3737
fn description() -> &'static str {
3838
"Break long method declarations with output parameters before the arrow."
@@ -42,19 +42,19 @@ impl Rule for MethodOutputBreakRule {
4242
}
4343
}
4444

45-
impl MethodOutputBreakArgs {
46-
pub fn from_method(node: &MethodContent) -> Option<MethodOutputBreakArgs> {
45+
impl BreakMethodOutputArgs {
46+
pub fn from_method(node: &MethodContent) -> Option<BreakMethodOutputArgs> {
4747
let Some(returns) = &node.returns else { return None; };
48-
Some(MethodOutputBreakArgs {
48+
Some(BreakMethodOutputArgs {
4949
before_arrow_range: node.rparen.range(),
5050
arrow_range: returns.0.range(),
5151
after_arrow_range: returns.1.range(),
5252
})
5353
}
5454
}
5555

56-
impl MethodOutputBreakRule {
57-
pub fn check(&self, args: Option<MethodOutputBreakArgs>, acc: &mut Vec<DMLStyleError>) {
56+
impl BreakMethodOutputRule {
57+
pub fn check(&self, args: Option<BreakMethodOutputArgs>, acc: &mut Vec<DMLStyleError>) {
5858
if !self.enabled { return; }
5959
let Some(args) = args else { return; };
6060
if args.before_arrow_range.row_end.0 == args.after_arrow_range.row_start.0 {
@@ -68,26 +68,26 @@ impl MethodOutputBreakRule {
6868
}
6969
}
7070

71-
pub struct FuncCallBreakOnOpenParenRule {
71+
pub struct BreakFuncCallOpenParenRule {
7272
pub enabled: bool,
7373
indentation_spaces: u32
7474
}
7575

76-
pub struct FuncCallBreakOnOpenParenArgs {
76+
pub struct BreakFuncCallOpenParenArgs {
7777
pub members_ranges: Vec<ZeroRange>,
7878
pub expected_depth: u32,
7979
pub lparen: ZeroRange,
8080
}
8181

8282
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
83-
pub struct FuncCallBreakOnOpenParenOptions{
83+
pub struct BreakFuncCallOpenParenOptions{
8484
#[serde(default = "default_indentation_spaces")]
8585
pub indentation_spaces: u32,
8686
}
8787

88-
impl Rule for FuncCallBreakOnOpenParenRule {
88+
impl Rule for BreakFuncCallOpenParenRule {
8989
fn name() -> &'static str {
90-
"FUNC_CALL_BREAK_ON_OPEN_PAREN"
90+
"break_func_call_open_paren"
9191
}
9292
fn description() -> &'static str {
9393
"Function or method calls broken right after opening parenthesis should
@@ -98,7 +98,7 @@ impl Rule for FuncCallBreakOnOpenParenRule {
9898
}
9999
}
100100

101-
impl FuncCallBreakOnOpenParenArgs {
101+
impl BreakFuncCallOpenParenArgs {
102102
pub fn filter_out_parenthesized_tokens(expression_tokens: TreeElementTokenIterator) -> Vec<Token> {
103103
let mut token_list: Vec<Token> = vec![];
104104
let mut paren_depth = 0;
@@ -125,7 +125,7 @@ impl FuncCallBreakOnOpenParenArgs {
125125
}
126126
token_list
127127
}
128-
pub fn from_function_call(node: &FunctionCallContent, depth: u32) -> Option<FuncCallBreakOnOpenParenArgs> {
128+
pub fn from_function_call(node: &FunctionCallContent, depth: u32) -> Option<BreakFuncCallOpenParenArgs> {
129129
let mut filtered_member_ranges: Vec<ZeroRange> = vec![];
130130
for (arg, _comma) in node.arguments.iter() {
131131
filtered_member_ranges.extend(
@@ -139,40 +139,40 @@ impl FuncCallBreakOnOpenParenArgs {
139139
filtered_member_ranges.first()?.to_owned()) {
140140
return None
141141
}
142-
Some(FuncCallBreakOnOpenParenArgs {
142+
Some(BreakFuncCallOpenParenArgs {
143143
members_ranges: filtered_member_ranges,
144144
expected_depth: depth,
145145
lparen: node.lparen.range(),
146146
})
147147
}
148148

149-
pub fn from_paren_expression(node: &ParenExpressionContent, depth: u32) -> Option<FuncCallBreakOnOpenParenArgs> {
150-
Some(FuncCallBreakOnOpenParenArgs {
149+
pub fn from_paren_expression(node: &ParenExpressionContent, depth: u32) -> Option<BreakFuncCallOpenParenArgs> {
150+
Some(BreakFuncCallOpenParenArgs {
151151
members_ranges: Self::filter_out_parenthesized_tokens(node.expr.tokens())
152152
.iter().map(|t| t.range).collect(),
153153
expected_depth: depth,
154154
lparen: node.lparen.range(),
155155
})
156156
}
157157

158-
pub fn from_method(node: &MethodContent, depth: u32) -> Option<FuncCallBreakOnOpenParenArgs> {
158+
pub fn from_method(node: &MethodContent, depth: u32) -> Option<BreakFuncCallOpenParenArgs> {
159159
let mut filtered_member_ranges: Vec<ZeroRange> = vec![];
160160
for (arg, _comma) in node.arguments.iter() {
161161
filtered_member_ranges.extend(
162162
Self::filter_out_parenthesized_tokens(arg.tokens())
163163
.iter().map(|t| t.range));
164164
}
165-
Some(FuncCallBreakOnOpenParenArgs {
165+
Some(BreakFuncCallOpenParenArgs {
166166
members_ranges: filtered_member_ranges,
167167
expected_depth: depth,
168168
lparen: node.lparen.range(),
169169
})
170170
}
171171

172-
pub fn from_cast(node: &CastContent, depth: u32) -> Option<FuncCallBreakOnOpenParenArgs> {
172+
pub fn from_cast(node: &CastContent, depth: u32) -> Option<BreakFuncCallOpenParenArgs> {
173173
let mut cast_member_tokens = node.from.tokens();
174174
cast_member_tokens.append(&mut node.to.tokens());
175-
Some(FuncCallBreakOnOpenParenArgs {
175+
Some(BreakFuncCallOpenParenArgs {
176176
members_ranges: Self::filter_out_parenthesized_tokens(cast_member_tokens)
177177
.iter().map(|t| t.range).collect(),
178178
expected_depth: depth,
@@ -181,21 +181,21 @@ impl FuncCallBreakOnOpenParenArgs {
181181
}
182182
}
183183

184-
impl FuncCallBreakOnOpenParenRule {
185-
pub fn from_options(options: &Option<FuncCallBreakOnOpenParenOptions>) -> FuncCallBreakOnOpenParenRule {
184+
impl BreakFuncCallOpenParenRule {
185+
pub fn from_options(options: &Option<BreakFuncCallOpenParenOptions>) -> BreakFuncCallOpenParenRule {
186186
match options {
187-
Some(options) => FuncCallBreakOnOpenParenRule {
187+
Some(options) => BreakFuncCallOpenParenRule {
188188
enabled: true,
189189
indentation_spaces: options.indentation_spaces
190190
},
191-
None => FuncCallBreakOnOpenParenRule {
191+
None => BreakFuncCallOpenParenRule {
192192
enabled: false,
193193
indentation_spaces: 0
194194
}
195195
}
196196
}
197197

198-
pub fn check(&self, args: Option<FuncCallBreakOnOpenParenArgs>, acc: &mut Vec<DMLStyleError>) {
198+
pub fn check(&self, args: Option<BreakFuncCallOpenParenArgs>, acc: &mut Vec<DMLStyleError>) {
199199
if !self.enabled { return; }
200200
let Some(args) = args else { return; };
201201
if args.members_ranges.is_empty() { return; }
@@ -271,11 +271,11 @@ impl Rule for BreakBeforeBinaryOpRule {
271271
}
272272
}
273273

274-
pub struct ConditionalExpressionBreakBeforeOperatorRule {
274+
pub struct BreakConditionalExpressionRule {
275275
pub enabled: bool,
276276
}
277277

278-
pub struct ConditionalExpressionBreakBeforeOperatorArgs {
278+
pub struct BreakConditionalExpression {
279279
pub left: ZeroRange,
280280
pub left_operation: ZeroRange,
281281
pub middle: ZeroRange,
@@ -284,10 +284,10 @@ pub struct ConditionalExpressionBreakBeforeOperatorArgs {
284284
}
285285

286286

287-
impl ConditionalExpressionBreakBeforeOperatorArgs {
287+
impl BreakConditionalExpression {
288288
pub fn from_tertiary_expression(node: &TertiaryExpressionContent)
289-
-> Option<ConditionalExpressionBreakBeforeOperatorArgs> {
290-
Some(ConditionalExpressionBreakBeforeOperatorArgs {
289+
-> Option<BreakConditionalExpression> {
290+
Some(BreakConditionalExpression {
291291
left: node.left.range(),
292292
left_operation: node.left_operation.range(),
293293
middle: node.middle.range(),
@@ -297,19 +297,19 @@ impl ConditionalExpressionBreakBeforeOperatorArgs {
297297
}
298298
}
299299

300-
impl ConditionalExpressionBreakBeforeOperatorRule {
301-
pub fn from_options(options: &Option<ConditionalExpressionBreakBeforeOperatorOptions>) -> ConditionalExpressionBreakBeforeOperatorRule {
300+
impl BreakConditionalExpressionRule {
301+
pub fn from_options(options: &Option<BreakConditionalExpressionOptions>) -> BreakConditionalExpressionRule {
302302
match options {
303-
Some(_options) => ConditionalExpressionBreakBeforeOperatorRule {
303+
Some(_options) => BreakConditionalExpressionRule {
304304
enabled: true,
305305
},
306-
None => ConditionalExpressionBreakBeforeOperatorRule {
306+
None => BreakConditionalExpressionRule {
307307
enabled: false,
308308
}
309309
}
310310
}
311311

312-
pub fn check(&self, args: Option<ConditionalExpressionBreakBeforeOperatorArgs>, acc: &mut Vec<DMLStyleError>) {
312+
pub fn check(&self, args: Option<BreakConditionalExpression>, acc: &mut Vec<DMLStyleError>) {
313313
if !self.enabled { return; }
314314
let Some(args) = args else { return; };
315315
let has_break_before_question_operator = args.left.row_end.0 != args.left_operation.row_start.0;
@@ -327,12 +327,12 @@ impl ConditionalExpressionBreakBeforeOperatorRule {
327327

328328

329329
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
330-
pub struct ConditionalExpressionBreakBeforeOperatorOptions{
330+
pub struct BreakConditionalExpressionOptions{
331331
}
332332

333-
impl Rule for ConditionalExpressionBreakBeforeOperatorRule {
333+
impl Rule for BreakConditionalExpressionRule {
334334
fn name() -> &'static str {
335-
"COND_EXPRESSION_BREAK_BEFORE_OPERATOR"
335+
"break_conditional_expression"
336336
}
337337
fn description() -> &'static str {
338338
"Break conditional expressions before the ?, or both before the ? and before the :."

0 commit comments

Comments
 (0)