From b5d99245f6a9876c9460072abad96e191e121aef Mon Sep 17 00:00:00 2001 From: "Tony Arcieri (iqlusion)" Date: Tue, 19 Mar 2024 17:33:05 +0000 Subject: [PATCH] Fix unused imports and future clippy warnings (#883) Recent nightlies have better diagnostics around unused imports. This fixes all of the current redundant imports. Additionally it uses `clippy --fix` on nightly to fix some upcoming clippy warnings. --- src/commands/init.rs | 2 +- src/commands/softsign/import.rs | 2 +- src/commands/softsign/keygen.rs | 2 +- src/commands/yubihsm/detect.rs | 2 +- src/commands/yubihsm/keys/export.rs | 4 ++-- src/commands/yubihsm/keys/generate.rs | 4 ++-- src/commands/yubihsm/keys/import.rs | 4 ++-- src/commands/yubihsm/keys/list.rs | 2 +- src/commands/yubihsm/setup.rs | 2 +- src/commands/yubihsm/test.rs | 2 +- src/connection/unix.rs | 1 - tests/cli/yubihsm/keys/generate.rs | 4 ++-- tests/cli/yubihsm/keys/import.rs | 6 +++--- tests/cli/yubihsm/keys/list.rs | 4 ++-- tests/integration.rs | 8 ++++---- 15 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/commands/init.rs b/src/commands/init.rs index b2606792..31faf571 100644 --- a/src/commands/init.rs +++ b/src/commands/init.rs @@ -5,7 +5,7 @@ pub mod networks; use self::{config_builder::ConfigBuilder, networks::Network}; use crate::{config::CONFIG_FILE_NAME, key_utils, prelude::*}; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use clap::Parser; use std::{ fs, diff --git a/src/commands/softsign/import.rs b/src/commands/softsign/import.rs index 41a4fdfe..bad79f8d 100644 --- a/src/commands/softsign/import.rs +++ b/src/commands/softsign/import.rs @@ -1,7 +1,7 @@ //! `tmkms softsign import` command use crate::{config::provider::softsign::KeyFormat, key_utils, prelude::*}; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use clap::Parser; use std::{path::PathBuf, process}; use tendermint::PrivateKey; diff --git a/src/commands/softsign/keygen.rs b/src/commands/softsign/keygen.rs index bfbde05d..a815018a 100644 --- a/src/commands/softsign/keygen.rs +++ b/src/commands/softsign/keygen.rs @@ -1,7 +1,7 @@ //! `tmkms softsign keygen` subcommand use crate::{key_utils, keyring::ed25519, prelude::*}; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use clap::Parser; use k256::ecdsa; use rand_core::{OsRng, RngCore}; diff --git a/src/commands/yubihsm/detect.rs b/src/commands/yubihsm/detect.rs index eaa4e87a..91c87287 100644 --- a/src/commands/yubihsm/detect.rs +++ b/src/commands/yubihsm/detect.rs @@ -1,7 +1,7 @@ //! Detect YubiHSM2s connected via USB use crate::prelude::*; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use clap::Parser; use std::process; use yubihsm::connector::usb::Devices; diff --git a/src/commands/yubihsm/keys/export.rs b/src/commands/yubihsm/keys/export.rs index a13bc935..0d728e27 100644 --- a/src/commands/yubihsm/keys/export.rs +++ b/src/commands/yubihsm/keys/export.rs @@ -1,8 +1,8 @@ //! Create encrypted backups of YubiHSM2 keys -use super::*; +use super::DEFAULT_WRAP_KEY; use crate::{key_utils, prelude::*}; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use clap::Parser; use std::{path::PathBuf, process}; diff --git a/src/commands/yubihsm/keys/generate.rs b/src/commands/yubihsm/keys/generate.rs index c2152fa9..1e072c05 100644 --- a/src/commands/yubihsm/keys/generate.rs +++ b/src/commands/yubihsm/keys/generate.rs @@ -1,8 +1,8 @@ //! Generate a new key within the YubiHSM2 -use super::*; +use super::{DEFAULT_DOMAINS, DEFAULT_WRAP_KEY}; use crate::{config::provider::KeyType, key_utils, prelude::*}; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use chrono::{SecondsFormat, Utc}; use clap::Parser; use std::{ diff --git a/src/commands/yubihsm/keys/import.rs b/src/commands/yubihsm/keys/import.rs index f06b43d0..8d2dd07b 100644 --- a/src/commands/yubihsm/keys/import.rs +++ b/src/commands/yubihsm/keys/import.rs @@ -1,8 +1,8 @@ //! Import keys either from encrypted backups or existing plaintext keys -use super::*; +use super::{DEFAULT_DOMAINS, DEFAULT_WRAP_KEY}; use crate::{keyring::ed25519, prelude::*}; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use clap::Parser; use std::{fs, path::PathBuf, process}; use subtle_encoding::base64; diff --git a/src/commands/yubihsm/keys/list.rs b/src/commands/yubihsm/keys/list.rs index f04ae5ae..ed24ee7c 100644 --- a/src/commands/yubihsm/keys/list.rs +++ b/src/commands/yubihsm/keys/list.rs @@ -1,7 +1,7 @@ //! List keys inside the YubiHSM2 use crate::{chain, keyring, prelude::*, Map}; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use clap::Parser; use k256::elliptic_curve::generic_array::GenericArray; use std::{path::PathBuf, process}; diff --git a/src/commands/yubihsm/setup.rs b/src/commands/yubihsm/setup.rs index b6468fb2..d02c866b 100644 --- a/src/commands/yubihsm/setup.rs +++ b/src/commands/yubihsm/setup.rs @@ -1,7 +1,7 @@ //! Set up a new YubiHSM2 or restore from backup use crate::prelude::*; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use chrono::{SecondsFormat, Utc}; use clap::Parser; use getrandom::getrandom; diff --git a/src/commands/yubihsm/test.rs b/src/commands/yubihsm/test.rs index d5f73076..250da129 100644 --- a/src/commands/yubihsm/test.rs +++ b/src/commands/yubihsm/test.rs @@ -1,7 +1,7 @@ //! Test the YubiHSM2 is working by performing signatures successively use crate::prelude::*; -use abscissa_core::{Command, Runnable}; +use abscissa_core::Command; use clap::Parser; use std::{ path::PathBuf, diff --git a/src/connection/unix.rs b/src/connection/unix.rs index 942d2bad..01f764a6 100644 --- a/src/connection/unix.rs +++ b/src/connection/unix.rs @@ -1,7 +1,6 @@ //! Unix domain socket connection to a validator use std::io; -use std::marker::{Send, Sync}; /// Protocol implementation of the UNIX socket domain connection pub struct UnixConnection { diff --git a/tests/cli/yubihsm/keys/generate.rs b/tests/cli/yubihsm/keys/generate.rs index b5c5f815..ee2c4f85 100644 --- a/tests/cli/yubihsm/keys/generate.rs +++ b/tests/cli/yubihsm/keys/generate.rs @@ -12,8 +12,8 @@ fn keys_generate_command_test() { args.extend_from_slice(&["-c", super::KMS_CONFIG_PATH]); let cmd_out = cli::run_successfully(args.as_slice()); - assert_eq!(true, cmd_out.status.success()); - assert_eq!(true, cmd_out.stderr.is_empty()); + assert!(cmd_out.status.success()); + assert!(cmd_out.stderr.is_empty()); let stdout = str::from_utf8(&cmd_out.stdout).unwrap().trim().to_owned(); assert!(stdout.contains("Generated")); diff --git a/tests/cli/yubihsm/keys/import.rs b/tests/cli/yubihsm/keys/import.rs index b51841cb..577fabfa 100644 --- a/tests/cli/yubihsm/keys/import.rs +++ b/tests/cli/yubihsm/keys/import.rs @@ -16,9 +16,9 @@ fn keys_import_priv_validator_test() { let out = cli::run_successfully(args.as_slice()); - assert_eq!(true, out.status.success()); - assert_eq!(true, out.stderr.is_empty()); + assert!(out.status.success()); + assert!(out.stderr.is_empty()); let message = str::from_utf8(&out.stdout).unwrap().trim().to_owned(); - assert_eq!(true, message.contains("key 0x0001")); + assert!(message.contains("key 0x0001")); } diff --git a/tests/cli/yubihsm/keys/list.rs b/tests/cli/yubihsm/keys/list.rs index 38224078..ecd25e45 100644 --- a/tests/cli/yubihsm/keys/list.rs +++ b/tests/cli/yubihsm/keys/list.rs @@ -13,8 +13,8 @@ fn keys_command_test() { let out = cli::run_successfully(args.as_slice()); - assert_eq!(true, out.status.success()); - assert_eq!(true, out.stdout.is_empty()); + assert!(out.status.success()); + assert!(out.stdout.is_empty()); let stderr = str::from_utf8(&out.stderr).unwrap().trim().to_owned(); assert!(stderr.contains("no keys in this YubiHSM")); diff --git a/tests/integration.rs b/tests/integration.rs index 4554fc8d..5d24a4d4 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -152,7 +152,7 @@ impl KmsProcess { path = "{}" key_type = "{}" "#, - &peer_id.to_string(), port, signing_key_path(&key_type), key_type + &peer_id.to_string(), port, signing_key_path(key_type), key_type ) .unwrap(); @@ -162,7 +162,7 @@ impl KmsProcess { /// Create a config file for a UNIX KMS and return its path fn create_unix_config(socket_path: &str, key_type: &KeyType) -> NamedTempFile { let mut config_file = NamedTempFile::new().unwrap(); - let key_path = signing_key_path(&key_type); + let key_path = signing_key_path(key_type); writeln!( config_file, r#" @@ -230,9 +230,9 @@ impl ProtocolTester { where F: FnOnce(ProtocolTester), { - let tcp_device = KmsProcess::create_tcp(&key_type); + let tcp_device = KmsProcess::create_tcp(key_type); let tcp_connection = tcp_device.create_connection(); - let unix_device = KmsProcess::create_unix(&key_type); + let unix_device = KmsProcess::create_unix(key_type); let unix_connection = unix_device.create_connection(); functor(Self {