From 83a4cb57d80c1079e432dee564a1d2f665b8c12b Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 28 Jan 2023 17:04:20 +0100 Subject: [PATCH] Fix clippy::uninlined_format_args lint Fixes local lint violations. For the final fix, I have to wait for https://github.com/kaj/ructe/pull/123 --- src/error.rs | 12 ++++++------ src/lib.rs | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/error.rs b/src/error.rs index 660b554..faa13d8 100644 --- a/src/error.rs +++ b/src/error.rs @@ -19,13 +19,13 @@ pub enum Error { impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match self { - Error::Badge(s) => write!(fmt, "Badge({})", s), - Error::Client(e) => write!(fmt, "Client({})", e), - Error::Git(e) => write!(fmt, "Git({})", e), + Error::Badge(s) => write!(fmt, "Badge({s})"), + Error::Client(e) => write!(fmt, "Client({e})"), + Error::Git(e) => write!(fmt, "Git({e})"), Error::Internal => write!(fmt, "Internal Error"), - Error::Io(e) => write!(fmt, "Io({})", e), - Error::Parse(e) => write!(fmt, "Parse({})", e), - Error::Serial(e) => write!(fmt, "Serial({})", e), + Error::Io(e) => write!(fmt, "Io({e})"), + Error::Parse(e) => write!(fmt, "Parse({e})"), + Error::Serial(e) => write!(fmt, "Serial({e})"), Error::BranchNotFound => write!(fmt, "Repo doesn't have master branch"), } } diff --git a/src/lib.rs b/src/lib.rs index 888ba20..f917c51 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -101,8 +101,8 @@ fn pull(path: impl AsRef) -> Result<()> { } fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &str) -> Result<(u64, String, u64)> { - let repo_dir = format!("{}/{}", repo_dir, repo); - let cache_dir = format!("{}/{}.json", cache_dir, repo); + let repo_dir = format!("{repo_dir}/{repo}"); + let cache_dir = format!("{cache_dir}/{repo}.json"); let cache_dir = Path::new(&cache_dir); let repo = Repository::open_bare(&repo_dir)?; // TODO: do better... @@ -132,8 +132,8 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &str) -> Result<(u64 } CacheState::Old { head, .. } => { info!("Updating cache"); - arg.push(format!("{}..{}", head, branch)); - arg_commit_count.push(format!("{}..{}", head, branch)); + arg.push(format!("{head}..{branch}")); + arg_commit_count.push(format!("{head}..{branch}")); } CacheState::No | CacheState::NoneForBranch(..) => { info!("Creating cache"); @@ -214,8 +214,8 @@ where data.1.to_lowercase() ); info!("Deleting cache and repository"); - let cache_dir = format!("{}/{}.json", &state.cache(), repo); - let repo_dir = format!("{}/{}", &state.repos(), repo); + let cache_dir = format!("{}/{repo}.json", &state.cache()); + let repo_dir = format!("{}/{repo}", &state.repos()); std::fs::remove_file(cache_dir).or_else(|e| { if e.kind() == io::ErrorKind::NotFound { Ok(()) @@ -262,10 +262,10 @@ where ); let future = async { let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase()); - let service_path = format!("{}/{}", T::url_path(), repo); - let service_url = format!("{}/{}", T::domain(), repo); - let path = format!("{}/{}", state.repos(), service_url); - let url = format!("https://{}", service_url); + let service_path = format!("{}/{repo}", T::url_path()); + let service_url = format!("{}/{repo}", T::domain()); + let path = format!("{}/{service_url}", state.repos()); + let url = format!("https://{service_url}"); let remote_exists = remote_exists(&url).await?; let file = Path::new(&path); if !file.exists() { @@ -284,7 +284,7 @@ where let (hoc, head, commits) = hoc(&service_url, &state.repos(), &state.cache(), branch)?; let hoc_pretty = match NumberPrefix::decimal(hoc as f64) { NumberPrefix::Standalone(hoc) => hoc.to_string(), - NumberPrefix::Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix), + NumberPrefix::Prefixed(prefix, hoc) => format!("{hoc:.1}{prefix}"), }; let res = HocResult::Hoc { hoc,