Skip to content

Commit

Permalink
refactor: ♻️ Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pvshvp-oss committed Mar 18, 2024
1 parent 01a2316 commit 933b9fb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
7 changes: 4 additions & 3 deletions paxy/src/actions/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ pub enum Error {

// region: IMPORTS

use std::path::Path;
use std::path::PathBuf;

use snafu::Snafu;

// endregion: IMPORTS

fn plugin(manifest: Box<Path>) -> Box<Path> {
#[allow(dead_code)]
#[allow(unused_variables)]
fn plugin(manifest: PathBuf) -> PathBuf {
todo!()
}
20 changes: 15 additions & 5 deletions paxy/src/data/config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use serde::{Deserialize, Serialize};
use std::{
fs::{self, create_dir_all, File},
io::Write,
path::PathBuf,
};

use serde::{Deserialize, Serialize};
use url::Url;

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -32,7 +33,8 @@ impl Default for Config {
repositories: Some(vec![
Url::parse("https://github.com/Pax-Hub/Packages.git").unwrap()
]),
user_install_location: user.clone(), // Not harmful since the value is dropped in the very next line
user_install_location: user.clone(), /* Not harmful since the value is dropped in the
* very next line */
system_install_location: system,
default_install_type: InstallType::default(),
};
Expand All @@ -45,8 +47,12 @@ impl Default for Config {
}
if !user.is_file() {
let mut file = File::create(user).unwrap();
file.write_all(toml::to_string(&conf).unwrap().as_bytes())
.expect("Permission error");
file.write_all(
toml::to_string(&conf)
.unwrap()
.as_bytes(),
)
.expect("Permission error");
}
}
conf
Expand All @@ -68,7 +74,11 @@ fn load_conf() -> Config {
};
conf_path.push(".paxy");
conf_path.push("config.ini");
match toml::from_str::<Config>(fs::read_to_string(&conf_path).unwrap().as_str()) {
match toml::from_str::<Config>(
fs::read_to_string(&conf_path)
.unwrap()
.as_str(),
) {
Ok(val) => val,
Err(_) => Config::default(),
}
Expand Down
19 changes: 13 additions & 6 deletions paxy/src/data/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct Version {
number: String,
}

#[allow(dead_code)]
fn parse_manifest(manifest: Box<Path>) -> Manifest {
let toml = fs::read_to_string(manifest).unwrap();
toml::from_str(&toml).unwrap()
Expand All @@ -31,10 +32,16 @@ mod tests {
[[version]]
url = "https://github.com/tizonia/tizonia-openmax-il"
number = "1.0.0""#;
assert_eq!(toml::from_str::<Manifest>(toml).unwrap(), Manifest {
version: vec![Version {url: Url::parse("https://github.com/tizonia/tizonia-openmax-il").unwrap(), number: "1.0.0".to_string()}],
name: "paxy".to_string(),
author: None
});
assert_eq!(
toml::from_str::<Manifest>(toml).unwrap(),
Manifest {
version: vec![Version {
url: Url::parse("https://github.com/tizonia/tizonia-openmax-il").unwrap(),
number: "1.0.0".to_string()
}],
name: "paxy".to_string(),
author: None
}
);
}
}
}
2 changes: 1 addition & 1 deletion paxy/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ use snafu::Snafu;

// endregion: RE-EXPORTS
mod config;
mod manifest;
mod manifest;

0 comments on commit 933b9fb

Please sign in to comment.