From dc127ed87a45cdc162785b2a38f5bc303c8dfe07 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Sun, 14 Nov 2021 18:59:56 +0100 Subject: [PATCH] Fix Clippy lints & GitHub Action improvements (#74) * ci: improve - run on all branches to test things - no cargo color, it destroys actions-rs/cargo features - update versions * refactor(lint): fix clippy issues * refactor(lint): fix more clippy issues --- .github/workflows/rust.yml | 15 ++++----------- src/aur.rs | 2 +- src/main.rs | 2 +- src/presets.rs | 12 ++++++------ src/storage/loop_device.rs | 2 +- src/storage/removeable_devices.rs | 2 +- src/storage/storage_device.rs | 2 +- src/tool/mount.rs | 4 ++-- 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1089172..f656169 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,37 +2,30 @@ name: Rust on: push: - branches: [ master ] pull_request: - branches: [ master ] - -env: - CARGO_TERM_COLOR: always jobs: build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable profile: minimal override: true components: rustfmt, clippy - - uses: actions-rs/cargo@v1.0.1 + - uses: actions-rs/cargo@v1 name: Check format with: command: fmt args: --all -- --check - - uses: actions-rs/cargo@v1.0.1 + - uses: actions-rs/cargo@v1 name: Run clippy with: command: clippy args: --all-targets --locked -- -D warnings - - uses: actions-rs/cargo@v1.0.1 + - uses: actions-rs/cargo@v1 name: Run tests with: command: test diff --git a/src/aur.rs b/src/aur.rs index e165823..0aefa42 100644 --- a/src/aur.rs +++ b/src/aur.rs @@ -12,7 +12,7 @@ impl FromStr for AurHelper { fn from_str(s: &str) -> anyhow::Result { match s { - "yay" => Ok(AurHelper { + "yay" => Ok(Self { name: String::from("yay"), package_name: String::from("yay-bin"), install_command: vec![ diff --git a/src/main.rs b/src/main.rs index 49b301d..e33466b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -186,7 +186,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> { let root_partition_base = storage_device.get_partition(constants::ROOT_PARTITION_INDEX)?; let encrypted_root = if let Some(cryptsetup) = &cryptsetup { info!("Encrypting the root filesystem"); - EncryptedDevice::prepare(&cryptsetup, &root_partition_base)?; + EncryptedDevice::prepare(cryptsetup, &root_partition_base)?; Some(EncryptedDevice::open( cryptsetup, &root_partition_base, diff --git a/src/presets.rs b/src/presets.rs index c6d9851..ef7b064 100644 --- a/src/presets.rs +++ b/src/presets.rs @@ -33,7 +33,7 @@ fn visit_dirs(dir: &Path, filevec: &mut Vec) -> Result<(), io::Error> { impl Preset { fn load(path: &Path) -> anyhow::Result { let data = fs::read_to_string(path).with_context(|| format!("{}", path.display()))?; - Ok(toml::from_str(&data).with_context(|| format!("{}", path.display()))?) + toml::from_str(&data).with_context(|| format!("{}", path.display())) } fn process( @@ -41,7 +41,7 @@ impl Preset { packages: &mut HashSet, scripts: &mut Vec