From 4ea5807a5a902719058f35ecf9d7fcc5df970c18 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Thu, 1 Aug 2019 11:03:54 +0300 Subject: [PATCH] Make Clippy happy --- azure-pipelines.yml | 6 +++++- src/main.rs | 1 + src/storage/storage_device.rs | 13 +++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 49a2134..8f451c8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,8 +7,12 @@ stages: vmImage: 'ubuntu-16.04' container: 'rust:latest' steps: + - script: cargo fmt -- --check + displayName: Check Formatting - script: cargo check --all - displayName: Run check + displayName: Check + - script: cargo clippy + displayName: Clippy - stage: Build jobs: diff --git a/src/main.rs b/src/main.rs index 82cc4c8..89eafa4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -126,6 +126,7 @@ fn select_block_device(running: Arc) -> Result { } } +#[allow(clippy::cognitive_complexity)] fn create(command: CreateCommand, running: Arc) -> Result<(), Error> { let presets = presets::Presets::load(&command.presets)?; diff --git a/src/storage/storage_device.rs b/src/storage/storage_device.rs index e786265..da7b035 100644 --- a/src/storage/storage_device.rs +++ b/src/storage/storage_device.rs @@ -16,22 +16,19 @@ pub struct StorageDevice<'a> { impl<'a> StorageDevice<'a> { pub fn from_path(path: &'a Path) -> Result { - let real_path = path.canonicalize().context(ErrorKind::DeviceQuery)?; - let device_name = real_path + debug!("path: {:?}", path); + let path = path.canonicalize().context(ErrorKind::DeviceQuery)?; + let device_name = path .file_name() .and_then(|s| s.to_str()) .map(String::from) .ok_or_else(|| Error::from(ErrorKind::InvalidDeviceName))?; - debug!( - "path: {:?}, real path: {:?}, device name: {:?}", - path, real_path, device_name - ); + debug!("real path: {:?}, device name: {:?}", path, device_name); - drop(path); let _self = Self { name: device_name, - path: real_path, + path, origin: PhantomData, }; if !(_self.is_removable_device()? || _self.is_loop_device()) {