fix some pedantic lints

This commit is contained in:
Dr. Matthias Ratajczak
2023-02-01 16:42:49 +01:00
parent 2989e40925
commit 57aa7bdc94
6 changed files with 12 additions and 12 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ impl Backend for Rust {
let content = read_to_string(file).context("reading crates file")?; let content = read_to_string(file).context("reading crates file")?;
let json: Value = let json: Value =
serde_json::from_str(&content).context("parsing JSON from crates file")?; serde_json::from_str(&content).context("parsing JSON from crates file")?;
extract_packages(json).context("extracing packages from crates file") extract_packages(&json).context("extracing packages from crates file")
} }
fn get_explicitly_installed_packages(&self) -> Result<HashSet<Package>> { fn get_explicitly_installed_packages(&self) -> Result<HashSet<Package>> {
@@ -42,7 +42,7 @@ impl Backend for Rust {
} }
} }
fn extract_packages(json: Value) -> Result<HashSet<Package>> { fn extract_packages(json: &Value) -> Result<HashSet<Package>> {
let result: HashSet<_> = json let result: HashSet<_> = json
.get("installs") .get("installs")
.context("get 'installs' field from json")? .context("get 'installs' field from json")?
+1 -1
View File
@@ -35,7 +35,7 @@ pub(crate) trait Backend: Debug {
let section_header = format!("[{}]", self.get_section()); let section_header = format!("[{}]", self.get_section());
for (group, packages) in group_package_map { for (group, packages) in group_package_map {
group.save_packages(&section_header, packages); group.save_packages(&section_header, &packages);
} }
} }
+3 -3
View File
@@ -70,7 +70,7 @@ impl Pacdef {
match backend.get_missing_packages_sorted() { match backend.get_missing_packages_sorted() {
Ok(diff) => to_install.push((backend, diff)), Ok(diff) => to_install.push((backend, diff)),
Err(error) => show_error(error, backend), Err(error) => show_error(&error, &*backend),
}; };
} }
@@ -155,7 +155,7 @@ impl Pacdef {
match backend.get_unmanaged_packages_sorted() { match backend.get_unmanaged_packages_sorted() {
Ok(unmanaged) => result.push((backend, unmanaged)), Ok(unmanaged) => result.push((backend, unmanaged)),
Err(error) => show_error(error, backend), Err(error) => show_error(&error, &*backend),
}; };
} }
result result
@@ -278,7 +278,7 @@ fn get_assumed_group_file_names(arg_match: &ArgMatches) -> Result<Vec<PathBuf>>
Ok(paths) Ok(paths)
} }
fn show_error(error: anyhow::Error, backend: Box<dyn Backend>) { fn show_error(error: &anyhow::Error, backend: &dyn Backend) {
let section = backend.get_section(); let section = backend.get_section();
match get_single_var("RUST_BACKTRACE") { match get_single_var("RUST_BACKTRACE") {
Some(s) => { Some(s) => {
+4 -4
View File
@@ -94,7 +94,7 @@ impl Group {
sections.insert(section); sections.insert(section);
} }
Err(e) => { Err(e) => {
println!("WARNING: could not process a section under group '{name}': {e:?}\n") println!("WARNING: could not process a section under group '{name}': {e:?}\n");
} }
} }
} }
@@ -112,13 +112,13 @@ impl Group {
}) })
} }
pub(crate) fn save_packages(&self, section_header: &str, packages: Vec<Package>) { pub(crate) fn save_packages(&self, section_header: &str, packages: &[Package]) {
let mut content = read_to_string(&self.path).unwrap(); let mut content = read_to_string(&self.path).unwrap();
if content.contains(section_header) { if content.contains(section_header) {
write_packages_to_existing_section(&mut content, section_header, &packages); write_packages_to_existing_section(&mut content, section_header, packages);
} else { } else {
add_new_section_with_packages(&mut content, section_header, &packages); add_new_section_with_packages(&mut content, section_header, packages);
} }
let mut file = File::create(&self.path).unwrap(); let mut file = File::create(&self.path).unwrap();
+1 -1
View File
@@ -77,7 +77,7 @@ pub(crate) fn review(
} }
for strat in strategies { for strat in strategies {
strat.execute()? strat.execute()?;
} }
Ok(()) Ok(())
+1 -1
View File
@@ -21,7 +21,7 @@ pub(crate) fn search_packages(args: &ArgMatches, groups: &HashSet<Group>) -> Res
for section in &group.sections { for section in &group.sections {
for package in &section.packages { for package in &section.packages {
if re.is_match(&package.name) { if re.is_match(&package.name) {
vec.push((group, section, package)) vec.push((group, section, package));
} }
} }
} }