From 0fc18e90eabca63a2fb1685319261f0bfa6dd615 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Fri, 16 Dec 2022 10:15:13 +0100 Subject: [PATCH] Fix Clippy warnings 1.66.0 --- packages/hurl/src/cli/options.rs | 2 ++ packages/hurl/src/runner/body.rs | 2 +- packages/hurl/src/runner/response.rs | 2 +- packages/hurl/src/util/logger.rs | 2 +- packages/hurl_core/src/error/mod.rs | 6 +----- packages/hurlfmt/src/cli/logger.rs | 2 +- packages/hurlfmt/src/format/json.rs | 4 ++-- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/hurl/src/cli/options.rs b/packages/hurl/src/cli/options.rs index c160c894e..b58b1876c 100644 --- a/packages/hurl/src/cli/options.rs +++ b/packages/hurl/src/cli/options.rs @@ -403,6 +403,8 @@ pub fn app(version: &str) -> Command { } /// Parses command line options `matches`. +// FIXME: disallow this clippy warning because of https://github.com/rust-lang/rust-clippy/issues/9766 +#[allow(clippy::manual_filter)] pub fn parse_options(matches: &ArgMatches) -> Result { let cacert_file = match get::(matches, "cacert_file") { None => None, diff --git a/packages/hurl/src/runner/body.rs b/packages/hurl/src/runner/body.rs index 9f2d75a3e..89aada5b6 100644 --- a/packages/hurl/src/runner/body.rs +++ b/packages/hurl/src/runner/body.rs @@ -79,7 +79,7 @@ pub fn eval_file(filename: &Filename, context_dir: &ContextDir) -> Result Ok(value), Err(_) => Err(Error { source_info: filename.source_info.clone(), diff --git a/packages/hurl/src/runner/response.rs b/packages/hurl/src/runner/response.rs index 78cab6b65..5caedbd22 100644 --- a/packages/hurl/src/runner/response.rs +++ b/packages/hurl/src/runner/response.rs @@ -49,7 +49,7 @@ pub fn eval_version_status_asserts( if let StatusValue::Specific(v) = status.value { asserts.push(AssertResult::Status { actual: http_response.status as u64, - expected: v as u64, + expected: v, source_info: status.source_info.clone(), }); } diff --git a/packages/hurl/src/util/logger.rs b/packages/hurl/src/util/logger.rs index a28e77b54..4da7a87ff 100644 --- a/packages/hurl/src/util/logger.rs +++ b/packages/hurl/src/util/logger.rs @@ -457,7 +457,7 @@ fn error_string(filename: &str, content: &str, error: &dyn Error, colored: bool) } else { let line = lines.get(line_number - 1).unwrap(); let width = if error.source_info().end.column > column_number { - (error.source_info().end.column - column_number) as usize + error.source_info().end.column - column_number } else { 0 }; diff --git a/packages/hurl_core/src/error/mod.rs b/packages/hurl_core/src/error/mod.rs index b8555b165..aa7569e92 100644 --- a/packages/hurl_core/src/error/mod.rs +++ b/packages/hurl_core/src/error/mod.rs @@ -149,11 +149,7 @@ fn levenshtein_distance(s1: &str, s2: &str) -> usize { cmp::min(v1, cmp::min(v2, v3)) } fn delta(x: char, y: char) -> usize { - if x == y { - 0 - } else { - 1 - } + usize::from(x != y) } let mut column: Vec = (0..=v1.len()).collect(); diff --git a/packages/hurlfmt/src/cli/logger.rs b/packages/hurlfmt/src/cli/logger.rs index b586e7c4a..250391c1a 100644 --- a/packages/hurlfmt/src/cli/logger.rs +++ b/packages/hurlfmt/src/cli/logger.rs @@ -145,7 +145,7 @@ fn log_error( } } else { let line = lines.get(error.source_info().start.line - 1).unwrap(); - let width = (error.source_info().end.column - error.source_info().start.column) as usize; + let width = error.source_info().end.column - error.source_info().start.column; let mut tab_shift = 0; for (i, c) in line.chars().enumerate() { diff --git a/packages/hurlfmt/src/format/json.rs b/packages/hurlfmt/src/format/json.rs index 090c4dbf2..a9ae7e935 100644 --- a/packages/hurlfmt/src/format/json.rs +++ b/packages/hurlfmt/src/format/json.rs @@ -475,11 +475,11 @@ fn json_predicate_value(predicate_value: PredicateValue) -> (JValue, Option (JValue::Boolean(value), None), PredicateValue::Null {} => (JValue::Null, None), PredicateValue::Hex(value) => ( - JValue::String(base64::encode(&value.value)), + JValue::String(base64::encode(value.value)), Some("base64".to_string()), ), PredicateValue::Base64(value) => ( - JValue::String(base64::encode(&value.value)), + JValue::String(base64::encode(value.value)), Some("base64".to_string()), ), PredicateValue::Expression(value) => (JValue::String(value.to_string()), None),