fix some pedantic lints
This commit is contained in:
@@ -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")?
|
||||||
|
|||||||
@@ -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(§ion_header, packages);
|
group.save_packages(§ion_header, &packages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -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) => {
|
||||||
|
|||||||
@@ -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
@@ -77,7 +77,7 @@ pub(crate) fn review(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for strat in strategies {
|
for strat in strategies {
|
||||||
strat.execute()?
|
strat.execute()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
+1
-1
@@ -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 §ion.packages {
|
for package in §ion.packages {
|
||||||
if re.is_match(&package.name) {
|
if re.is_match(&package.name) {
|
||||||
vec.push((group, section, package))
|
vec.push((group, section, package));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user