diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-07 20:23:44 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-04-09 13:13:59 +0200 |
commit | 19169b76117db8b1d81f1aafa64a5440d042803d (patch) | |
tree | bdd07c05920f6217bd1512e6dc56c1d8fb1da6bf /sq | |
parent | 694680ae3b2192c102f1b9a4d342677545cac629 (diff) |
Lint: Use is_empty().
- https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
- https://rust-lang.github.io/rust-clippy/master/index.html#comparison_to_empty
Diffstat (limited to 'sq')
-rw-r--r-- | sq/build.rs | 2 | ||||
-rw-r--r-- | sq/src/commands/certify.rs | 4 | ||||
-rw-r--r-- | sq/src/commands/dump.rs | 2 | ||||
-rw-r--r-- | sq/src/commands/inspect.rs | 2 | ||||
-rw-r--r-- | sq/src/commands/key.rs | 2 | ||||
-rw-r--r-- | sq/src/commands/keyring.rs | 2 | ||||
-rw-r--r-- | sq/src/sq.rs | 8 |
7 files changed, 11 insertions, 11 deletions
diff --git a/sq/build.rs b/sq/build.rs index 4671370b..5cc59cc0 100644 --- a/sq/build.rs +++ b/sq/build.rs @@ -69,7 +69,7 @@ fn dump_help(sink: &mut dyn io::Write, writeln!(sink, "//! ```text")?; for line in help.trim_end().split("\n").skip(1) { - if line == "" { + if line.is_empty() { writeln!(sink, "//!")?; } else { writeln!(sink, "//! {}", line.trim_end())?; diff --git a/sq/src/commands/certify.rs b/sq/src/commands/certify.rs index 8779e5e3..746737b8 100644 --- a/sq/src/commands/certify.rs +++ b/sq/src/commands/certify.rs @@ -30,7 +30,7 @@ pub fn certify(config: Config, m: &clap::ArgMatches) .map(|s| s.parse()).unwrap_or(Ok(120))?; let regex = m.values_of("regex").map(|v| v.collect::<Vec<_>>()) .unwrap_or_default(); - if trust_depth == 0 && regex.len() > 0 { + if trust_depth == 0 && !regex.is_empty() { return Err( anyhow::format_err!("A regex only makes sense \ if the trust depth is greater than 0")); @@ -123,7 +123,7 @@ pub fn certify(config: Config, m: &clap::ArgMatches) while let Some(name) = n.next() { let value = n.next().unwrap(); - let (critical, name) = if name.len() > 0 + let (critical, name) = if !name.is_empty() && Some('!') == name.chars().next() { (true, &name[1..]) diff --git a/sq/src/commands/dump.rs b/sq/src/commands/dump.rs index 5cbd55cb..efc701f5 100644 --- a/sq/src/commands/dump.rs +++ b/sq/src/commands/dump.rs @@ -941,7 +941,7 @@ impl PacketDumper { fn dump_mpis(&self, output: &mut dyn io::Write, i: &str, chunks: &[&[u8]], keys: &[&str]) -> Result<()> { assert_eq!(chunks.len(), keys.len()); - if chunks.len() == 0 { + if chunks.is_empty() { return Ok(()); } diff --git a/sq/src/commands/inspect.rs b/sq/src/commands/inspect.rs index dd47c487..e4be6883 100644 --- a/sq/src/commands/inspect.rs +++ b/sq/src/commands/inspect.rs @@ -334,7 +334,7 @@ fn inspect_key_flags(flags: openpgp::types::KeyFlags) -> Option<String> { capabilities.push("split key") } - if capabilities.len() > 0 { + if !capabilities.is_empty() { Some(capabilities.join(", ")) } else { None diff --git a/sq/src/commands/key.rs b/sq/src/commands/key.rs index cd3cf4ef..daba78df 100644 --- a/sq/src/commands/key.rs +++ b/sq/src/commands/key.rs @@ -314,7 +314,7 @@ fn adopt(config: Config, m: &ArgMatches) -> Result<()> { } }) .collect(); - if missing.len() > 0 { + if !missing.is_empty() { return Err(anyhow::anyhow!( "Keys not found: {}", missing.iter().map(|&h| h.to_hex()).join(", "))); diff --git a/sq/src/commands/keyring.rs b/sq/src/commands/keyring.rs index a0fc92d2..51c5dd13 100644 --- a/sq/src/commands/keyring.rs +++ b/sq/src/commands/keyring.rs @@ -389,7 +389,7 @@ fn to_filename_fragment<S: AsRef<str>>(s: S) -> Option<String> { _ => None, }).for_each(|c| r.push(c)); - if r.len() > 0 { + if !r.is_empty() { Some(r) } else { None diff --git a/sq/src/sq.rs b/sq/src/sq.rs index d91534f3..fb6567f5 100644 --- a/sq/src/sq.rs +++ b/sq/src/sq.rs @@ -86,7 +86,7 @@ fn parse_duration(expiry: &str) -> Result<Duration> { .for_each(|_| ()); let junk = expiry.collect::<String>(); - if digits == "" { + if digits.is_empty() { return Err(anyhow::anyhow!( "--expiry: missing count \ (try: '2y' for 2 years)")); @@ -118,7 +118,7 @@ fn parse_duration(expiry: &str) -> Result<Duration> { suffix, digits, digits, digits, digits)), }; - if junk != "" { + if !junk.is_empty() { return Err(anyhow::anyhow!( "--expiry: contains trailing junk ('{:?}') \ (try: '{}{}')", @@ -278,7 +278,7 @@ fn decrypt_key<R>(key: Key<key::SecretParts, R>, passwords: &mut Vec<String>) { Ok(p) => { first = false; - if p == "" { + if p.is_empty() { // Give up. break; } @@ -500,7 +500,7 @@ fn main() -> Result<()> { while let Some(name) = n.next() { let value = n.next().unwrap(); - let (critical, name) = if name.len() > 0 + let (critical, name) = if !name.is_empty() && Some('!') == name.chars().next() { (true, &name[1..]) |