Skip to content

Commit

Permalink
refactor: Give checks full control
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Page committed Jan 2, 2021
1 parent 220a79f commit 6c28376
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ pub trait Check: Send + Sync {

Ok(())
}

fn check_file(
&self,
path: &std::path::Path,
explicit: bool,
parser: &tokens::Tokenizer,
dictionary: &dyn Dictionary,
reporter: &dyn report::Report,
) -> Result<(), std::io::Error> {
self.check_filename(path, parser, dictionary, reporter)?;
self.check_file_content(path, explicit, parser, dictionary, reporter)?;
Ok(())
}
}

struct ReportContext<'m, 'r> {
Expand Down Expand Up @@ -491,8 +504,7 @@ fn check_entry(
let entry = entry?;
if entry.file_type().map(|t| t.is_file()).unwrap_or(true) {
let explicit = entry.depth() == 0;
checks.check_filename(entry.path(), parser, dictionary, reporter)?;
checks.check_file_content(entry.path(), explicit, parser, dictionary, reporter)?;
checks.check_file(entry.path(), explicit, parser, dictionary, reporter)?;
}

Ok(())
Expand Down

0 comments on commit 6c28376

Please sign in to comment.