Skip to content

Commit 558c6de

Browse files
ref: Enable string-to-string lint (#2626)
Using `clone` makes it clearer that we are cloning a `String` versus calling `to_string` on a `String.
1 parent 10d936f commit 558c6de

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ unstable-mobile-app = ["apple-catalog-parsing"]
101101
[workspace.lints.clippy]
102102
allow-attributes = "warn"
103103
str-to-string = "warn"
104+
string-to-string = "warn"
104105
unnecessary-wraps = "warn"
105106
unwrap-used = "warn"
106107

src/commands/debug_files/bundle_jvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
9696
let local_path_jvm_ext = local_path.with_extension("jvm");
9797
let url = format!("~/{}", path_as_url(&local_path_jvm_ext));
9898
(
99-
url.to_string(),
99+
url.clone(),
100100
SourceFile {
101101
url,
102102
path: source.path.clone(),

src/commands/files/upload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
205205
let url = format!("{}/{}{}", url_prefix, path_as_url(local_path), url_suffix);
206206

207207
(
208-
url.to_string(),
208+
url.clone(),
209209
SourceFile {
210210
url,
211211
path: source.path.clone(),

src/commands/send_event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
316316

317317
if let Some(fingerprint) = matches.get_many::<String>("fingerprint") {
318318
event.fingerprint = fingerprint
319-
.map(|x| x.to_string().into())
319+
.map(|x| x.clone().into())
320320
.collect::<Vec<_>>()
321321
.into();
322322
}

src/commands/sourcemaps/explain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ fn print_mapped_frame(frame: &Frame) {
333333
fn extract_release(event: &ProcessedEvent) -> Result<String> {
334334
if let Some(release) = event.release.as_ref() {
335335
success(format!("Event has release name: {release}"));
336-
Ok(release.to_string())
336+
Ok(release.clone())
337337
} else {
338338
error("Event is missing a release name");
339339
tip("Configure 'release' option in the SDK.\n \

src/config.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ impl Config {
194194
);
195195
}
196196
Some(Auth::Key(ref val)) => {
197-
self.ini
198-
.set_to(Some("auth"), "api_key".into(), val.to_string());
197+
self.ini.set_to(Some("auth"), "api_key".into(), val.clone());
199198
}
200199
None => {}
201200
}
@@ -351,7 +350,7 @@ impl Config {
351350
format_err!("An organization ID or slug is required (provide with --org)")
352351
}),
353352
(None, Some(cli_org)) => Ok(cli_org),
354-
(Some(token_org), None) => Ok(token_org.to_string()),
353+
(Some(token_org), None) => Ok(token_org.clone()),
355354
(Some(token_org), Some(cli_org)) => {
356355
if cli_org != *token_org {
357356
log::warn!(
@@ -381,7 +380,7 @@ impl Config {
381380
// Backward compatibility with `releases files <VERSION>` commands.
382381
pub fn get_release_with_legacy_fallback(&self, matches: &ArgMatches) -> Result<String> {
383382
if let Some(version) = matches.get_one::<String>("version") {
384-
Ok(version.to_string())
383+
Ok(version.clone())
385384
} else {
386385
self.get_release(matches)
387386
}

src/utils/sourcemaps.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl SourceMapProcessor {
292292
.iter()
293293
.map(|x| x.1)
294294
.filter(|x| x.ty == SourceFileType::SourceMap)
295-
.map(|x| x.url.to_string())
295+
.map(|x| x.url.clone())
296296
.collect();
297297

298298
for source in self.sources.values_mut() {
@@ -325,15 +325,14 @@ impl SourceMapProcessor {
325325
source.warn(format!(
326326
"could not determine a source map reference ({err})"
327327
));
328-
self.sourcemap_references
329-
.insert(source.url.to_string(), None);
328+
self.sourcemap_references.insert(source.url.clone(), None);
330329
continue;
331330
}
332331
},
333332
};
334333

335334
self.sourcemap_references
336-
.insert(source.url.to_string(), Some(sourcemap_reference));
335+
.insert(source.url.clone(), Some(sourcemap_reference));
337336
}
338337
}
339338

@@ -610,7 +609,7 @@ impl SourceMapProcessor {
610609
}
611610

612611
if let Some(Some(sourcemap)) = self.sourcemap_references.get(&source.url) {
613-
source.set_sourcemap_reference(sourcemap.url.to_string());
612+
source.set_sourcemap_reference(sourcemap.url.clone());
614613
}
615614
}
616615
}
@@ -925,7 +924,7 @@ impl SourceMapProcessor {
925924

926925
let sourcemap_url = match &matches[..] {
927926
[] => normalized,
928-
[x] => x.to_string(),
927+
[x] => x.clone(),
929928
_ => {
930929
warn!("Ambiguous matches for sourcemap path {normalized}:");
931930
for path in matches {

src/utils/vcs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub fn find_heads(
424424
} else {
425425
for repo in repos {
426426
let spec = CommitSpec {
427-
repo: repo.name.to_string(),
427+
repo: repo.name.clone(),
428428
path: None,
429429
rev: "HEAD".into(),
430430
prev_rev: None,
@@ -433,7 +433,7 @@ pub fn find_heads(
433433
find_matching_rev(spec.reference(), &spec, repos, false, remote_name.clone())?
434434
{
435435
rv.push(Ref {
436-
repo: repo.name.to_string(),
436+
repo: repo.name.clone(),
437437
rev,
438438
prev_rev: None,
439439
});

0 commit comments

Comments
 (0)