Skip to content

Commit 7ee9577

Browse files
committed
Resolve clippy issues
1 parent d545399 commit 7ee9577

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

src/bors/handlers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub async fn handle_bors_repository_event(
3939
.read()
4040
.unwrap()
4141
.get(event.repository())
42-
.map(Arc::clone)
42+
.cloned()
4343
else {
4444
return Err(anyhow::anyhow!(
4545
"Repository {} not found in the bot state",

src/github/api/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl GithubRepositoryClient {
131131
head: &CommitSha,
132132
commit_message: &str,
133133
) -> Result<CommitSha, MergeError> {
134-
Ok(merge_branches(self, base, head, commit_message).await?)
134+
merge_branches(self, base, head, commit_message).await
135135
}
136136

137137
/// Find all check suites attached to the given commit and branch.

src/tests/mocks/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ impl ExternalHttpMock {
116116
/// Create a mock that dynamically responds to its requests using the given function `f`.
117117
/// It is expected that the path will be a regex, which will be parsed when a request is received,
118118
/// and matched capture groups will be passed as a second argument to `f`.
119-
fn dynamic_mock_req<F: Fn(&Request, [&str; N]) -> ResponseTemplate, const N: usize>(
119+
fn dynamic_mock_req<
120+
F: Fn(&Request, [&str; N]) -> ResponseTemplate + Send + Sync + 'static,
121+
const N: usize,
122+
>(
120123
f: F,
121124
m: &str,
122125
regex: String,
123-
) -> Mock
124-
where
125-
F: Send + Sync + 'static,
126-
{
126+
) -> Mock {
127127
// We need to parse the regex from the request path again, because wiremock doesn't give
128128
// the parsed path regex results to us :(
129129
let parsed_regex = Regex::new(&regex).unwrap();

src/tests/mocks/pull_request.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ pub async fn mock_pull_requests(
2424
comments_tx: Sender<Comment>,
2525
mock_server: &MockServer,
2626
) {
27-
let repo_arc = repo;
28-
let repo = repo_arc.lock();
29-
let repo_name = repo.name.clone();
30-
for &pr_number in repo.pull_requests.keys() {
27+
let repo_name = repo.lock().name.clone();
28+
let prs = repo.lock().pull_requests.clone();
29+
for &pr_number in prs.keys() {
3130
Mock::given(method("GET"))
3231
.and(path(format!("/repos/{repo_name}/pulls/{pr_number}")))
3332
.respond_with(
@@ -36,18 +35,23 @@ pub async fn mock_pull_requests(
3635
.mount(mock_server)
3736
.await;
3837

39-
mock_pr_comments(&repo, pr_number, comments_tx.clone(), mock_server).await;
40-
mock_pr_labels(repo_arc.clone(), repo_name.clone(), pr_number, mock_server).await;
38+
mock_pr_comments(
39+
repo_name.clone(),
40+
pr_number,
41+
comments_tx.clone(),
42+
mock_server,
43+
)
44+
.await;
45+
mock_pr_labels(repo.clone(), repo_name.clone(), pr_number, mock_server).await;
4146
}
4247
}
4348

4449
async fn mock_pr_comments(
45-
repo: &Repo,
50+
repo_name: GithubRepoName,
4651
pr_number: u64,
4752
comments_tx: Sender<Comment>,
4853
mock_server: &MockServer,
4954
) {
50-
let repo_name = repo.name.clone();
5155
Mock::given(method("POST"))
5256
.and(path(format!(
5357
"/repos/{repo_name}/issues/{pr_number}/comments",

src/tests/mocks/repository.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl Branch {
201201

202202
impl Default for Branch {
203203
fn default() -> Self {
204-
Self::new(&default_branch_name(), &default_branch_sha())
204+
Self::new(default_branch_name(), default_branch_sha())
205205
}
206206
}
207207

@@ -334,7 +334,7 @@ async fn mock_create_branch(repo: Arc<Mutex<Repo>>, mock_server: &MockServer) {
334334
}
335335
None => {
336336
// Create a new branch
337-
repo.branches.push(Branch::new(&branch_name, &sha));
337+
repo.branches.push(Branch::new(branch_name, &sha));
338338
}
339339
}
340340

@@ -481,18 +481,21 @@ async fn mock_check_suites(repo: Arc<Mutex<Repo>>, mock_server: &MockServer) {
481481
}
482482

483483
async fn mock_config(repo: Arc<Mutex<Repo>>, mock_server: &MockServer) {
484-
let repo = repo.lock();
485-
Mock::given(method("GET"))
486-
.and(path(format!(
487-
"/repos/{}/contents/rust-bors.toml",
488-
repo.name
489-
)))
490-
.respond_with(
491-
ResponseTemplate::new(200)
492-
.set_body_json(GitHubContent::new("rust-bors.toml", &repo.config)),
493-
)
494-
.mount(mock_server)
495-
.await;
484+
// Extracted into a block to avoid holding the lock over an await point
485+
let mock = {
486+
let repo = repo.lock();
487+
Mock::given(method("GET"))
488+
.and(path(format!(
489+
"/repos/{}/contents/rust-bors.toml",
490+
repo.name
491+
)))
492+
.respond_with(
493+
ResponseTemplate::new(200)
494+
.set_body_json(GitHubContent::new("rust-bors.toml", &repo.config)),
495+
)
496+
.mount(mock_server)
497+
};
498+
mock.await;
496499
}
497500

498501
/// Represents all repositories for an installation

src/tests/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub struct TestSyncMarker {
88
impl TestSyncMarker {
99
pub const fn new() -> Self {
1010
Self {
11-
state: Lazy::new(|| TestSyncMarkerInner::new()),
11+
state: Lazy::new(TestSyncMarkerInner::new),
1212
}
1313
}
1414

0 commit comments

Comments
 (0)