From 9518d158e8117378449824fe46302746c488e77b Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Tue, 5 Jan 2021 08:18:08 +0100 Subject: [PATCH] Fix clippy warning --- packages/hurl/src/http/client.rs | 2 +- packages/hurl/src/main.rs | 2 +- packages/hurl_core/src/parser/base64.rs | 2 +- packages/hurl_core/src/parser/expr.rs | 2 +- packages/hurlfmt/src/format/token.rs | 2 +- packages/hurlfmt/src/linter/rules.rs | 4 ++-- packages/hurlfmt/src/main.rs | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/hurl/src/http/client.rs b/packages/hurl/src/http/client.rs index f5e152ac9..4ba4d653e 100644 --- a/packages/hurl/src/http/client.rs +++ b/packages/hurl/src/http/client.rs @@ -453,7 +453,7 @@ impl Client { } let response_code = self.handle.response_code().unwrap(); - if response_code < 300 || response_code >= 400 { + if !(300..400).contains(&response_code) { return None; } diff --git a/packages/hurl/src/main.rs b/packages/hurl/src/main.rs index 6e8b31b12..e3403e0ce 100644 --- a/packages/hurl/src/main.rs +++ b/packages/hurl/src/main.rs @@ -74,7 +74,7 @@ fn execute( .split(&contents) .map(|l| l.to_string()) .collect(); - let optional_filename = if filename == "" { + let optional_filename = if filename.is_empty() { None } else { Some(filename.to_string()) diff --git a/packages/hurl_core/src/parser/base64.rs b/packages/hurl_core/src/parser/base64.rs index ed29685bf..86c2a5282 100644 --- a/packages/hurl_core/src/parser/base64.rs +++ b/packages/hurl_core/src/parser/base64.rs @@ -40,7 +40,7 @@ pub fn parse(reader: &mut Reader) -> Vec { let mut buf = vec![]; // base64 text loop { let pad = padding(reader); - if pad != "" { + if !pad.is_empty() { break; } let save = reader.state.clone(); diff --git a/packages/hurl_core/src/parser/expr.rs b/packages/hurl_core/src/parser/expr.rs index 89163772b..800beeee5 100644 --- a/packages/hurl_core/src/parser/expr.rs +++ b/packages/hurl_core/src/parser/expr.rs @@ -59,7 +59,7 @@ pub fn parse2(reader: &mut Reader) -> ParseResult<'static, Expr> { fn variable_name(reader: &mut Reader) -> ParseResult<'static, Variable> { let start = reader.state.clone(); let name = reader.read_while(|c| c.is_alphanumeric() || *c == '_'); - if name == "" { + if name.is_empty() { return Err(Error { pos: start.pos, recoverable: false, diff --git a/packages/hurlfmt/src/format/token.rs b/packages/hurlfmt/src/format/token.rs index af8c61cc0..9056f2853 100644 --- a/packages/hurlfmt/src/format/token.rs +++ b/packages/hurlfmt/src/format/token.rs @@ -760,7 +760,7 @@ impl Tokenizable for LineTerminator { impl Tokenizable for Whitespace { fn tokenize(&self) -> Vec { let mut tokens: Vec = vec![]; - if self.value != "" { + if !self.value.is_empty() { tokens.push(Token::Whitespace(self.clone().value)); } tokens diff --git a/packages/hurlfmt/src/linter/rules.rs b/packages/hurlfmt/src/linter/rules.rs index 33626954a..85a206063 100644 --- a/packages/hurlfmt/src/linter/rules.rs +++ b/packages/hurlfmt/src/linter/rules.rs @@ -685,7 +685,7 @@ impl Lintable for LineTerminator { } } None => { - if self.space0.value != "" { + if !self.space0.value.is_empty() { errors.push(Error { source_info: self.clone().space0.source_info, inner: LinterError::UnneccessarySpace {}, @@ -709,7 +709,7 @@ impl Lintable for LineTerminator { Some(comment) => Some(comment.lint()), }; let newline = Whitespace { - value: if self.newline.value == "" { + value: if self.newline.value.is_empty() { "".to_string() } else { "\n".to_string() diff --git a/packages/hurlfmt/src/main.rs b/packages/hurlfmt/src/main.rs index e9b6abd11..8f867194b 100644 --- a/packages/hurlfmt/src/main.rs +++ b/packages/hurlfmt/src/main.rs @@ -158,7 +158,7 @@ fn main() { .collect(); let lines: Vec = lines.iter().map(|s| (*s).to_string()).collect(); - let optional_filename = if filename == "" { + let optional_filename = if filename.is_empty() { None } else { Some(filename.to_string())