Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Nov 9, 2024
1 parent 228c0e8 commit 52fdbfd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
6 changes: 5 additions & 1 deletion src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ async fn save_aur_list(aur_url: &Url, cache_dir: &Path) -> Result<()> {

create_dir_all(cache_dir)?;
let path = cache_dir.join("packages.aur");
let file = OpenOptions::new().write(true).create(true).open(&path);
let file = OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&path);
let mut file = file.with_context(|| tr!("failed to open cache file '{}'", path.display()))?;

for line in data.split(|&c| c == b'\n').skip(1) {
Expand Down
12 changes: 6 additions & 6 deletions src/devel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub async fn possible_devel_updates(config: &Config) -> Result<Vec<String>> {
let mut pkgbases: HashMap<&str, Vec<&alpm::Package>> = HashMap::new();

for pkg in db.pkgs().iter() {
let name = pkg_base_or_name(&pkg);
let name = pkg_base_or_name(pkg);
pkgbases.entry(name).or_default().push(pkg);
}

Expand Down Expand Up @@ -411,12 +411,12 @@ pub async fn filter_devel_updates(

let (_, dbs) = repo::repo_aur_dbs(config);
for pkg in dbs.iter().flat_map(|d| d.pkgs()) {
let name = pkg_base_or_name(&pkg);
let name = pkg_base_or_name(pkg);
pkgbases.entry(name).or_default().push(pkg);
}

for pkg in db.pkgs().iter() {
let name = pkg_base_or_name(&pkg);
let name = pkg_base_or_name(pkg);
pkgbases.entry(name).or_default().push(pkg);
}

Expand Down Expand Up @@ -571,19 +571,19 @@ pub fn load_devel_info(config: &Config) -> Result<Option<DevelInfo>> {
}

for pkg in config.alpm.localdb().pkgs().iter() {
let name = pkg_base_or_name(&pkg);
let name = pkg_base_or_name(pkg);
pkgbases.entry(name).or_default().push(pkg);
}

let (_, dbs) = repo::repo_aur_dbs(config);
for pkg in dbs.iter().flat_map(|d| d.pkgs()) {
let name = pkg_base_or_name(&pkg);
let name = pkg_base_or_name(pkg);
pkgbases.entry(name).or_default().push(pkg);
}

devel_info
.info
.retain(|pkg, _| pkgbases.get(pkg.as_str()).is_some());
.retain(|pkg, _| pkgbases.contains_key(pkg.as_str()));

save_devel_info(config, &devel_info)?;

Expand Down
12 changes: 6 additions & 6 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ impl Installer {
.iter()
.find(|db| db.name() == *repo)
.unwrap();
let path = repo::file(&repo).unwrap();
let path = repo::file(repo).unwrap();
let name = repo.name().to_string();
repo::add(config, path, &name, &paths)?;
repo::refresh(config, &[name])?;
Expand Down Expand Up @@ -820,7 +820,7 @@ impl Installer {
let (_, repo) = repo::repo_aur_dbs(config);
let default_repo = repo.first();
if let Some(repo) = default_repo {
let file = repo::file(&repo).unwrap();
let file = repo::file(repo).unwrap();
repo::init(config, file, repo.name())?;
}

Expand All @@ -833,7 +833,7 @@ impl Installer {
}

let repo_server =
default_repo.map(|r| (r.name().to_string(), repo::file(&r).unwrap().to_string()));
default_repo.map(|r| (r.name().to_string(), repo::file(r).unwrap().to_string()));
drop(repo);

for base in build {
Expand Down Expand Up @@ -1256,14 +1256,14 @@ fn print_warnings(config: &Config, cache: &Cache, actions: Option<&Actions>) {
warnings.missing = pkgs
.iter()
.filter(|pkg| !cache.contains(pkg.name()))
.filter(|pkg| !is_debug(**pkg))
.filter(|pkg| !is_debug(pkg))
.map(|pkg| pkg.name())
.filter(|pkg| !config.no_warn.is_match(pkg))
.collect::<Vec<_>>();

warnings.ood = pkgs
.iter()
.filter(|pkg| !is_debug(**pkg))
.filter(|pkg| !is_debug(pkg))
.filter_map(|pkg| cache.get(pkg.name()))
.filter(|pkg| pkg.out_of_date.is_some())
.map(|pkg| pkg.name.as_str())
Expand All @@ -1272,7 +1272,7 @@ fn print_warnings(config: &Config, cache: &Cache, actions: Option<&Actions>) {

warnings.orphans = pkgs
.iter()
.filter(|pkg| !is_debug(**pkg))
.filter(|pkg| !is_debug(pkg))
.filter_map(|pkg| cache.get(pkg.name()))
.filter(|pkg| pkg.maintainer.is_none())
.map(|pkg| pkg.name.as_str())
Expand Down
2 changes: 1 addition & 1 deletion src/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn remove(config: &mut Config) -> Result<i32> {
.targets
.iter()
.filter_map(|pkg| db.pkg(pkg.as_str()).ok())
.map(|pkg| pkg_base_or_name(&pkg))
.map(pkg_base_or_name)
.collect::<Vec<_>>();

let mut db_map: HashMap<String, Vec<String>> = HashMap::new();
Expand Down
4 changes: 2 additions & 2 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub fn refresh<S: AsRef<OsStr>>(config: &mut Config, repos: &[S]) -> Result<i32>
}

for db in dbs {
let path = file(&db);
let path = file(db);
if let Some(path) = path {
init(config, path, db.name())?;
}
Expand Down Expand Up @@ -277,7 +277,7 @@ pub fn clean(config: &mut Config) -> Result<i32> {

for pkgs in rem {
let repo = pkgs[0].db().unwrap();
let path = file(&repo).unwrap();
let path = file(repo).unwrap();
let pkgs = pkgs.iter().map(|p| p.name()).collect::<Vec<_>>();
remove(config, path, repo.name(), &pkgs)?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn print_pkgbuild_pkg(
"{}/{} {}",
color_repo(c.enabled, repo),
c.ss_name.paint(&pkg.pkgname),
c.ss_ver.paint(&srcinfo.version()),
c.ss_ver.paint(srcinfo.version()),
);

if let Ok(repo_pkg) = config.alpm.localdb().pkg(&*pkg.pkgname) {
Expand Down
4 changes: 2 additions & 2 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn print_pkg(config: &Config, mut stdout: impl Write, line: &[u8], repo: &str, v

if config.args.has_arg("q", "quiet") {
let _ = stdout.write_all(line);
let _ = stdout.write_all(&[b'\n']);
let _ = stdout.write_all(b"\n");
return;
}
let _ = crepo.paint(repo.as_bytes()).write_to(&mut stdout);
Expand All @@ -147,5 +147,5 @@ fn print_pkg(config: &Config, mut stdout: impl Write, line: &[u8], repo: &str, v
.write_to(&mut stdout);
}

let _ = stdout.write_all(&[b'\n']);
let _ = stdout.write_all(b"\n");
}

0 comments on commit 52fdbfd

Please sign in to comment.