Skip to content

Commit 308ee69

Browse files
committed
Apply consistent naming convention for linelength rules
1 parent b34ea26 commit 308ee69

File tree

13 files changed

+64
-64
lines changed

13 files changed

+64
-64
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_conditional_expression": {},
23+
"break_method_output": {},
24+
"break_conditional_expression_before_op": {},
2525
"break_before_binary_op": {},
2626
"annotate_lints": true
2727
}

src/analysis/parsing/expression.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ 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
165+
rules.break_conditional_expression_before_op
166166
.check(ConditionalExpressionBreakBeforeOperatorArgs::from_tertiary_expression(self), acc);
167167
}
168168
}
@@ -183,7 +183,7 @@ 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(
186+
rules.break_conditional_expression.check(
187187
FuncCallBreakOnOpenParenArgs::from_paren_expression(self, aux.depth), acc);
188188
}
189189
}
@@ -235,7 +235,7 @@ 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
238+
rules.break_conditional_expression
239239
.check(FuncCallBreakOnOpenParenArgs::from_function_call(self, aux.depth), acc);
240240
}
241241
}
@@ -352,7 +352,7 @@ 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
355+
rules.break_conditional_expression
356356
.check(FuncCallBreakOnOpenParenArgs::from_cast(self, aux.depth), acc);
357357
}
358358
}

src/analysis/parsing/structure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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_conditional_expression.check(FuncCallBreakOnOpenParenArgs::from_method(self, aux.depth), acc);
248+
rules.break_method_output.check(MethodOutputBreakArgs::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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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_conditional_expression: Option<FuncCallBreakOnOpenParenOptions>,
122122
#[serde(default)]
123-
pub conditional_expression_break_before_op: Option<ConditionalExpressionBreakBeforeOperatorOptions>,
123+
pub break_conditional_expression_before_op: Option<ConditionalExpressionBreakBeforeOperatorOptions>,
124124
#[serde(default)]
125-
pub method_output_break: Option<MethodOutputBreakOptions>,
125+
pub break_method_output: Option<MethodOutputBreakOptions>,
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_conditional_expression: Some(FuncCallBreakOnOpenParenOptions{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
175+
break_method_output: Some(MethodOutputBreakOptions{}),
176+
break_conditional_expression_before_op: Some(ConditionalExpressionBreakBeforeOperatorOptions{}),
177177
break_before_binary_op: Some(BreakBeforeBinaryOpOptions{}),
178178
annotate_lints: true,
179179
}

src/lint/rules/linebreaking.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct MethodOutputBreakOptions{
3232

3333
impl Rule for MethodOutputBreakRule {
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."
@@ -87,7 +87,7 @@ pub struct FuncCallBreakOnOpenParenOptions{
8787

8888
impl Rule for FuncCallBreakOnOpenParenRule {
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
@@ -332,7 +332,7 @@ pub struct ConditionalExpressionBreakBeforeOperatorOptions{
332332

333333
impl Rule for ConditionalExpressionBreakBeforeOperatorRule {
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 :."

src/lint/rules/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ pub struct CurrentRules {
5151
pub indent_switch_case: IndentSwitchCaseRule,
5252
pub indent_empty_loop: IndentEmptyLoopRule,
5353
pub indent_continuation_line: IndentContinuationLineRule,
54-
pub func_call_break_on_open_paren: FuncCallBreakOnOpenParenRule,
55-
pub method_output_break: MethodOutputBreakRule,
56-
pub conditional_expression_break_before_op: ConditionalExpressionBreakBeforeOperatorRule,
54+
pub break_conditional_expression: FuncCallBreakOnOpenParenRule,
55+
pub break_method_output: MethodOutputBreakRule,
56+
pub break_conditional_expression_before_op: ConditionalExpressionBreakBeforeOperatorRule,
5757
pub break_before_binary_op: BreakBeforeBinaryOpRule, // Placeholder for future rule
5858
}
5959

@@ -78,9 +78,9 @@ pub fn instantiate_rules(cfg: &LintCfg) -> CurrentRules {
7878
indent_switch_case: IndentSwitchCaseRule::from_options(&cfg.indent_switch_case),
7979
indent_empty_loop: IndentEmptyLoopRule::from_options(&cfg.indent_empty_loop),
8080
indent_continuation_line: IndentContinuationLineRule::from_options(&cfg.indent_continuation_line),
81-
func_call_break_on_open_paren: FuncCallBreakOnOpenParenRule::from_options(&cfg.func_call_break_on_open_paren),
82-
method_output_break: MethodOutputBreakRule { enabled: cfg.method_output_break.is_some() },
83-
conditional_expression_break_before_op: ConditionalExpressionBreakBeforeOperatorRule::from_options(&cfg.conditional_expression_break_before_op),
81+
break_conditional_expression: FuncCallBreakOnOpenParenRule::from_options(&cfg.break_conditional_expression),
82+
break_method_output: MethodOutputBreakRule { enabled: cfg.break_method_output.is_some() },
83+
break_conditional_expression_before_op: ConditionalExpressionBreakBeforeOperatorRule::from_options(&cfg.break_conditional_expression_before_op),
8484
break_before_binary_op: BreakBeforeBinaryOpRule { enabled: cfg.break_before_binary_op.is_some() },
8585
}
8686
}

src/lint/rules/tests/line_length_breaking/mod.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/lint/rules/tests/line_length_breaking/conditional_expression_break.rs renamed to src/lint/rules/tests/linelength/break_conditional_expression.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,50 @@ use crate::lint::rules::tests::common::{set_up, assert_snippet};
22
use crate::lint::rules::RuleType;
33

44

5-
static CORRECT_BREAK_BEFORE_QUESTION_MARK: &str = "
5+
static BEFORE_QUESTION_MARK_CORRECT: &str = "
66
method bootprep_type_to_string(uint8 prep_type) -> (const char*) {
77
return
88
prep_type == PREP_GENERAL
99
? \"PrepGeneral\" : \"PrepEarly\";
1010
}";
1111
#[test]
12-
fn condexpr_correct_break_before_question_mark() {
12+
fn before_question_mark_correct() {
1313
let rules = set_up();
1414
let expected_errors = vec![];
15-
assert_snippet(CORRECT_BREAK_BEFORE_QUESTION_MARK, expected_errors, &rules);
15+
assert_snippet(BEFORE_QUESTION_MARK_CORRECT, expected_errors, &rules);
1616
}
1717

18-
static CORRECT_BREAK_BEFORE_COLON_AND_QUESTION_MARK: &str = "
18+
static BEFORE_COLON_AND_QUESTION_MARK_CORRECT: &str = "
1919
method bootprep_type_to_string(uint8 prep_type) -> (const char*) {
2020
return
2121
prep_type == PREP_GENERAL
2222
? \"PrepGeneral\"
2323
: \"PrepEarly\";
2424
}";
2525
#[test]
26-
fn condexpr_correct_break_after_colon_and_question_mark() {
26+
fn after_colon_and_question_mark_correct() {
2727
let rules = set_up();
2828
let expected_errors = vec![];
29-
assert_snippet(CORRECT_BREAK_BEFORE_COLON_AND_QUESTION_MARK, expected_errors, &rules);
29+
assert_snippet(BEFORE_COLON_AND_QUESTION_MARK_CORRECT, expected_errors, &rules);
3030
}
3131

32-
static BREAK_ONLY_BEFORE_COLON: &str = "
32+
static ONLY_BEFORE_COLON: &str = "
3333
method harvest_resource() {
3434
harvest_resource(my->gas < GAS_THRESHOLD ? Rsrc_Gas
3535
: (my->minerals < MINERAL_THRESHOLD
3636
? Rsrc_Minerals : nearest_resource()));
3737
}";
3838
#[test]
39-
fn condexpr_only_before_colon() {
39+
fn only_before_colon() {
4040
let rules = set_up();
4141
let expected_errors = define_expected_errors!(
4242
RuleType::LL3,
4343
(3, 3, 21, 22),
4444
);
45-
assert_snippet(BREAK_ONLY_BEFORE_COLON, expected_errors, &rules);
45+
assert_snippet(ONLY_BEFORE_COLON, expected_errors, &rules);
4646
}
4747

48-
static CORRECT_NESTED: &str = "
48+
static NESTED_CORRECT: &str = "
4949
method bootprep_type_to_string(uint8 prep_type) -> (const char*) {
5050
return
5151
prep_type == PREP_GENERAL
@@ -54,13 +54,13 @@ method bootprep_type_to_string(uint8 prep_type) -> (const char*) {
5454
? \"PrepEarly\" : \"UnknownBootPrepType\";
5555
}";
5656
#[test]
57-
fn condexpr_correct_nested() {
57+
fn nested_correct() {
5858
let rules = set_up();
5959
let expected_errors = vec![];
60-
assert_snippet(CORRECT_NESTED, expected_errors, &rules);
60+
assert_snippet(NESTED_CORRECT, expected_errors, &rules);
6161
}
6262

63-
static BREAK_AFTER_OPERATORS_NESTED: &str = "
63+
static AFTER_OPERATORS_NESTED: &str = "
6464
method bootprep_type_to_string(uint8 prep_type) -> (const char*) {
6565
return
6666
prep_type == PREP_GENERAL ?
@@ -69,14 +69,14 @@ method bootprep_type_to_string(uint8 prep_type) -> (const char*) {
6969
\"UnknownBootPrepType\";
7070
}";
7171
#[test]
72-
fn condexpr_broken_after_operators_nested() {
72+
fn after_operators_nested() {
7373
let rules = set_up();
7474
let expected_errors = define_expected_errors!(
7575
RuleType::LL3,
7676
(3, 3, 34, 35),
7777
(4, 4, 22, 23),
7878
(5, 5, 46, 47),
7979
);
80-
assert_snippet(BREAK_AFTER_OPERATORS_NESTED, expected_errors, &rules);
80+
assert_snippet(AFTER_OPERATORS_NESTED, expected_errors, &rules);
8181
}
8282

src/lint/rules/tests/line_length_breaking/func_call_break_open_paren.rs renamed to src/lint/rules/tests/linelength/break_func_call_open_paren.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::lint::rules::RuleType;
44
// LL6: Function and method invocations can be broken after the opening parenthesis,
55
// with the continuation lines indented one level.
66

7-
static FUNCALL_BROKEN_AFTER_PAREN_EXCEPTION_CORRECT: &str = "
7+
static AFTER_PAREN_EXCEPTION_CORRECT: &str = "
88
method effect() {
99
callback(
1010
0xABC,
@@ -13,12 +13,12 @@ method effect() {
1313
}
1414
";
1515
#[test]
16-
fn funcall_broken_after_paren_exception_correct() {
16+
fn after_paren_exception_correct() {
1717
let rules = set_up();
18-
assert_snippet(FUNCALL_BROKEN_AFTER_PAREN_EXCEPTION_CORRECT, vec![], &rules);
18+
assert_snippet(AFTER_PAREN_EXCEPTION_CORRECT, vec![], &rules);
1919
}
2020

21-
static FUNCALL_BROKEN_AFTER_PAREN_EXCEPTION_INCORRECT: &str = "
21+
static AFTER_PAREN_EXCEPTION_INCORRECT: &str = "
2222
method effect() {
2323
callback(
2424
0xABC,
@@ -27,14 +27,14 @@ method effect() {
2727
}
2828
";
2929
#[test]
30-
fn funcall_broken_after_paren_exception_incorrect() {
30+
fn after_paren_exception_incorrect() {
3131
let rules = set_up();
3232
let expected_errors = define_expected_errors!(
3333
RuleType::LL6,
3434
(4, 4, 12, 22),
3535
(5, 5, 4, 9),
3636
);
37-
assert_snippet(FUNCALL_BROKEN_AFTER_PAREN_EXCEPTION_INCORRECT, expected_errors, &rules);
37+
assert_snippet(AFTER_PAREN_EXCEPTION_INCORRECT, expected_errors, &rules);
3838
}
3939

4040
static FIRST_LINE_INCORRECT: &str = "
@@ -55,7 +55,7 @@ fn first_line_incorrect() {
5555
assert_snippet(FIRST_LINE_INCORRECT, expected_errors, &rules);
5656
}
5757

58-
static PAREN_NESTED_CORRECT: &str = "
58+
static NESTED_PAREN_CORRECT: &str = "
5959
param result = (
6060
(reg0.val
6161
* reg1.enable.val)
@@ -64,12 +64,12 @@ param result = (
6464
";
6565

6666
#[test]
67-
fn paren_nested_correct(){
67+
fn nested_paren_correct(){
6868
let rules = set_up();
69-
assert_snippet(PAREN_NESTED_CORRECT, vec![], &rules);
69+
assert_snippet(NESTED_PAREN_CORRECT, vec![], &rules);
7070
}
7171

72-
static PAREN_NESTED_INCORRECT: &str = "
72+
static NESTED_PAREN_INCORRECT: &str = "
7373
param result = (
7474
(reg0.val
7575
* reg1.enable.val)
@@ -78,14 +78,14 @@ param result = (
7878
";
7979

8080
#[test]
81-
fn paren_nested_incorrect(){
81+
fn nested_paren_incorrect(){
8282
let rules = set_up();
8383
let expected_errors = define_expected_errors!(
8484
RuleType::LL6,
8585
(4, 4, 16, 17),
8686
(5, 5, 16, 17),
8787
);
88-
assert_snippet(PAREN_NESTED_INCORRECT, expected_errors, &rules);
88+
assert_snippet(NESTED_PAREN_INCORRECT, expected_errors, &rules);
8989
}
9090

9191
static METHOD_CORRECT: &str = "

0 commit comments

Comments
 (0)