Skip to content

Commit 9e616a7

Browse files
authored
Merge pull request #12 from kevv87/feat/remove-in6-code
Remove IN6 code
2 parents 1b14379 + 7620dda commit 9e616a7

File tree

6 files changed

+3
-171
lines changed

6 files changed

+3
-171
lines changed

example_files/example_lint_cfg.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"in1": { "indentation_spaces": 4 },
1010
"in2": {},
1111
"in3": {},
12-
"in6": {},
1312
"in9": {},
1413
"in10": {}
1514
}

src/lint/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use rules::{instantiate_rules, CurrentRules, RuleType};
77
use rules::{spacing::{SpBraceOptions, SpPunctOptions, NspFunparOptions,
88
NspInparenOptions, NspUnaryOptions, NspTrailingOptions},
99
indentation::{LongLineOptions, IN1Options, IN3Options,
10-
IN2Options, IN9Options, IN6Options,
11-
IN10Options},
10+
IN2Options, IN9Options, IN10Options},
1211
};
1312
use crate::analysis::{DMLError, IsolatedAnalysis, LocalDMLError};
1413
use crate::analysis::parsing::tree::TreeElement;
@@ -67,8 +66,6 @@ pub struct LintCfg {
6766
#[serde(default)]
6867
pub in3: Option<IN3Options>,
6968
#[serde(default)]
70-
pub in6: Option<IN6Options>,
71-
#[serde(default)]
7269
pub in9: Option<IN9Options>,
7370
#[serde(default)]
7471
pub in10: Option<IN10Options>,
@@ -87,7 +84,6 @@ impl Default for LintCfg {
8784
in1: Some(IN1Options{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
8885
in2: Some(IN2Options{}),
8986
in3: Some(IN3Options{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
90-
in6: Some(IN6Options{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
9187
in9: Some(IN9Options{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
9288
in10: Some(IN10Options{indentation_spaces: INDENTATION_LEVEL_DEFAULT}),
9389
}
@@ -147,9 +143,6 @@ pub fn begin_style_check(ast: TopAst, file: String, rules: &CurrentRules) -> Res
147143
rules.nsp_trailing.check(&mut linting_errors, row, line);
148144
}
149145

150-
// Continuation line check
151-
rules.in6.check(&mut linting_errors, &lines);
152-
153146
post_process_linting_errors(&mut linting_errors);
154147

155148
Ok(linting_errors.into_iter().map(|e| e.error).collect())

src/lint/rules/indentation.rs

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::analysis::parsing::{statement::{self, CompoundContent, ForContent,
44
SwitchCase, WhileContent},
55
structure::ObjectStatementsContent,
66
types::{BitfieldsContent, LayoutContent, StructTypeContent}};
7-
use crate::span::{Range, ZeroIndexed, Row, Column};
7+
use crate::span::{Range, ZeroIndexed};
88
use crate::analysis::LocalDMLError;
99
use crate::analysis::parsing::tree::{ZeroRange, Content, TreeElement};
1010
use serde::{Deserialize, Serialize};
@@ -27,9 +27,6 @@ pub fn setup_indentation_size(cfg: &mut LintCfg) {
2727
if let Some(in3) = &mut cfg.in3 {
2828
in3.indentation_spaces = indentation_spaces;
2929
}
30-
if let Some(in6) = &mut cfg.in6 {
31-
in6.indentation_spaces = indentation_spaces;
32-
}
3330
if let Some(in9) = &mut cfg.in9 {
3431
in9.indentation_spaces = indentation_spaces;
3532
}
@@ -251,92 +248,6 @@ impl Rule for IN3Rule {
251248
}
252249
}
253250

254-
// IN6: Continuation Line
255-
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
256-
pub struct IN6Options {
257-
#[serde(default = "default_indentation_spaces")]
258-
pub indentation_spaces: u32,
259-
}
260-
261-
pub struct IN6Rule {
262-
pub enabled: bool,
263-
pub indentation_spaces: u32,
264-
}
265-
266-
impl IN6Rule {
267-
pub fn from_options(options: &Option<IN6Options>) -> IN6Rule {
268-
match options {
269-
Some(in6) => IN6Rule {
270-
enabled: true,
271-
indentation_spaces: in6.indentation_spaces,
272-
},
273-
None => IN6Rule {
274-
enabled: false,
275-
indentation_spaces: 0,
276-
},
277-
}
278-
}
279-
280-
pub fn check(&self, acc: &mut Vec<DMLStyleError>, lines: &[&str]) {
281-
if !self.enabled {
282-
return;
283-
}
284-
285-
let arithmetic_operators = ["+", "-", "*", "/", "%", "="];
286-
let comparison_operators = ["==", "!=", "<", ">", "<=", ">="];
287-
let logical_operators = ["&&", "||"];
288-
let bitwise_operators = ["&", "|", "<<", ">>"];
289-
290-
let operators = [
291-
&arithmetic_operators[..],
292-
&comparison_operators[..],
293-
&logical_operators[..],
294-
&bitwise_operators[..],
295-
];
296-
297-
for (i, line) in lines.iter().enumerate() {
298-
if let Some(last_char) = line.trim().chars().last() {
299-
if operators.iter().any(|ops| ops.contains(&last_char.to_string().as_str())) {
300-
let next_line = lines.get(i + 1);
301-
if let Some(next_line) = next_line {
302-
let expected_indent = line.chars().take_while(|c| c.is_whitespace()).count() + self.indentation_spaces as usize;
303-
let actual_indent = next_line.chars().take_while(|c| c.is_whitespace()).count();
304-
if actual_indent != expected_indent {
305-
let msg = IN6Rule::description().to_owned();
306-
let dmlerror = DMLStyleError {
307-
error: LocalDMLError {
308-
range: Range::new(
309-
Row::new_zero_indexed((i + 1) as u32),
310-
Row::new_zero_indexed((i + 1) as u32),
311-
Column::new_zero_indexed(0),
312-
Column::new_zero_indexed(next_line.len() as u32)
313-
),
314-
description: msg,
315-
},
316-
rule_type: Self::get_rule_type(),
317-
};
318-
acc.push(dmlerror);
319-
}
320-
}
321-
}
322-
}
323-
}
324-
}
325-
}
326-
327-
impl Rule for IN6Rule {
328-
fn name() -> &'static str {
329-
"IN6_CONTINUATION_LINE"
330-
}
331-
332-
fn description() -> &'static str {
333-
"Continuation line not indented correctly."
334-
}
335-
fn get_rule_type() -> RuleType {
336-
RuleType::IN6
337-
}
338-
}
339-
340251
pub struct IN9Rule {
341252
pub enabled: bool,
342253
indentation_spaces: u32

src/lint/rules/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub mod tests;
77
use spacing::{SpBracesRule,
88
SpPunctRule, NspFunparRule, NspInparenRule,
99
NspUnaryRule, NspTrailingRule};
10-
use indentation::{LongLinesRule, IN2Rule, IN3Rule, IN6Rule, IN9Rule, IN10Rule};
10+
use indentation::{LongLinesRule, IN2Rule, IN3Rule, IN9Rule, IN10Rule};
1111
use crate::lint::LintCfg;
1212

1313
pub struct CurrentRules {
@@ -20,7 +20,6 @@ pub struct CurrentRules {
2020
pub long_lines: LongLinesRule,
2121
pub in2: IN2Rule,
2222
pub in3: IN3Rule,
23-
pub in6: IN6Rule,
2423
pub in9: IN9Rule,
2524
pub in10: IN10Rule
2625
}
@@ -36,7 +35,6 @@ pub fn instantiate_rules(cfg: &LintCfg) -> CurrentRules {
3635
long_lines: LongLinesRule::from_options(&cfg.long_lines),
3736
in2: IN2Rule { enabled: cfg.in2.is_some() },
3837
in3: IN3Rule::from_options(&cfg.in3),
39-
in6: IN6Rule::from_options(&cfg.in6),
4038
in9: IN9Rule::from_options(&cfg.in9),
4139
in10: IN10Rule::from_options(&cfg.in10)
4240
}

src/lint/rules/tests/indentation/in6.rs

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub mod in2;
22
pub mod in3;
3-
pub mod in6;
43
pub mod in9;
54
pub mod in10;
65

0 commit comments

Comments
 (0)