Skip to content

Commit e7fa404

Browse files
committed
fix: cargo clippy lints
1 parent 65a2980 commit e7fa404

File tree

11 files changed

+23
-38
lines changed

11 files changed

+23
-38
lines changed

src/api_client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl CodSpeedAPIClient {
170170
.await;
171171
match response {
172172
Ok(response) => Ok(response.create_login_session),
173-
Err(err) => bail!("Failed to create login session: {}", err),
173+
Err(err) => bail!("Failed to create login session: {err}"),
174174
}
175175
}
176176

@@ -189,7 +189,7 @@ impl CodSpeedAPIClient {
189189
.await;
190190
match response {
191191
Ok(response) => Ok(response.consume_login_session),
192-
Err(err) => bail!("Failed to use login session: {}", err),
192+
Err(err) => bail!("Failed to use login session: {err}"),
193193
}
194194
}
195195

@@ -212,7 +212,7 @@ impl CodSpeedAPIClient {
212212
Err(err) if err.contains_error_code("UNAUTHENTICATED") => {
213213
bail!("Your session has expired, please login again using `codspeed auth login`")
214214
}
215-
Err(err) => bail!("Failed to fetch local run report: {}", err),
215+
Err(err) => bail!("Failed to fetch local run report: {err}"),
216216
}
217217
}
218218
}

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl CodSpeedConfig {
5656
debug!("Config file not found at {}", config_path.display());
5757
CodSpeedConfig::default()
5858
}
59-
Err(e) => bail!("Failed to load config: {}", e),
59+
Err(e) => bail!("Failed to load config: {e}"),
6060
};
6161

6262
if let Some(oauth_token) = oauth_token_override {

src/run/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl TryFrom<RunArgs> for Config {
7070
let instruments = Instruments::try_from(&args)?;
7171
let raw_upload_url = args.upload_url.unwrap_or_else(|| DEFAULT_UPLOAD_URL.into());
7272
let upload_url = Url::parse(&raw_upload_url)
73-
.map_err(|e| anyhow!("Invalid upload URL: {}, {}", raw_upload_url, e))?;
73+
.map_err(|e| anyhow!("Invalid upload URL: {raw_upload_url}, {e}"))?;
7474

7575
Ok(Self {
7676
upload_url,

src/run/helpers/download_file.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub async fn download_file(url: &Url, path: &Path) -> Result<()> {
99
.get(url.clone())
1010
.send()
1111
.await
12-
.map_err(|e| anyhow!("Failed to download file: {}", e))?;
12+
.map_err(|e| anyhow!("Failed to download file: {e}"))?;
1313
if !response.status().is_success() {
1414
bail!("Failed to download file: {}", response.status());
1515
}
@@ -18,13 +18,8 @@ pub async fn download_file(url: &Url, path: &Path) -> Result<()> {
1818
let content = response
1919
.bytes()
2020
.await
21-
.map_err(|e| anyhow!("Failed to read response: {}", e))?;
22-
std::io::copy(&mut content.as_ref(), &mut file).map_err(|e| {
23-
anyhow!(
24-
"Failed to write to file: {}, {}",
25-
path.display(),
26-
e.to_string()
27-
)
28-
})?;
21+
.map_err(|e| anyhow!("Failed to read response: {e}"))?;
22+
std::io::copy(&mut content.as_ref(), &mut file)
23+
.map_err(|e| anyhow!("Failed to write to file: {}, {}", path.display(), e))?;
2924
Ok(())
3025
}

src/run/helpers/get_env_var.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use anyhow::anyhow;
33
use std::env;
44

55
pub fn get_env_variable(name: &str) -> Result<String> {
6-
env::var(name).map_err(|_| anyhow!("{} environment variable not found", name))
6+
env::var(name).map_err(|_| anyhow!("{name} environment variable not found"))
77
}
88

99
#[cfg(test)]

src/run/helpers/parse_git_remote.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ pub struct GitRemote {
1717

1818
pub fn parse_git_remote(remote: &str) -> Result<GitRemote> {
1919
let captures = REMOTE_REGEX.captures(remote).ok_or_else(|| {
20-
anyhow!(
21-
"Could not extract owner and repository from remote url: {}",
22-
remote
23-
)
20+
anyhow!("Could not extract owner and repository from remote url: {remote}")
2421
})?;
2522

2623
let domain = captures.name("domain").unwrap().as_str();

src/run/instruments/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl TryFrom<&RunArgs> for Instruments {
4747
for instrument_name in &args.instruments {
4848
match instrument_name.as_str() {
4949
"mongodb" => validated_instrument_names.insert(InstrumentName::MongoDB),
50-
_ => bail!("Invalid instrument name: {}", instrument_name),
50+
_ => bail!("Invalid instrument name: {instrument_name}"),
5151
};
5252
}
5353

src/run/run_environment/gitlab_ci/provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl TryFrom<&Config> for GitLabCIProvider {
101101
None,
102102
),
103103

104-
_ => bail!("Event {} is not supported by CodSpeed", ci_pipeline_source),
104+
_ => bail!("Event {ci_pipeline_source} is not supported by CodSpeed"),
105105
};
106106

107107
let run_id = get_env_variable("CI_JOB_ID")?;

src/run/run_environment/local/provider.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,7 @@ fn extract_provider_owner_and_repository_from_remote_url(
191191
let repository_provider = match domain.as_str() {
192192
"github.com" => RepositoryProvider::GitHub,
193193
"gitlab.com" => RepositoryProvider::GitLab,
194-
domain => bail!(
195-
"Repository provider {} is not supported by CodSpeed",
196-
domain
197-
),
194+
domain => bail!("Repository provider {domain} is not supported by CodSpeed"),
198195
};
199196

200197
Ok((

src/run/runner/valgrind/measure.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ pub async fn measure(
9393
format!(
9494
"{}:{}:{}",
9595
introspected_nodejs::setup()
96-
.map_err(|e| anyhow!("failed to setup NodeJS introspection. {}", e))?
96+
.map_err(|e| anyhow!("failed to setup NodeJS introspection. {e}"))?
9797
.to_string_lossy(),
9898
introspected_golang::setup()
99-
.map_err(|e| anyhow!("failed to setup Go introspection. {}", e))?
99+
.map_err(|e| anyhow!("failed to setup Go introspection. {e}"))?
100100
.to_string_lossy(),
101101
env::var("PATH").unwrap_or_default(),
102102
),
@@ -136,7 +136,7 @@ pub async fn measure(
136136
debug!("cmd: {cmd:?}");
137137
let status = run_command_with_log_pipe(cmd)
138138
.await
139-
.map_err(|e| anyhow!("failed to execute the benchmark process. {}", e))?;
139+
.map_err(|e| anyhow!("failed to execute the benchmark process. {e}"))?;
140140
debug!(
141141
"Valgrind exit code = {:?}, Valgrind signal = {:?}",
142142
status.code(),
@@ -157,14 +157,11 @@ pub async fn measure(
157157
let content = std::fs::read_to_string(&cmd_status_path)?;
158158
content
159159
.parse::<u32>()
160-
.map_err(|e| anyhow!("unable to retrieve the program exit code. {}", e))?
160+
.map_err(|e| anyhow!("unable to retrieve the program exit code. {e}"))?
161161
};
162162
debug!("Program exit code = {cmd_status}");
163163
if cmd_status != 0 {
164-
bail!(
165-
"failed to execute the benchmark process, exit code: {}",
166-
cmd_status
167-
);
164+
bail!("failed to execute the benchmark process, exit code: {cmd_status}");
168165
}
169166

170167
Ok(())

0 commit comments

Comments
 (0)