From 6c28376e503ab48f230d06b2e41456e6bb3b12ff Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 30 Dec 2020 21:17:28 -0600 Subject: [PATCH] refactor: Give checks full control --- src/checks.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/checks.rs b/src/checks.rs index 01bfd91..c84c76a 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -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> { @@ -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(())