From 553258af51034bc84dc9f951201e7b8f2285b57e Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 25 Jul 2024 15:35:58 -0700 Subject: [PATCH 1/5] Have clippy warn about uninlined format arguments This makes clippy warn about `format!("{}", var)`, with a machine-applicable fix converting to `format!("{var}")`. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 90d89f6ea..97c7ed79b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,6 +80,7 @@ string_lit_as_bytes = "warn" string_to_string = "warn" todo = "warn" trait_duplication_in_bounds = "warn" +uninlined_format_args = "warn" verbose_file_reads = "warn" wildcard_imports = "warn" zero_sized_map_values = "warn" From 7a28f01acfe8eb95f4e54127e1b66aa31cf2aeed Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 23 Aug 2024 19:02:02 -0500 Subject: [PATCH 2/5] docs(contrib): Fix tpo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87d9134ed..b0318b825 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ We ask that commits are atomic, meaning they are complete and have a single resp PRs should tell a cohesive story, with test and refactor commits that keep the fix or feature commits simple and clear. -Specifically, we would encouage +Specifically, we would encourage - File renames be isolated into their own commit - Add tests in a commit before their feature or fix, showing the current behavior. The diff for the feature/fix commit will then show how the behavior changed, From 37cf1085bc6aa53e18a37f0aa97be51afa6e7f14 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 01:02:47 +0000 Subject: [PATCH 3/5] chore(deps): Update EmbarkStudios/cargo-deny-action action to v2 --- .github/workflows/audit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 07c70eeba..a94be1591 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -47,7 +47,7 @@ jobs: - bans licenses sources steps: - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 + - uses: EmbarkStudios/cargo-deny-action@v2 with: command: check ${{ matrix.checks }} rust-version: stable From 6e193aa09aed80118df4e1317b8eed057bad6f0b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 26 Sep 2024 20:59:12 -0500 Subject: [PATCH 4/5] chore: Ensure pre-commit gets non-system Python This is needed with the ubuntu-24.04 images so that `setup-python` will install a version of Python that the pre-commit action can install into. See pre-commit/action#210 for more of an analysis of this. --- .github/workflows/pre-commit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1b000abfa..7b55a3d9f 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -24,4 +24,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + with: + python-version: '3.x' - uses: pre-commit/action@v3.0.1 From a888481b57043c62493359c4fdb4e6631ffc6ec8 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 27 Sep 2024 11:10:28 -0500 Subject: [PATCH 5/5] style: Inline fmt args --- src/ops/cargo.rs | 5 +---- src/ops/git.rs | 14 ++++++-------- src/ops/shell.rs | 4 ++-- src/ops/version.rs | 15 +++++++-------- src/steps/changes.rs | 2 +- src/steps/hook.rs | 3 +-- src/steps/mod.rs | 17 +++++++---------- src/steps/release.rs | 3 +-- src/steps/tag.rs | 3 +-- 9 files changed, 27 insertions(+), 39 deletions(-) diff --git a/src/ops/cargo.rs b/src/ops/cargo.rs index d391687d2..c2bf5557d 100644 --- a/src/ops/cargo.rs +++ b/src/ops/cargo.rs @@ -407,10 +407,7 @@ fn upgrade_req( let _ = crate::ops::shell::status( "Updating", - format!( - "{}'s dependency from {} to {}", - manifest_name, existing_req_str, new_req - ), + format!("{manifest_name}'s dependency from {existing_req_str} to {new_req}"), ); *version_value = toml_edit::value(new_req); true diff --git a/src/ops/git.rs b/src/ops/git.rs index fcde08384..e54a47ce8 100644 --- a/src/ops/git.rs +++ b/src/ops/git.rs @@ -23,7 +23,7 @@ pub fn is_behind_remote(dir: &Path, remote: &str, branch: &str) -> CargoResult { let remote_branch_id = o.id(); @@ -36,8 +36,7 @@ pub fn is_behind_remote(dir: &Path, remote: &str, branch: &str) -> CargoResult { - let _ = - crate::ops::shell::warn(format!("push target `{}` doesn't exist", remote_branch)); + let _ = crate::ops::shell::warn(format!("push target `{remote_branch}` doesn't exist")); log::trace!("error {}", err); false } @@ -51,7 +50,7 @@ pub fn is_local_unchanged(dir: &Path, remote: &str, branch: &str) -> CargoResult let branch_id = repo.revparse_single(branch)?.id(); - let remote_branch = format!("{}/{}", remote, branch); + let remote_branch = format!("{remote}/{branch}"); let unchanged = match repo.revparse_single(&remote_branch) { Ok(o) => { let remote_branch_id = o.id(); @@ -64,8 +63,7 @@ pub fn is_local_unchanged(dir: &Path, remote: &str, branch: &str) -> CargoResult base_id == branch_id } Err(err) => { - let _ = - crate::ops::shell::warn(format!("push target `{}` doesn't exist", remote_branch)); + let _ = crate::ops::shell::warn(format!("push target `{remote_branch}` doesn't exist")); log::trace!("error {}", err); false } @@ -90,7 +88,7 @@ pub fn is_dirty(dir: &Path) -> CargoResult>> { let state = repo.state(); let dirty_state = state != git2::RepositoryState::Clean; if dirty_state { - entries.push(format!("Dirty because of state {:?}", state)); + entries.push(format!("Dirty because of state {state:?}")); } let mut options = git2::StatusOptions::new(); @@ -118,7 +116,7 @@ pub fn changed_files(dir: &Path, tag: &str) -> CargoResult>> let output = Command::new("git") .arg("diff") - .arg(&format!("{}..HEAD", tag)) + .arg(format!("{tag}..HEAD")) .arg("--name-only") .arg("--exit-code") .arg("--") diff --git a/src/ops/shell.rs b/src/ops/shell.rs index 1462aa54f..cc6a609eb 100644 --- a/src/ops/shell.rs +++ b/src/ops/shell.rs @@ -9,7 +9,7 @@ use crate::ops::style::{ERROR, HEADER, NOTE, WARN}; pub fn confirm(prompt: &str) -> bool { let mut input = String::new(); - console_println(&format!("{} [y/N] ", prompt), Style::new()); + console_println(&format!("{prompt} [y/N] "), Style::new()); stdout().flush().unwrap(); stdin().read_line(&mut input).expect("y/n required"); @@ -32,7 +32,7 @@ pub fn print( if justified { write!(stderr, "{style}{status:>12}{style:#}")?; } else { - write!(stderr, "{style}{}{style:#}:", status)?; + write!(stderr, "{style}{status}{style:#}:")?; } writeln!(stderr, " {message:#}").with_context(|| "Failed to write message")?; diff --git a/src/ops/version.rs b/src/ops/version.rs index c69df6121..c22dbdd1c 100644 --- a/src/ops/version.rs +++ b/src/ops/version.rs @@ -69,12 +69,12 @@ impl VersionExt for semver::Version { } else { 1 }; - self.pre = semver::Prerelease::new(&format!("{}.{}", VERSION_ALPHA, new_ext_ver))?; + self.pre = semver::Prerelease::new(&format!("{VERSION_ALPHA}.{new_ext_ver}"))?; Ok(()) } } else { self.increment_patch(); - self.pre = semver::Prerelease::new(&format!("{}.1", VERSION_ALPHA))?; + self.pre = semver::Prerelease::new(&format!("{VERSION_ALPHA}.1"))?; Ok(()) } } @@ -92,12 +92,12 @@ impl VersionExt for semver::Version { } else { 1 }; - self.pre = semver::Prerelease::new(&format!("{}.{}", VERSION_BETA, new_ext_ver))?; + self.pre = semver::Prerelease::new(&format!("{VERSION_BETA}.{new_ext_ver}"))?; Ok(()) } } else { self.increment_patch(); - self.pre = semver::Prerelease::new(&format!("{}.1", VERSION_BETA))?; + self.pre = semver::Prerelease::new(&format!("{VERSION_BETA}.1"))?; Ok(()) } } @@ -109,11 +109,11 @@ impl VersionExt for semver::Version { } else { 1 }; - self.pre = semver::Prerelease::new(&format!("{}.{}", VERSION_RC, new_ext_ver))?; + self.pre = semver::Prerelease::new(&format!("{VERSION_RC}.{new_ext_ver}"))?; Ok(()) } else { self.increment_patch(); - self.pre = semver::Prerelease::new(&format!("{}.1", VERSION_RC))?; + self.pre = semver::Prerelease::new(&format!("{VERSION_RC}.1"))?; Ok(()) } } @@ -172,8 +172,7 @@ pub fn upgrade_requirement(req: &str, version: &semver::Version) -> CargoResult< { assert!( new_req.matches(version), - "Invalid req created: {}", - new_req_text + "Invalid req created: {new_req_text}" ); } if new_req_text == req_text { diff --git a/src/steps/changes.rs b/src/steps/changes.rs index dbd4797bf..48bbabb86 100644 --- a/src/steps/changes.rs +++ b/src/steps/changes.rs @@ -112,7 +112,7 @@ pub fn changes( let repo = git2::Repository::discover(workspace_root)?; let mut tag_id = None; - let fq_prior_tag_name = format!("refs/tags/{}", prior_tag_name); + let fq_prior_tag_name = format!("refs/tags/{prior_tag_name}"); repo.tag_foreach(|id, name| { if name == fq_prior_tag_name.as_bytes() { tag_id = Some(id); diff --git a/src/steps/hook.rs b/src/steps/hook.rs index 3b43aab8c..ed50c5b08 100644 --- a/src/steps/hook.rs +++ b/src/steps/hook.rs @@ -207,8 +207,7 @@ pub fn hook( // so here we set dry_run=false and always execute the command. if !cmd::call_with_env(pre_rel_hook, envs, cwd, false)? { let _ = crate::ops::shell::error(format!( - "release of {} aborted by non-zero return of prerelease hook.", - crate_name + "release of {crate_name} aborted by non-zero return of prerelease hook." )); return Err(101.into()); } diff --git a/src/steps/mod.rs b/src/steps/mod.rs index c53fdcd82..40905ec97 100644 --- a/src/steps/mod.rs +++ b/src/steps/mod.rs @@ -57,7 +57,7 @@ pub fn verify_tags_missing( let crate_name = pkg.meta.name.as_str(); let _ = crate::ops::shell::log( level, - format!("tag `{}` already exists (for `{}`)", tag_name, crate_name), + format!("tag `{tag_name}` already exists (for `{crate_name}`)"), ); tag_exists = true; } @@ -91,7 +91,7 @@ pub fn verify_tags_exist( let crate_name = pkg.meta.name.as_str(); let _ = crate::ops::shell::log( level, - format!("tag `{}` doesn't exist (for `{}`)", tag_name, crate_name), + format!("tag `{tag_name}` doesn't exist (for `{crate_name}`)"), ); tag_missing = true; } @@ -163,10 +163,7 @@ pub fn verify_if_behind( let branch = crate::ops::git::current_branch(path)?; crate::ops::git::fetch(path, git_remote, &branch)?; if crate::ops::git::is_behind_remote(path, git_remote, &branch)? { - let _ = crate::ops::shell::log( - level, - format!("{} is behind {}/{}", branch, git_remote, branch), - ); + let _ = crate::ops::shell::log(level, format!("{branch} is behind {git_remote}/{branch}")); if level == log::Level::Error { success = false; if !dry_run { @@ -464,7 +461,7 @@ pub fn confirm( use std::io::Write; let mut buffer: Vec = vec![]; - writeln!(&mut buffer, "{}", step).unwrap(); + writeln!(&mut buffer, "{step}").unwrap(); for pkg in pkgs { let crate_name = pkg.meta.name.as_str(); let version = pkg.planned_version.as_ref().unwrap_or(&pkg.initial_version); @@ -558,10 +555,10 @@ impl std::fmt::Display for TargetVersion { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { match self { TargetVersion::Relative(bump_level) => { - write!(f, "{}", bump_level) + write!(f, "{bump_level}") } TargetVersion::Absolute(version) => { - write!(f, "{}", version) + write!(f, "{version}") } } } @@ -660,7 +657,7 @@ impl FromStr for BumpLevel { return Ok(*variant); } } - Err(format!("Invalid variant: {}", s)) + Err(format!("Invalid variant: {s}")) } } diff --git a/src/steps/release.rs b/src/steps/release.rs index 881c6939d..a1ce654a0 100644 --- a/src/steps/release.rs +++ b/src/steps/release.rs @@ -130,8 +130,7 @@ impl ReleaseStep { { if !changed.is_empty() { let _ = crate::ops::shell::warn(format!( - "disabled by user, skipping {} which has files changed since {}: {:#?}", - crate_name, prior_tag_name, changed + "disabled by user, skipping {crate_name} which has files changed since {prior_tag_name}: {changed:#?}" )); } else { log::trace!( diff --git a/src/steps/tag.rs b/src/steps/tag.rs index 644f453ce..52e58f24f 100644 --- a/src/steps/tag.rs +++ b/src/steps/tag.rs @@ -90,8 +90,7 @@ impl TagStep { if git::tag_exists(ws_meta.workspace_root.as_std_path(), tag_name)? { let crate_name = pkg.meta.name.as_str(); let _ = crate::ops::shell::warn(format!( - "disabled due to existing tag ({}), skipping {}", - tag_name, crate_name + "disabled due to existing tag ({tag_name}), skipping {crate_name}" )); pkg.planned_tag = None; pkg.config.tag = Some(false);