Skip to content

Commit 8aa0979

Browse files
committed
fix clippy warnings
1 parent 1b99f55 commit 8aa0979

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

api/src/config/config_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl AppConfig {
148148
}
149149

150150
fn must_from_env(key: &str) -> String {
151-
std::env::var(key).unwrap_or_else(|_| panic!("{} must be set!", key))
151+
std::env::var(key).unwrap_or_else(|_| panic!("{key} must be set!"))
152152
}
153153

154154
fn from_env_or_default<T>(key: &str, default: T) -> T

api/src/gitlab.rs

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ use tokio::sync::mpsc;
1717
pub trait GitlabApi: Send + Sync {
1818
async fn groups(&self, skip_groups: &[u64], top_level: bool) -> Result<Vec<Group>, ApiError>;
1919

20-
async fn projects(&self, group_id: u64, include_subgroups: bool) -> Result<Vec<Project>, ApiError>;
20+
async fn projects(
21+
&self,
22+
group_id: u64,
23+
include_subgroups: bool,
24+
) -> Result<Vec<Project>, ApiError>;
2125

2226
async fn latest_pipeline(
2327
&self,
@@ -81,7 +85,7 @@ impl GitlabClient {
8185
.build()
8286
.expect("http client to be build");
8387
Self {
84-
base_url: format!("{}/api/v4", gitlab_url),
88+
base_url: format!("{gitlab_url}/api/v4"),
8589
http_client,
8690
}
8791
}
@@ -97,7 +101,7 @@ impl GitlabClient {
97101
let url = Url::parse_with_params(format!("{}{}", self.base_url, path).as_str(), params)
98102
.expect("url to be parsed with params");
99103

100-
log::debug!("HTTP (post) {} body: {:?}", url, body_json);
104+
log::debug!("HTTP (post) {url} body: {body_json:?}");
101105
let builder = self.http_client.post(url);
102106

103107
match body_json {
@@ -123,7 +127,7 @@ impl GitlabClient {
123127
let url = Url::parse_with_params(format!("{}{}", self.base_url, path).as_str(), params)
124128
.expect("url to be parsed with params");
125129

126-
log::debug!("HTTP (get) {}", url);
130+
log::debug!("HTTP (get) {url}");
127131

128132
self.http_client.get(url).send().await?.error_for_status()
129133
}
@@ -174,7 +178,7 @@ impl GitlabClient {
174178
page: _,
175179
} = self.get_page(path.clone(), 1, params.clone()).await?;
176180

177-
log::debug!("fetched page 1/{} data: {:?}", total_pages, all_data);
181+
log::debug!("fetched page 1/{total_pages} data: {all_data:?}");
178182

179183
if total_pages == 1 {
180184
return Ok(all_data);
@@ -188,10 +192,10 @@ impl GitlabClient {
188192
let path = path.clone();
189193
let tx = tx.clone();
190194
tokio::spawn(async move {
191-
log::debug!("fetching page {}", page);
195+
log::debug!("fetching page {page}");
192196
let result = self_clone.get_page(path, page, params).await;
193197
if let Err(err) = tx.send(result).await {
194-
log::error!("could not send result via channel. err: {}", err);
198+
log::error!("could not send result via channel. err: {err}");
195199
}
196200
});
197201
}
@@ -204,7 +208,7 @@ impl GitlabClient {
204208
total_pages,
205209
page,
206210
} = result?;
207-
log::debug!("fetched page {}/{} data: {:?}", page, total_pages, data);
211+
log::debug!("fetched page {page}/{total_pages} data: {data:?}");
208212
all_data.append(&mut data);
209213
}
210214

@@ -231,12 +235,19 @@ impl GitlabApi for GitlabClient {
231235
self.get_all_pages(path.to_string(), params).await
232236
}
233237

234-
async fn projects(&self, group_id: u64, include_subgroups: bool) -> Result<Vec<Project>, ApiError> {
238+
async fn projects(
239+
&self,
240+
group_id: u64,
241+
include_subgroups: bool,
242+
) -> Result<Vec<Project>, ApiError> {
235243
let params = [
236244
("archived".to_string(), "false".to_string()),
237-
("include_subgroups".to_string(), include_subgroups.to_string()),
245+
(
246+
"include_subgroups".to_string(),
247+
include_subgroups.to_string(),
248+
),
238249
];
239-
let path = format!("/groups/{}/projects", group_id);
250+
let path = format!("/groups/{group_id}/projects");
240251

241252
self.get_all_pages(path, params.to_vec()).await
242253
}
@@ -247,7 +258,7 @@ impl GitlabApi for GitlabClient {
247258
branch: String,
248259
) -> Result<Option<Pipeline>, ApiError> {
249260
let params = [("ref".to_string(), branch)];
250-
let path = format!("/projects/{}/pipelines/latest", project_id);
261+
let path = format!("/projects/{project_id}/pipelines/latest");
251262

252263
match self.do_get_parsed::<Pipeline>(path, params.to_vec()).await {
253264
Ok(pipeline) => Ok(Some(pipeline)),
@@ -276,7 +287,7 @@ impl GitlabApi for GitlabClient {
276287
.map(|d| [("updated_after".to_string(), d.to_string())])
277288
.unwrap_or_default();
278289

279-
let path = format!("/projects/{}/pipelines", project_id);
290+
let path = format!("/projects/{project_id}/pipelines");
280291
self.get_all_pages(path, params.to_vec()).await
281292
}
282293

@@ -286,7 +297,7 @@ impl GitlabApi for GitlabClient {
286297
pipeline_id: u64,
287298
) -> Result<Pipeline, ApiError> {
288299
let params = [];
289-
let path = format!("/projects/{}/pipelines/{}/retry", project_id, pipeline_id);
300+
let path = format!("/projects/{project_id}/pipelines/{pipeline_id}/retry");
290301

291302
self.do_post_parsed(path, params.to_vec(), None)
292303
.await
@@ -300,7 +311,7 @@ impl GitlabApi for GitlabClient {
300311
env_vars: Option<HashMap<String, String>>,
301312
) -> Result<Pipeline, ApiError> {
302313
let params = [("ref".to_string(), branch)];
303-
let path = format!("/projects/{}/pipeline", project_id);
314+
let path = format!("/projects/{project_id}/pipeline");
304315

305316
let body_json = env_vars.map(|vars| {
306317
let mut env_vars = Vec::new();
@@ -328,7 +339,7 @@ impl GitlabApi for GitlabClient {
328339
pipeline_id: u64,
329340
) -> Result<Pipeline, ApiError> {
330341
let params = [];
331-
let path = format!("/projects/{}/pipelines/{}/cancel", project_id, pipeline_id);
342+
let path = format!("/projects/{project_id}/pipelines/{pipeline_id}/cancel");
332343

333344
self.do_post_parsed(path, params.to_vec(), None)
334345
.await
@@ -337,13 +348,13 @@ impl GitlabApi for GitlabClient {
337348

338349
async fn branches(&self, project_id: u64) -> Result<Vec<Branch>, ApiError> {
339350
let params = [];
340-
let path = format!("/projects/{}/repository/branches", project_id);
351+
let path = format!("/projects/{project_id}/repository/branches");
341352
self.get_all_pages(path, params.to_vec()).await
342353
}
343354

344355
async fn schedules(&self, project_id: u64) -> Result<Vec<Schedule>, ApiError> {
345356
let params = [];
346-
let path = format!("/projects/{}/pipeline_schedules", project_id);
357+
let path = format!("/projects/{project_id}/pipeline_schedules");
347358
self.get_all_pages(path, params.to_vec()).await
348359
}
349360

@@ -358,13 +369,13 @@ impl GitlabApi for GitlabClient {
358369
params.push(("scope[]".to_string(), scope.as_string()))
359370
}
360371

361-
let path = format!("/projects/{}/pipelines/{}/jobs", project_id, pipeline_id);
372+
let path = format!("/projects/{project_id}/pipelines/{pipeline_id}/jobs");
362373
self.get_all_pages(path, params).await
363374
}
364375

365376
async fn artifact(&self, project_id: u64, job_id: u64) -> Result<Bytes, ApiError> {
366377
let params = [];
367-
let path = format!("/projects/{}/jobs/{}/artifacts", project_id, job_id);
378+
let path = format!("/projects/{project_id}/jobs/{job_id}/artifacts");
368379
Ok(self.do_get(path, params.to_vec()).await?.bytes().await?)
369380
}
370381
}

api/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ async fn main() -> std::io::Result<()> {
4444

4545
log::info!("Gitlab CI Dashboard :: {} ::", &api_config.api_version);
4646

47-
log::debug!("{:?}", app_config);
48-
log::debug!("{:?}", api_config);
47+
log::debug!("{app_config:?}");
48+
log::debug!("{api_config:?}");
4949

5050
let api_config = Data::new(api_config);
5151
let qs_config = QueryStringConfig::default().parse_mode(ParseMode::Delimiter(b','));

0 commit comments

Comments
 (0)