Skip to content

Commit fa50ca2

Browse files
ref: Enable str-to-string lint
Primarily to maintain a consistent style for converting `&str` to `String`.
1 parent 504638f commit fa50ca2

File tree

28 files changed

+85
-88
lines changed

28 files changed

+85
-88
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ unstable-mobile-app = ["apple-catalog-parsing"]
100100

101101
[workspace.lints.clippy]
102102
allow-attributes = "warn"
103+
str-to-string = "warn"
103104
unnecessary-wraps = "warn"
104105
unwrap-used = "warn"
105106

src/api/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl<'a> AuthenticatedApi<'a> {
473473
checksums: &[String],
474474
) -> ApiResult<Vec<Artifact>> {
475475
let mut rv = vec![];
476-
let mut cursor = "".to_string();
476+
let mut cursor = "".to_owned();
477477
loop {
478478
let mut path = if let Some(project) = project {
479479
format!(
@@ -1080,7 +1080,7 @@ impl<'a> AuthenticatedApi<'a> {
10801080
/// we're issuing a request to a monolith deployment.
10811081
pub fn list_organizations(&self, region: Option<&Region>) -> ApiResult<Vec<Organization>> {
10821082
let mut rv = vec![];
1083-
let mut cursor = "".to_string();
1083+
let mut cursor = "".to_owned();
10841084
loop {
10851085
let current_path = &format!("/organizations/?cursor={}", QueryArg(&cursor));
10861086
let resp = if let Some(rg) = region {
@@ -1128,7 +1128,7 @@ impl<'a> AuthenticatedApi<'a> {
11281128
/// List all monitors associated with an organization
11291129
pub fn list_organization_monitors(&self, org: &str) -> ApiResult<Vec<Monitor>> {
11301130
let mut rv = vec![];
1131-
let mut cursor = "".to_string();
1131+
let mut cursor = "".to_owned();
11321132
loop {
11331133
let resp = self.get(&format!(
11341134
"/organizations/{}/monitors/?cursor={}",
@@ -1156,7 +1156,7 @@ impl<'a> AuthenticatedApi<'a> {
11561156
/// List all projects associated with an organization
11571157
pub fn list_organization_projects(&self, org: &str) -> ApiResult<Vec<Project>> {
11581158
let mut rv = vec![];
1159-
let mut cursor = "".to_string();
1159+
let mut cursor = "".to_owned();
11601160
loop {
11611161
let resp = self.get(&format!(
11621162
"/organizations/{}/projects/?cursor={}",
@@ -1189,7 +1189,7 @@ impl<'a> AuthenticatedApi<'a> {
11891189
max_pages: usize,
11901190
) -> ApiResult<Vec<ProcessedEvent>> {
11911191
let mut rv = vec![];
1192-
let mut cursor = "".to_string();
1192+
let mut cursor = "".to_owned();
11931193
let mut requests_no = 0;
11941194

11951195
loop {
@@ -1236,7 +1236,7 @@ impl<'a> AuthenticatedApi<'a> {
12361236
query: Option<String>,
12371237
) -> ApiResult<Vec<Issue>> {
12381238
let mut rv = vec![];
1239-
let mut cursor = "".to_string();
1239+
let mut cursor = "".to_owned();
12401240
let mut requests_no = 0;
12411241

12421242
let url = if let Some(query) = query {
@@ -1283,7 +1283,7 @@ impl<'a> AuthenticatedApi<'a> {
12831283
/// List all repos associated with an organization
12841284
pub fn list_organization_repos(&self, org: &str) -> ApiResult<Vec<Repo>> {
12851285
let mut rv = vec![];
1286-
let mut cursor = "".to_string();
1286+
let mut cursor = "".to_owned();
12871287
loop {
12881288
let path = format!(
12891289
"/organizations/{}/repos/?cursor={}",
@@ -1930,7 +1930,7 @@ fn log_headers(is_response: bool, data: &[u8]) {
19301930

19311931
let replaced = AUTH_RE.replace_all(line, |caps: &Captures<'_>| {
19321932
let info = if &caps[1].to_lowercase() == "basic" {
1933-
caps[3].split(':').next().unwrap().to_string()
1933+
caps[3].split(':').next().unwrap().to_owned()
19341934
} else {
19351935
format!("{}***", &caps[3][..std::cmp::min(caps[3].len(), 8)])
19361936
};

src/api/pagination.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl FromStr for Pagination {
3333

3434
*target = Some(Link {
3535
results: item.get("results") == Some(&"true"),
36-
cursor: (*item.get("cursor").unwrap_or(&"")).to_string(),
36+
cursor: (*item.get("cursor").unwrap_or(&"")).to_owned(),
3737
});
3838
}
3939

src/commands/bash_hook.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn send_event(
117117
);
118118
}
119119

120-
let mut cmd = "unknown".to_string();
120+
let mut cmd = "unknown".to_owned();
121121
let mut exit_code = 1;
122122
let mut frames = vec![];
123123

@@ -129,7 +129,7 @@ fn send_event(
129129
// meta info
130130
if line.starts_with('@') {
131131
if let Some(rest) = line.strip_prefix("@command:") {
132-
cmd = rest.to_string();
132+
cmd = rest.to_owned();
133133
} else if let Some(rest) = line.strip_prefix("@exit_code:") {
134134
exit_code = rest.parse().unwrap_or(exit_code);
135135
} else {
@@ -170,7 +170,7 @@ fn send_event(
170170
if let Ok(f) = fs::File::open(filename) {
171171
let lines: Vec<_> = BufReader::new(f)
172172
.lines()
173-
.map(|x| x.unwrap_or_else(|_| "".to_string()))
173+
.map(|x| x.unwrap_or_else(|_| "".to_owned()))
174174
.collect();
175175
source_caches.insert(filename, lines);
176176
} else {

src/commands/files/upload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
143143
bail!("Invalid header. Needs to be in key:value format");
144144
}
145145
let (key, value) = header.split_once(':').unwrap();
146-
headers.insert(key.trim().to_string(), value.trim().to_string());
146+
headers.insert(key.trim().to_owned(), value.trim().to_owned());
147147
}
148148
};
149149

src/commands/info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn get_config_status_json() -> Result<()> {
7070
let (org, project) = config.get_org_and_project_defaults();
7171
rv.config.org = org;
7272
rv.config.project = project;
73-
rv.config.url = Some(config.get_base_url()?.to_string());
73+
rv.config.url = Some(config.get_base_url()?.to_owned());
7474

7575
rv.auth.auth_type = config.get_auth().map(|val| match val {
7676
Auth::Token(_) => "token".into(),

src/commands/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn get_org_from_token(token: &AuthToken) -> Option<&str> {
153153
fn format_org_info(org: Option<&str>) -> String {
154154
match org {
155155
Some(org_name) => format!("for organization {org_name}"),
156-
None => "not tied to any specific organization".to_string(),
156+
None => "not tied to any specific organization".to_owned(),
157157
}
158158
}
159159

src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const UPDATE_NAGGER_CMDS: &[&str] = &[
106106
const AUTH_TOKEN_ARG: &str = "auth-token";
107107

108108
fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
109-
generate(gen, cmd, cmd.get_name().to_string(), &mut io::stdout());
109+
generate(gen, cmd, cmd.get_name().to_owned(), &mut io::stdout());
110110
}
111111

112112
fn preexecute_hooks() -> Result<bool> {

src/commands/monitors/run.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ fn execute_checkin(
140140

141141
let open_checkin = MonitorCheckIn {
142142
check_in_id,
143-
monitor_slug: monitor_slug.to_string(),
143+
monitor_slug: monitor_slug.to_owned(),
144144
status: MonitorCheckInStatus::InProgress,
145145
duration: None,
146-
environment: Some(environment.to_string()),
146+
environment: Some(environment.to_owned()),
147147
monitor_config,
148148
};
149149

@@ -166,10 +166,10 @@ fn execute_checkin(
166166

167167
let close_checkin = MonitorCheckIn {
168168
check_in_id,
169-
monitor_slug: monitor_slug.to_string(),
169+
monitor_slug: monitor_slug.to_owned(),
170170
status,
171171
duration,
172-
environment: Some(environment.to_string()),
172+
environment: Some(environment.to_owned()),
173173
monitor_config: None,
174174
};
175175

src/commands/react_native/xcode.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn find_hermesc() -> String {
145145
}
146146
}
147147

148-
let pods_root_path = env::var("PODS_ROOT").unwrap_or("".to_string());
148+
let pods_root_path = env::var("PODS_ROOT").unwrap_or("".to_owned());
149149
format!("{pods_root_path}/hermes-engine/destroot/bin/hermesc")
150150
}
151151

@@ -219,10 +219,10 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
219219
let url = url.trim_end_matches('/');
220220
bundle_file = TempFile::create()?;
221221
bundle_path = bundle_file.path().to_path_buf();
222-
bundle_url = "~/index.ios.bundle".to_string();
222+
bundle_url = "~/index.ios.bundle".to_owned();
223223
sourcemap_file = TempFile::create()?;
224224
sourcemap_path = sourcemap_file.path().to_path_buf();
225-
sourcemap_url = "~/index.ios.map".to_string();
225+
sourcemap_url = "~/index.ios.map".to_owned();
226226

227227
// wait up to 10 seconds for the server to be up.
228228
if !api.wait_until_available(url, Duration::seconds(10))? {
@@ -359,7 +359,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
359359
match InfoPlist::discover_from_env() {
360360
Ok(Some(plist)) => {
361361
// Successfully discovered and parsed Info.plist
362-
let dist_string = plist.build().to_string();
362+
let dist_string = plist.build().to_owned();
363363
let release_string =
364364
format!("{}@{}+{}", plist.bundle_id(), plist.version(), dist_string);
365365
info!("Parse result from Info.plist: {:?}", &plist);
@@ -418,7 +418,7 @@ pub fn wrap_call() -> Result<()> {
418418
let mut sourcemap_path = None;
419419
let bundle_command = env::var("SENTRY_RN_BUNDLE_COMMAND");
420420
let compose_source_maps_path = env::var("COMPOSE_SOURCEMAP_PATH");
421-
let no_debug_id = env::var("SENTRY_RN_NO_DEBUG_ID").unwrap_or("0".to_string()) == "1";
421+
let no_debug_id = env::var("SENTRY_RN_NO_DEBUG_ID").unwrap_or("0".to_owned()) == "1";
422422

423423
let report_file_path = env::var("SENTRY_RN_SOURCEMAP_REPORT").unwrap();
424424
let mut sourcemap_report: SourceMapReport = if std::path::Path::new(&report_file_path).exists()
@@ -442,11 +442,11 @@ pub fn wrap_call() -> Result<()> {
442442
if item == "--sourcemap-output" {
443443
sourcemap_path = iter.next().cloned();
444444
} else if let Some(rest) = item.strip_prefix("--sourcemap-output=") {
445-
sourcemap_path = Some(rest.to_string());
445+
sourcemap_path = Some(rest.to_owned());
446446
} else if item == "--bundle-output" {
447447
bundle_path = iter.next().cloned();
448448
} else if let Some(rest) = item.strip_prefix("--bundle-output=") {
449-
bundle_path = Some(rest.to_string());
449+
bundle_path = Some(rest.to_owned());
450450
}
451451
}
452452

@@ -551,8 +551,8 @@ pub fn wrap_call() -> Result<()> {
551551
.get("debugId")
552552
.or_else(|| packager_sourcemap.get("debug_id"))
553553
{
554-
hermes_sourcemap.insert("debugId".to_string(), debug_id.clone());
555-
hermes_sourcemap.insert("debug_id".to_string(), debug_id.clone());
554+
hermes_sourcemap.insert("debugId".to_owned(), debug_id.clone());
555+
hermes_sourcemap.insert("debug_id".to_owned(), debug_id.clone());
556556

557557
hermes_sourcemap_file = fs::File::create(hermes_sourcemap_path)?;
558558
serde_json::to_writer(&mut hermes_sourcemap_file, &hermes_sourcemap)?;

0 commit comments

Comments
 (0)