Skip to content

Commit

Permalink
Apply clippy::uninlined_format_args fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Oct 28, 2022
1 parent efbb487 commit 9553388
Show file tree
Hide file tree
Showing 24 changed files with 77 additions and 77 deletions.
6 changes: 3 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ fn get_git_sha() -> Option<String> {
let symbolic = cmd(&["git", "rev-parse", "--symbolic", "HEAD"]).unwrap();
let symbolic_full = cmd(&["git", "rev-parse", "--symbolic-full-name", "HEAD"]).unwrap();

println!("cargo:rerun-if-changed=.git/{}", symbolic);
println!("cargo:rerun-if-changed=.git/{symbolic}");
if symbolic != symbolic_full {
println!("cargo:rerun-if-changed=.git/{}", symbolic_full);
println!("cargo:rerun-if-changed=.git/{symbolic_full}");
}

Some(sha)
Expand All @@ -31,5 +31,5 @@ fn main() {
let sha = format!("{:?}", get_git_sha());

let output = std::env::var("OUT_DIR").unwrap();
::std::fs::write(format!("{}/sha", output), sha.as_bytes()).unwrap();
::std::fs::write(format!("{output}/sha"), sha.as_bytes()).unwrap();
}
2 changes: 1 addition & 1 deletion src/actions/experiments/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Action for EditExperiment {
}

let changes = t.execute(
&format!("UPDATE experiments SET {} = ?1 WHERE name = ?2;", col),
&format!("UPDATE experiments SET {col} = ?1 WHERE name = ?2;"),
&[&ex.toolchains[i].to_string(), &self.name],
)?;
assert_eq!(changes, 1);
Expand Down
6 changes: 3 additions & 3 deletions src/agent/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl ResponseExt for ::reqwest::blocking::Response {
let status = self.status();
let result: ApiResponse<T> = self
.json()
.with_context(|_| format!("failed to parse API response (status code {})", status,))?;
.with_context(|_| format!("failed to parse API response (status code {status})",))?;
match result {
ApiResponse::Success { result } => Ok(result),
ApiResponse::SlowDown => Err(AgentApiError::ServerUnavailable.into()),
Expand All @@ -78,7 +78,7 @@ impl AgentApi {
}

fn build_request(&self, method: Method, url: &str) -> RequestBuilder {
utils::http::prepare_sync(method, &format!("{}/agent-api/{}", self.url, url)).header(
utils::http::prepare_sync(method, &format!("{}/agent-api/{url}", self.url)).header(
AUTHORIZATION,
(CraterToken {
token: self.token.clone(),
Expand All @@ -101,7 +101,7 @@ impl AgentApi {
// We retry these errors. Ideally it's something the
// server would handle, but that's (unfortunately) hard
// in practice.
format!("{:?}", err).contains("database is locked")
format!("{err:?}").contains("database is locked")
};

if retry {
Expand Down
8 changes: 4 additions & 4 deletions src/crates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ impl Crate {
Crate::Registry(ref details) => format!("reg/{}/{}", details.name, details.version),
Crate::GitHub(ref repo) => {
if let Some(ref sha) = repo.sha {
format!("gh/{}/{}/{}", repo.org, repo.name, sha)
format!("gh/{}/{}/{sha}", repo.org, repo.name)
} else {
format!("gh/{}/{}", repo.org, repo.name)
}
}
Crate::Local(ref name) => format!("local/{}", name),
Crate::Local(ref name) => format!("local/{name}"),
Crate::Path(ref path) => {
format!("path/{}", utf8_percent_encode(path, NON_ALPHANUMERIC))
}
Expand Down Expand Up @@ -132,11 +132,11 @@ impl fmt::Display for Crate {
Crate::Registry(ref krate) => format!("{}-{}", krate.name, krate.version),
Crate::GitHub(ref repo) =>
if let Some(ref sha) = repo.sha {
format!("{}/{}/{}", repo.org, repo.name, sha)
format!("{}/{}/{sha}", repo.org, repo.name)
} else {
format!("{}/{}", repo.org, repo.name)
},
Crate::Local(ref name) => format!("{} (local)", name),
Crate::Local(ref name) => format!("{name} (local)"),
Crate::Path(ref path) => format!("{}", utf8_percent_encode(path, NON_ALPHANUMERIC)),
Crate::Git(ref repo) =>
if let Some(ref sha) = repo.sha {
Expand Down
14 changes: 7 additions & 7 deletions src/db/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ fn migrations() -> Vec<(&'static str, MigrationKind)> {
if let Ok(parsed) = serde_json::from_str(&legacy) {
Ok(match parsed {
LegacyToolchain::Dist(name) => name,
LegacyToolchain::TryBuild { sha } => format!("try#{}", sha),
LegacyToolchain::Master { sha } => format!("master#{}", sha),
LegacyToolchain::TryBuild { sha } => format!("try#{sha}"),
LegacyToolchain::Master { sha } => format!("master#{sha}"),
})
} else {
Ok(legacy)
Expand All @@ -178,7 +178,7 @@ fn migrations() -> Vec<(&'static str, MigrationKind)> {
[],
)?;
t.execute(
&format!("UPDATE results SET toolchain = {}(toolchain);", fn_name),
&format!("UPDATE results SET toolchain = {fn_name}(toolchain);"),
[],
)?;
t.execute("PRAGMA foreign_keys = ON;", [])?;
Expand Down Expand Up @@ -352,15 +352,15 @@ fn migrations() -> Vec<(&'static str, MigrationKind)> {

t.execute("PRAGMA foreign_keys = OFF;", [])?;
t.execute(
&format!("UPDATE experiment_crates SET crate = {}(crate);", fn_name),
&format!("UPDATE experiment_crates SET crate = {fn_name}(crate);"),
[],
)?;
t.execute(
&format!("UPDATE results SET crate = {}(crate);", fn_name),
&format!("UPDATE results SET crate = {fn_name}(crate);"),
[],
)?;
t.execute(
&format!("UPDATE crates SET crate = {}(crate);", fn_name),
&format!("UPDATE crates SET crate = {fn_name}(crate);"),
[],
)?;
t.execute("PRAGMA foreign_keys = ON;", [])?;
Expand Down Expand Up @@ -406,7 +406,7 @@ pub fn execute(db: &mut Connection) -> Fallible<()> {
MigrationKind::SQL(sql) => t.execute_batch(sql),
MigrationKind::Code(code) => code(&t),
}
.with_context(|_| format!("error running migration: {}", name))?;
.with_context(|_| format!("error running migration: {name}"))?;

t.execute("INSERT INTO migrations (name) VALUES (?1)", [&name])?;
t.commit()?;
Expand Down
8 changes: 4 additions & 4 deletions src/experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ impl fmt::Display for CrateSelect {
CrateSelect::Full => write!(f, "full"),
CrateSelect::Demo => write!(f, "demo"),
CrateSelect::Dummy => write!(f, "dummy"),
CrateSelect::Top(n) => write!(f, "top-{}", n),
CrateSelect::Top(n) => write!(f, "top-{n}"),
CrateSelect::Local => write!(f, "local"),
CrateSelect::Random(n) => write!(f, "random-{}", n),
CrateSelect::Random(n) => write!(f, "random-{n}"),
CrateSelect::List(list) => {
let mut first = true;
write!(f, "list:")?;
Expand All @@ -109,7 +109,7 @@ impl fmt::Display for CrateSelect {
write!(f, ",")?;
}

write!(f, "{}", krate)?;
write!(f, "{krate}")?;
first = false;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ pub enum Assignee {
impl fmt::Display for Assignee {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Assignee::Agent(ref name) => write!(f, "agent:{}", name),
Assignee::Agent(ref name) => write!(f, "agent:{name}"),
Assignee::Distributed => write!(f, "distributed"),
Assignee::CLI => write!(f, "cli"),
}
Expand Down
8 changes: 4 additions & 4 deletions src/report/archives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn iterate<'a, DB: ReadResults + 'a>(
let log = db
.load_log(ex, tc, krate)
.and_then(|c| c.ok_or_else(|| err_msg("missing logs")))
.with_context(|_| format!("failed to read log of {} on {}", krate, tc));
.with_context(|_| format!("failed to read log of {krate} on {tc}"));

let log_bytes: EncodedLog = match log {
Ok(l) => l,
Expand Down Expand Up @@ -163,15 +163,15 @@ pub fn write_logs_archives<DB: ReadResults, W: ReportWriter>(
for (comparison, archive) in by_comparison.drain(..) {
let data = archive.into_inner()?.finish()?;
dest.write_bytes(
format!("logs-archives/{}.tar.gz", comparison),
format!("logs-archives/{comparison}.tar.gz"),
data,
&"application/gzip".parse().unwrap(),
EncodingType::Plain,
)?;

archives.push(Archive {
name: format!("{} crates", comparison),
path: format!("logs-archives/{}.tar.gz", comparison),
name: format!("{comparison} crates"),
path: format!("logs-archives/{comparison}.tar.gz"),
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/report/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn write_crate(
let prefix = if is_child { " * " } else { "* " };
let status_warning = krate
.status
.map(|status| format!(" ({})", status))
.map(|status| format!(" ({status})"))
.unwrap_or_default();

if let ReportConfig::Complete(toolchain) = comparison.report_config() {
Expand Down Expand Up @@ -106,7 +106,7 @@ fn render_markdown(context: &ResultsContext) -> Fallible<String> {
writeln!(rendered, "# Crater report for {}\n\n", context.ex.name)?;

for (comparison, results) in context.categories.iter() {
writeln!(rendered, "\n### {}", comparison)?;
writeln!(rendered, "\n### {comparison}")?;
match results {
ReportCratesMD::Plain(crates) => {
for krate in crates {
Expand Down
10 changes: 5 additions & 5 deletions src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn write_logs<DB: ReadResults, W: ReportWriter>(
let content = db
.load_log(ex, tc, krate)
.and_then(|c| c.ok_or_else(|| err_msg("missing logs")))
.with_context(|_| format!("failed to read log of {} on {}", krate, tc));
.with_context(|_| format!("failed to read log of {krate} on {tc}"));
let content = match content {
Ok(c) => c,
Err(e) => {
Expand Down Expand Up @@ -392,12 +392,12 @@ fn crate_to_name(c: &Crate) -> String {
Crate::Registry(ref details) => format!("{}-{}", details.name, details.version),
Crate::GitHub(ref repo) => {
if let Some(ref sha) = repo.sha {
format!("{}.{}.{}", repo.org, repo.name, sha)
format!("{}.{}.{sha}", repo.org, repo.name)
} else {
format!("{}.{}", repo.org, repo.name)
}
}
Crate::Local(ref name) => format!("{} (local)", name),
Crate::Local(ref name) => format!("{name} (local)"),
Crate::Path(ref path) => utf8_percent_encode(path, &REPORT_ENCODE_SET).to_string(),
Crate::Git(ref repo) => {
if let Some(ref sha) = repo.sha {
Expand All @@ -421,7 +421,7 @@ fn crate_to_url(c: &Crate) -> String {
),
Crate::GitHub(ref repo) => {
if let Some(ref sha) = repo.sha {
format!("https://github.com/{}/{}/tree/{}", repo.org, repo.name, sha)
format!("https://github.com/{}/{}/tree/{sha}", repo.org, repo.name)
} else {
format!("https://github.com/{}/{}", repo.org, repo.name)
}
Expand Down Expand Up @@ -499,7 +499,7 @@ fn compare(
| (TestPass, TestSkipped)
| (TestSkipped, TestFail(_))
| (TestSkipped, TestPass) => {
panic!("can't compare {} and {}", res1, res2);
panic!("can't compare {res1} and {res2}");
}
},
_ if config.should_skip(krate) => Comparison::Skipped,
Expand Down
2 changes: 1 addition & 1 deletion src/report/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mod tests {
"s3://bucket:80",
"s3://bucket/path/prefix?query#fragment",
] {
assert!(S3Prefix::from_str(bad).is_err(), "valid bad url: {}", bad);
assert!(S3Prefix::from_str(bad).is_err(), "valid bad url: {bad}");
}
}
}
2 changes: 1 addition & 1 deletion src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn run_ex<DB: WriteResults + Sync>(
let workers = (0..threads_count)
.map(|i| {
Worker::new(
format!("worker-{}", i),
format!("worker-{i}"),
workspace,
ex,
config,
Expand Down
4 changes: 2 additions & 2 deletions src/runner/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ impl fmt::Debug for TaskStep {
TaskStep::UnstableFeatures { ref tc } => ("find unstable features on", false, Some(tc)),
};

write!(f, "{}", name)?;
write!(f, "{name}")?;
if let Some(tc) = tc {
write!(f, " {}", tc)?;
write!(f, " {tc}")?;
}
if quiet {
write!(f, " (quiet)")?;
Expand Down
6 changes: 3 additions & 3 deletions src/server/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl ACL {
let members = github.team_members(
*orgs[org]
.get(team)
.ok_or_else(|| err_msg(format!("team {}/{} doesn't exist", org, team)))?,
.ok_or_else(|| err_msg(format!("team {org}/{team} doesn't exist")))?,
)?;
for member in &members {
new_cache.insert(member.clone());
Expand Down Expand Up @@ -206,11 +206,11 @@ mod tests {
fn test_git_revision() {
for sha in &["0000000", "0000000000000000000000000000000000000000"] {
assert_eq!(
git_revision(&format!("crater/{}", sha)),
git_revision(&format!("crater/{sha}")),
Some(sha.to_string())
);
assert_eq!(
git_revision(&format!("crater/{} (foo bar!)", sha)),
git_revision(&format!("crater/{sha} (foo bar!)")),
Some(sha.to_string())
);
}
Expand Down
18 changes: 9 additions & 9 deletions src/server/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl GitHubApi {

fn build_request(&self, method: Method, url: &str) -> RequestBuilder {
let url = if !url.starts_with("https://") {
format!("https://api.github.com/{}", url)
format!("https://api.github.com/{url}")
} else {
url.to_string()
};
Expand All @@ -57,7 +57,7 @@ impl GitHub for GitHubApi {

fn post_comment(&self, issue_url: &str, body: &str) -> Fallible<()> {
let response = self
.build_request(Method::POST, &format!("{}/comments", issue_url))
.build_request(Method::POST, &format!("{issue_url}/comments"))
.json(&json!({
"body": body,
}))
Expand All @@ -74,7 +74,7 @@ impl GitHub for GitHubApi {

fn list_labels(&self, issue_url: &str) -> Fallible<Vec<Label>> {
let response = self
.build_request(Method::GET, &format!("{}/labels", issue_url))
.build_request(Method::GET, &format!("{issue_url}/labels"))
.send()?;

let status = response.status();
Expand All @@ -88,7 +88,7 @@ impl GitHub for GitHubApi {

fn add_label(&self, issue_url: &str, label: &str) -> Fallible<()> {
let response = self
.build_request(Method::POST, &format!("{}/labels", issue_url))
.build_request(Method::POST, &format!("{issue_url}/labels"))
.json(&json!([label]))
.send()?;

Expand All @@ -103,7 +103,7 @@ impl GitHub for GitHubApi {

fn remove_label(&self, issue_url: &str, label: &str) -> Fallible<()> {
let response = self
.build_request(Method::DELETE, &format!("{}/labels/{}", issue_url, label))
.build_request(Method::DELETE, &format!("{issue_url}/labels/{label}"))
.send()?;

let status = response.status();
Expand All @@ -117,7 +117,7 @@ impl GitHub for GitHubApi {

fn list_teams(&self, org: &str) -> Fallible<HashMap<String, usize>> {
let response = self
.build_request(Method::GET, &format!("orgs/{}/teams", org))
.build_request(Method::GET, &format!("orgs/{org}/teams"))
.send()?;

let status = response.status();
Expand All @@ -132,7 +132,7 @@ impl GitHub for GitHubApi {

fn team_members(&self, team: usize) -> Fallible<Vec<String>> {
let response = self
.build_request(Method::GET, &format!("teams/{}/members", team))
.build_request(Method::GET, &format!("teams/{team}/members"))
.send()?;

let status = response.status();
Expand All @@ -147,7 +147,7 @@ impl GitHub for GitHubApi {

fn get_commit(&self, repo: &str, sha: &str) -> Fallible<Commit> {
let commit = self
.build_request(Method::GET, &format!("repos/{}/commits/{}", repo, sha))
.build_request(Method::GET, &format!("repos/{repo}/commits/{sha}"))
.send()?
.error_for_status()?
.json()?;
Expand All @@ -156,7 +156,7 @@ impl GitHub for GitHubApi {

fn get_pr_head_sha(&self, repo: &str, pr: i32) -> Fallible<String> {
let pr: PullRequestData = self
.build_request(Method::GET, &format!("repos/{}/pulls/{}", repo, pr))
.build_request(Method::GET, &format!("repos/{repo}/pulls/{pr}"))
.send()?
.error_for_status()?
.json()?;
Expand Down
Loading

0 comments on commit 9553388

Please sign in to comment.