Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Commit

Permalink
Fix Clippy lints & GitHub Action improvements (#74)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
EdJoPaTo authored Nov 14, 2021
1 parent 6b49b5f commit 41f6803
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 24 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/aur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl FromStr for AurHelper {

fn from_str(s: &str) -> anyhow::Result<Self> {
match s {
"yay" => Ok(AurHelper {
"yay" => Ok(Self {
name: String::from("yay"),
package_name: String::from("yay-bin"),
install_command: vec![
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ fn visit_dirs(dir: &Path, filevec: &mut Vec<PathBuf>) -> Result<(), io::Error> {
impl Preset {
fn load(path: &Path) -> anyhow::Result<Self> {
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(
&self,
packages: &mut HashSet<String>,
scripts: &mut Vec<Script>,
environment_variables: &mut HashSet<String>,
path: &PathBuf,
path: &Path,
aur_packages: &mut HashSet<String>,
) -> anyhow::Result<()> {
if let Some(preset_packages) = &self.packages {
Expand Down Expand Up @@ -111,7 +111,7 @@ impl PresetsCollection {
// Build vector of paths to files, then sort by path name
// Recursively load directories of preset files
let mut dir_paths: Vec<PathBuf> = Vec::new();
visit_dirs(&preset, &mut dir_paths)
visit_dirs(preset, &mut dir_paths)
.with_context(|| format!("{}", preset.display()))?;

// Order not guaranteed so we sort
Expand All @@ -128,11 +128,11 @@ impl PresetsCollection {
)?;
}
} else {
Preset::load(&preset)?.process(
Preset::load(preset)?.process(
&mut packages,
&mut scripts,
&mut environment_variables,
&preset,
preset,
&mut aur_packages,
)?;
}
Expand All @@ -151,8 +151,8 @@ impl PresetsCollection {

Ok(Self {
packages,
scripts,
aur_packages,
scripts,
})
}
}
2 changes: 1 addition & 1 deletion src/storage/loop_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl LoopDevice {
);
info!("Mounted {} to {}", file.display(), path.display());

Ok(LoopDevice { path, losetup })
Ok(Self { path, losetup })
}

pub fn path(&self) -> &Path {
Expand Down
2 changes: 1 addition & 1 deletion src/storage/removeable_devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn get_storage_devices(allow_non_removable: bool) -> anyhow::Result<Vec<Devi
.context("Could not parse block size to unsigned integer (u128)")?
* 512,
),
})
});
}

Ok(result)
Expand Down
2 changes: 1 addition & 1 deletion src/storage/storage_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<'a> StorageDevice<'a> {
.context("Error querying information about the block device")?;
let device_name = path
.file_name()
.and_then(|s| s.to_str())
.and_then(std::ffi::OsStr::to_str)
.map(String::from)
.ok_or_else(|| anyhow!("Invalid device name: {}", path.display()))?;

Expand Down
4 changes: 2 additions & 2 deletions src/tool/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn mount<'a>(

info!("Mounting filesystems to {}", mount_path.display());
mount_stack
.mount(&root_filesystem, mount_path.into(), None)
.mount(root_filesystem, mount_path.into(), None)
.with_context(|| format!("Error mounting filesystem to {}", mount_path.display()))?;

let boot_point = mount_path.join("boot");
Expand All @@ -29,7 +29,7 @@ pub fn mount<'a>(
}

mount_stack
.mount(&boot_filesystem, boot_point, None)
.mount(boot_filesystem, boot_point, None)
.context("Error mounting the boot point")?;

Ok(mount_stack)
Expand Down

0 comments on commit 41f6803

Please sign in to comment.