Skip to content

Commit 7aec8c7

Browse files
committed
fix clippy issues
1 parent 8105ef9 commit 7aec8c7

File tree

11 files changed

+32
-42
lines changed

11 files changed

+32
-42
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ jobs:
2929
fetch-depth: 50
3030

3131
- name: Install Rust Stable
32+
env:
33+
RUST_VERSION: "1.85.0"
3234
run: |
3335
rustc -vV
34-
rustup toolchain install 1.85.0
35-
rustup default 1.85.0
36-
rustup component add rustfmt
36+
rustup toolchain install $RUST_VERSION
37+
rustup default $RUST_VERSION
38+
rustup component add rustfmt clippy
3739
rustc -vV
3840
3941
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
@@ -49,6 +51,9 @@ jobs:
4951
- name: Run rustfmt
5052
run: cargo fmt -- --check
5153

54+
- name: Run clippy
55+
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
56+
5257
- name: Run tests
5358
run: cargo test --workspace --all-features
5459

rust_team_data/src/email_encryption.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ pub enum Error {
7979
impl std::fmt::Display for Error {
8080
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8181
match self {
82-
Error::GetRandom(e) => write!(f, "{}", e),
83-
Error::Hex(e) => write!(f, "{}", e),
82+
Error::GetRandom(e) => write!(f, "{e}"),
83+
Error::Hex(e) => write!(f, "{e}"),
8484
Error::EncryptionFailed => write!(f, "encryption failed"),
8585
Error::DecryptionFailed => write!(f, "encryption failed"),
8686
Error::InvalidUtf8 => write!(f, "invalid UTF-8"),

sync-team/src/github/api/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl HttpClient {
176176
for link in links.values() {
177177
if link
178178
.rel()
179-
.map(|r| r.iter().any(|r| *r == RelationType::Next))
179+
.map(|r| r.contains(&RelationType::Next))
180180
.unwrap_or(false)
181181
{
182182
next = Some(GitHubUrl::new(link.link(), next_url.org()));

sync-team/src/github/api/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl GitHubWrite {
271271
archived: settings.archived,
272272
allow_auto_merge: settings.auto_merge_enabled,
273273
};
274-
debug!("Editing repo {}/{} with {:?}", org, repo_name, req);
274+
debug!("Editing repo {org}/{repo_name} with {req:?}");
275275
if !self.dry_run {
276276
self.client
277277
.send(Method::PATCH, &GitHubUrl::repos(org, repo_name, "")?, &req)?;
@@ -369,7 +369,7 @@ impl GitHubWrite {
369369
branch_protection: &BranchProtection,
370370
org: &str,
371371
) -> anyhow::Result<()> {
372-
debug!("Updating '{}' branch protection", pattern);
372+
debug!("Updating '{pattern}' branch protection");
373373
#[derive(Debug, serde::Serialize)]
374374
#[serde(rename_all = "camelCase")]
375375
struct Params<'a> {
@@ -462,7 +462,7 @@ impl GitHubWrite {
462462
repo_name: &str,
463463
id: &str,
464464
) -> anyhow::Result<()> {
465-
debug!("Removing protection in {}/{}", org, repo_name);
465+
debug!("Removing protection in {org}/{repo_name}");
466466
println!("Remove protection {id}");
467467
if !self.dry_run {
468468
#[derive(serde::Serialize)]

sync-team/src/github/tests/test_utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ pub struct TeamData {
199199
}
200200

201201
impl TeamData {
202+
#[allow(clippy::new_ret_no_self)]
202203
pub fn new(name: &str) -> TeamDataBuilder {
203204
TeamDataBuilder::default().name(name.to_string())
204205
}
@@ -283,6 +284,7 @@ pub struct RepoData {
283284
}
284285

285286
impl RepoData {
287+
#[allow(clippy::new_ret_no_self)]
286288
pub fn new(name: &str) -> RepoDataBuilder {
287289
RepoDataBuilder::default().name(name.to_string())
288290
}

sync-team/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn run_sync_team(
2424
}
2525

2626
for service in services {
27-
info!("synchronizing {}", service);
27+
info!("synchronizing {service}");
2828
match service.as_str() {
2929
"github" => {
3030
let client = HttpClient::new()?;
@@ -33,7 +33,7 @@ pub fn run_sync_team(
3333
let repos = team_api.get_repos()?;
3434
let diff = create_diff(gh_read, teams, repos)?;
3535
if !diff.is_empty() {
36-
info!("{}", diff);
36+
info!("{diff}");
3737
}
3838
if !only_print_plan {
3939
let gh_write = GitHubWrite::new(client, dry_run)?;
@@ -51,7 +51,7 @@ pub fn run_sync_team(
5151
let sync = SyncZulip::new(username, token, &team_api, dry_run)?;
5252
let diff = sync.diff_all()?;
5353
if !diff.is_empty() {
54-
info!("{}", diff);
54+
info!("{diff}");
5555
}
5656
if !only_print_plan {
5757
diff.apply(&sync)?;

sync-team/src/mailgun/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Mailgun {
8989
}
9090

9191
pub(super) fn delete_route(&self, id: &str) -> Result<(), Error> {
92-
info!("deleting route with ID {}", id);
92+
info!("deleting route with ID {id}");
9393
if self.dry_run {
9494
return Ok(());
9595
}

sync-team/src/team_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl TeamApi {
5454
.map(Cow::Owned)
5555
.unwrap_or_else(|_| Cow::Borrowed(rust_team_data::v1::BASE_URL));
5656
let url = format!("{base}/{url}");
57-
trace!("http request: GET {}", url);
57+
trace!("http request: GET {url}");
5858
Ok(reqwest::blocking::get(&url)?
5959
.error_for_status()?
6060
.json_annotated()?)

sync-team/src/zulip/api.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ impl ZulipApi {
3737
member_ids: &[u64],
3838
) -> anyhow::Result<()> {
3939
log::info!(
40-
"creating Zulip user group '{}' with description '{}' and member ids: {:?}",
41-
user_group_name,
42-
description,
43-
member_ids
40+
"creating Zulip user group '{user_group_name}' with description '{description}' and member ids: {member_ids:?}"
4441
);
4542
if self.dry_run {
4643
return Ok(());
@@ -64,7 +61,7 @@ impl ZulipApi {
6461
};
6562
let error = body.get("msg").ok_or_else(err)?.as_str().ok_or_else(err)?;
6663
if error.contains("already exists") {
67-
log::debug!("Zulip user group '{}' already existed", user_group_name);
64+
log::debug!("Zulip user group '{user_group_name}' already existed");
6865
return Ok(());
6966
} else {
7067
return Err(err());
@@ -157,17 +154,13 @@ impl ZulipApi {
157154
) -> anyhow::Result<()> {
158155
if add_ids.is_empty() && remove_ids.is_empty() {
159156
log::debug!(
160-
"user group {} does not need to have its group members updated",
161-
user_group_id
157+
"user group {user_group_id} does not need to have its group members updated"
162158
);
163159
return Ok(());
164160
}
165161

166162
log::info!(
167-
"updating user group {} by adding {:?} and removing {:?}",
168-
user_group_id,
169-
add_ids,
170-
remove_ids
163+
"updating user group {user_group_id} by adding {add_ids:?} and removing {remove_ids:?}"
171164
);
172165

173166
if self.dry_run {
@@ -205,19 +198,11 @@ impl ZulipApi {
205198
remove_ids: &[u64],
206199
) -> anyhow::Result<()> {
207200
if add_ids.is_empty() && remove_ids.is_empty() {
208-
log::debug!(
209-
"stream {} does not need to have its members updated",
210-
stream_id
211-
);
201+
log::debug!("stream {stream_id} does not need to have its members updated");
212202
return Ok(());
213203
}
214204

215-
log::info!(
216-
"updating stream {} by adding {:?} and removing {:?}",
217-
stream_id,
218-
add_ids,
219-
remove_ids
220-
);
205+
log::info!("updating stream {stream_id} by adding {add_ids:?} and removing {remove_ids:?}");
221206

222207
if self.dry_run {
223208
return Ok(());

sync-team/src/zulip/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ fn get_user_group_definitions(
389389
ZulipGroupMember::Email(e) => {
390390
let id = email_map.get(e);
391391
if id.is_none() {
392-
log::warn!("no Zulip id found for '{}'", e);
392+
log::warn!("no Zulip id found for '{e}'");
393393
}
394394
id.copied()
395395
}
@@ -424,7 +424,7 @@ fn get_stream_definitions(
424424
ZulipStreamMember::Email(e) => {
425425
let id = email_map.get(e);
426426
if id.is_none() {
427-
log::warn!("no Zulip id found for '{}'", e);
427+
log::warn!("no Zulip id found for '{e}'");
428428
}
429429
id.copied()
430430
}

0 commit comments

Comments
 (0)