Skip to content

Commit

Permalink
trust-check rustfmt & clippy mods
Browse files Browse the repository at this point in the history
  • Loading branch information
alexheretic committed Feb 26, 2019
1 parent aca3a04 commit 1777d18
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 30 deletions.
2 changes: 1 addition & 1 deletion aur
Submodule aur updated from cd8c65 to a01f50
28 changes: 14 additions & 14 deletions trust-check/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 8 additions & 15 deletions trust-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
//! for each mistrusted package.
//!
//! If package is not found in the AUR will output PACKAGE_NAME::not-in-aur
use std::alloc::System;
use std::borrow::Cow;
use std::collections::HashSet;
use std::error::Error;
use std::path::Path;
use std::{env, fs, str};
use std::{
alloc::System, borrow::Cow, collections::HashSet, env, error::Error, ffi::OsStr, fs,
path::Path, str,
};

#[global_allocator]
static GLOBAL: System = System;
Expand All @@ -38,12 +36,7 @@ fn main() -> Res<()> {
}

let trust_everyone = !Path::new(LOCAL_TRUST_PATH).is_file();

let trusted = if trust_everyone {
HashSet::new()
} else {
local_trusted_users()?
};
let trusted = if trust_everyone { HashSet::new() } else { local_trusted_users()? };

let (pkg_maintainers, not_in_aur) = package_maintainers(&packages)?;

Expand All @@ -68,7 +61,7 @@ fn translate_full_package(arg: String) -> Result<String, String> {
if arg.contains(".pkg.") {
let archive_name = Path::new(&arg)
.file_name()
.and_then(|f| f.to_str())
.and_then(OsStr::to_str)
.ok_or_else(|| format!("Can't handle arg `{}`", arg))?;
let mut name_bits: Vec<_> = archive_name.split('-').rev().skip(3).collect();
name_bits.reverse();
Expand Down Expand Up @@ -100,7 +93,7 @@ fn package_maintainers<T: AsRef<str>>(
for pkg in packages
.iter()
.flat_map(|p| p.as_ref().split('\n'))
.map(|p| p.trim())
.map(str::trim)
.filter(|p| !p.is_empty())
{
url = url + "&arg[]=" + &uri_encode_pkg(valid_arch_package_name(pkg)?);
Expand All @@ -125,7 +118,7 @@ fn package_maintainers<T: AsRef<str>>(
let not_in_aur: Vec<_> = {
let in_aur: HashSet<_> = json["results"]
.members()
.filter_map(|info| info["Name"].as_str().map(|s| s.to_lowercase()))
.filter_map(|info| info["Name"].as_str().map(str::to_lowercase))
.collect();

packages
Expand Down

0 comments on commit 1777d18

Please sign in to comment.