From 60e4ece8c15c475d5f74b6fd2460f8f1535e37d1 Mon Sep 17 00:00:00 2001 From: Christopher Regali Date: Fri, 9 Dec 2022 09:42:08 +0100 Subject: [PATCH 1/2] Add annotations for clippy --- src/hash.rs | 2 ++ src/html.rs | 2 ++ src/pdf.rs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/hash.rs b/src/hash.rs index 3f7bf4a..f9bdcdd 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -88,6 +88,8 @@ pub fn compare_files>( } #[cfg(test)] +#![deny(clippy::unwrap_used)] +#![deny(clippy::expect_used)] mod test { use super::*; use crate::hash::HashFunction::Sha256; diff --git a/src/html.rs b/src/html.rs index b1b0765..b82d90b 100644 --- a/src/html.rs +++ b/src/html.rs @@ -97,6 +97,8 @@ pub fn compare_files>( } #[cfg(test)] +#![deny(clippy::unwrap_used)] +#![deny(clippy::expect_used)] mod test { use super::*; use test_log::test; diff --git a/src/pdf.rs b/src/pdf.rs index abddcde..a03f37f 100644 --- a/src/pdf.rs +++ b/src/pdf.rs @@ -70,6 +70,8 @@ pub fn compare_files>( } #[cfg(test)] +#![deny(clippy::unwrap_used)] +#![deny(clippy::expect_used)] mod test { use super::*; From 67e7b20e82bc57a04eafc1c0c34cd416212294b4 Mon Sep 17 00:00:00 2001 From: Christopher Regali Date: Fri, 9 Dec 2022 09:49:54 +0100 Subject: [PATCH 2/2] Add clippy allow unwrap / expect in tests Fix clippy lints --- clippy.toml | 2 ++ config_scheme.json | 13 +++++++++++++ src/csv/mod.rs | 2 -- src/csv/preprocessing.rs | 2 -- src/hash.rs | 8 +++----- src/html.rs | 8 +++----- src/lib.rs | 2 -- src/pdf.rs | 8 +++----- 8 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000..72db4f0 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,2 @@ +allow-unwrap-in-tests = true +allow-expect-in-tests = true \ No newline at end of file diff --git a/config_scheme.json b/config_scheme.json index 63281d9..dfe26af 100644 --- a/config_scheme.json +++ b/config_scheme.json @@ -287,6 +287,19 @@ } }, "additionalProperties": false + }, + { + "description": "PDF text compare", + "type": "object", + "required": [ + "PDFText" + ], + "properties": { + "PDFText": { + "$ref": "#/definitions/HTMLCompareConfig" + } + }, + "additionalProperties": false } ], "required": [ diff --git a/src/csv/mod.rs b/src/csv/mod.rs index 964046a..f0fa904 100644 --- a/src/csv/mod.rs +++ b/src/csv/mod.rs @@ -532,8 +532,6 @@ fn guess_format_from_reader(mut input: &mut R) -> Result Result<(), csv::Error> { } #[cfg(test)] -#[allow(clippy::unwrap_used)] -#[allow(clippy::expect_used)] mod tests { use super::*; use crate::csv::{Column, Delimiters, Error}; diff --git a/src/hash.rs b/src/hash.rs index f9bdcdd..9edec3c 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -18,11 +18,11 @@ pub enum HashFunction { /// Errors during hash checking pub enum Error { #[error("Failed to compile regex {0}")] - RegexCompilationError(#[from] regex::Error), + RegexCompilationFailed(#[from] regex::Error), #[error("Problem creating hash report {0}")] - ReportingError(#[from] report::Error), + ReportingFailure(#[from] report::Error), #[error("File access failed {0}")] - FileAccessError(#[from] FatIOError), + FileAccessProblem(#[from] FatIOError), } impl HashFunction { @@ -88,8 +88,6 @@ pub fn compare_files>( } #[cfg(test)] -#![deny(clippy::unwrap_used)] -#![deny(clippy::expect_used)] mod test { use super::*; use crate::hash::HashFunction::Sha256; diff --git a/src/html.rs b/src/html.rs index b82d90b..9303a25 100644 --- a/src/html.rs +++ b/src/html.rs @@ -44,11 +44,11 @@ impl Default for HTMLCompareConfig { /// Errors during html / plain text checking pub enum Error { #[error("Failed to compile regex {0}")] - RegexCompilationError(#[from] regex::Error), + RegexCompilationFailure(#[from] regex::Error), #[error("Problem creating hash report {0}")] - ReportingError(#[from] report::Error), + ReportingProblem(#[from] report::Error), #[error("File access failed {0}")] - FileAccessError(#[from] FatIOError), + FileAccessFailure(#[from] FatIOError), } pub fn compare_files>( @@ -97,8 +97,6 @@ pub fn compare_files>( } #[cfg(test)] -#![deny(clippy::unwrap_used)] -#![deny(clippy::expect_used)] mod test { use super::*; use test_log::test; diff --git a/src/lib.rs b/src/lib.rs index 0d0f672..09b5bdd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -263,8 +263,6 @@ pub fn get_schema() -> Result { } #[cfg(test)] -#[allow(clippy::unwrap_used)] -#[allow(clippy::expect_used)] mod tests { use super::*; use crate::image::ImageCompareConfig; diff --git a/src/pdf.rs b/src/pdf.rs index a03f37f..6029804 100644 --- a/src/pdf.rs +++ b/src/pdf.rs @@ -11,11 +11,11 @@ use vg_errortools::FatIOError; /// Errors during html / plain text checking pub enum Error { #[error("Failed to compile regex {0}")] - RegexCompilationError(#[from] regex::Error), + RegexCompilationFailure(#[from] regex::Error), #[error("Problem creating hash report {0}")] - ReportingError(#[from] report::Error), + ReportingFailure(#[from] report::Error), #[error("File access failed {0}")] - FileAccessError(#[from] FatIOError), + FileAccessProblem(#[from] FatIOError), #[error("PDF text extraction error {0}")] PdfTextExtractionFailed(#[from] pdf_extract::OutputError), } @@ -70,8 +70,6 @@ pub fn compare_files>( } #[cfg(test)] -#![deny(clippy::unwrap_used)] -#![deny(clippy::expect_used)] mod test { use super::*;