Skip to content

Commit

Permalink
bugfix257 Reinitialize linter for each file.
Browse files Browse the repository at this point in the history
- I've called this Option3 in the comments of dalance#257.
- Clone of `config` might be avoided, but this is the lowest-effort change.
  • Loading branch information
DaveMcEwan committed Jun 28, 2023
1 parent b306465 commit 3e97cf8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ pub fn run_opt_config(printer: &mut Printer, opt: &Opt, config: Config) -> Resul
not_obsolete = false;
}

let mut linter = Linter::new(config);
for plugin in &opt.plugins {
linter.load(&plugin)?;
}

let mut defines = HashMap::new();
for define in &opt.defines {
let mut define = define.splitn(2, '=');
Expand Down Expand Up @@ -265,12 +260,17 @@ pub fn run_opt_config(printer: &mut Printer, opt: &Opt, config: Config) -> Resul
}
}
} else {
// Iterate over lines in the file, applying each textrule to each
// line in turn.

let text: String = read_to_string(&path)?;
let mut linter = Linter::new(config.clone());
for plugin in &opt.plugins {
linter.load(&plugin)?;
}

let text: String = read_to_string(&path)?;
let mut beg: usize = 0;

// Iterate over lines in the file, applying each textrule to each
// line in turn.
for line in text.split_inclusive('\n') {
let line_stripped = line.trim_end_matches(&['\n', '\r']);

Expand All @@ -285,9 +285,9 @@ pub fn run_opt_config(printer: &mut Printer, opt: &Opt, config: Config) -> Resul

match parse_sv_str(text.as_str(), &path, &defines, &includes, opt.ignore_include, false) {
Ok((syntax_tree, new_defines)) => {

// Iterate over nodes in the concrete syntax tree, applying
// each syntaxrule to each node in turn.

for node in syntax_tree.into_iter().event() {
for failed in linter.syntaxrules_check(&syntax_tree, &node) {
pass = false;
Expand Down

0 comments on commit 3e97cf8

Please sign in to comment.