Skip to content

Commit dd4033c

Browse files
committed
Fix clippy warnings
1 parent e39958d commit dd4033c

File tree

13 files changed

+62
-62
lines changed

13 files changed

+62
-62
lines changed

rust-code-analysis-cli/src/formats.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ impl Format {
4141
} else {
4242
serde_json::to_string(&space).unwrap()
4343
};
44-
writeln!(stdout, "{}", json_data)
44+
writeln!(stdout, "{json_data}")
4545
}
4646
Format::Toml => {
4747
let toml_data = if pretty {
4848
toml::to_string_pretty(&space).unwrap()
4949
} else {
5050
toml::to_string(&space).unwrap()
5151
};
52-
writeln!(stdout, "{}", toml_data)
52+
writeln!(stdout, "{toml_data}")
5353
}
5454
Format::Yaml => writeln!(stdout, "{}", serde_yaml::to_string(&space).unwrap()),
5555
}
@@ -126,7 +126,7 @@ impl FromStr for Format {
126126
"json" => Ok(Format::Json),
127127
"toml" => Ok(Format::Toml),
128128
"yaml" => Ok(Format::Yaml),
129-
format => Err(format!("{:?} is not a supported format", format)),
129+
format => Err(format!("{format:?} is not a supported format")),
130130
}
131131
}
132132
}

rust-code-analysis-cli/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,14 @@ fn main() {
332332
{
333333
Ok(all_files) => all_files,
334334
Err(e) => {
335-
eprintln!("{:?}", e);
335+
eprintln!("{e:?}");
336336
process::exit(1);
337337
}
338338
};
339339

340340
if let Some(count) = count_lock {
341341
let count = Arc::try_unwrap(count).unwrap().into_inner().unwrap();
342-
println!("{}", count);
342+
println!("{count}");
343343
}
344344

345345
if let Some(preproc) = preproc_lock {
@@ -350,7 +350,7 @@ fn main() {
350350
if let Some(output_path) = opts.output {
351351
write_file(&output_path, data.as_bytes()).unwrap();
352352
} else {
353-
println!("{}", data);
353+
println!("{data}");
354354
}
355355
}
356356
}

rust-code-analysis-web/src/web/server.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async fn comment_removal_plain(
107107
} else {
108108
Ok(HttpResponse::NotFound()
109109
.append_header((http::header::CONTENT_TYPE, "text/plain"))
110-
.body(format!("error: {}", INVALID_LANGUAGE)))
110+
.body(format!("error: {INVALID_LANGUAGE}")))
111111
}
112112
}
113113

@@ -165,7 +165,7 @@ async fn metrics_plain(
165165
} else {
166166
Ok(HttpResponse::NotFound()
167167
.append_header((http::header::CONTENT_TYPE, "text/plain"))
168-
.body(format!("error: {}", INVALID_LANGUAGE)))
168+
.body(format!("error: {INVALID_LANGUAGE}")))
169169
}
170170
}
171171

@@ -210,7 +210,7 @@ async fn function_plain(
210210
} else {
211211
Ok(HttpResponse::NotFound()
212212
.append_header((http::header::CONTENT_TYPE, "text/plain"))
213-
.body(format!("error: {}", INVALID_LANGUAGE)))
213+
.body(format!("error: {INVALID_LANGUAGE}")))
214214
}
215215
}
216216

@@ -542,7 +542,7 @@ mod tests {
542542
assert_eq!(resp.status(), StatusCode::NOT_FOUND);
543543

544544
let res = test::read_body(resp).await;
545-
let expected = Bytes::from(format!("error: {}", INVALID_LANGUAGE));
545+
let expected = Bytes::from(format!("error: {INVALID_LANGUAGE}"));
546546

547547
assert_eq!(res, expected);
548548
}

src/c_langs_macros/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod tests {
1818
let parser = CppParser::new(v_sample.clone(), &path, None);
1919
let root = parser.get_root();
2020
if debug || root.has_error() {
21-
eprintln!("Sample (CPP) {}: {}", n, sample);
21+
eprintln!("Sample (CPP) {n}: {sample}");
2222
dump_node(&v_sample, &root, -1, None, None).unwrap();
2323
}
2424
assert!(!root.has_error());

src/comment_rm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Callback for CommentRm {
8383
if cfg.in_place {
8484
write_file(&cfg.path, &new_source)?;
8585
} else if let Ok(new_source) = std::str::from_utf8(&new_source) {
86-
println!("{}", new_source);
86+
println!("{new_source}");
8787
} else {
8888
io::stdout().write_all(&new_source)?;
8989
}

src/concurrent_files.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ where
3939
let path = job.path.clone();
4040

4141
if let Err(err) = func(job.path, &job.cfg) {
42-
eprintln!("{:?} for file {:?}", err, path);
42+
eprintln!("{err:?} for file {path:?}");
4343
}
4444
}
4545
}
@@ -86,7 +86,7 @@ where
8686

8787
for path in paths.drain(..) {
8888
if !path.exists() {
89-
eprintln!("Warning: File doesn't exist: {:?}", path);
89+
eprintln!("Warning: File doesn't exist: {path:?}");
9090
continue;
9191
}
9292
if path.is_dir() {
@@ -238,7 +238,7 @@ impl<Config: 'static + Send + Sync> ConcurrentRunner<Config> {
238238
let proc_files = proc_files.clone();
239239

240240
let t = match thread::Builder::new()
241-
.name(format!("Consumer {}", i))
241+
.name(format!("Consumer {i}"))
242242
.spawn(move || {
243243
consumer(receiver, proc_files);
244244
}) {

src/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn dump_span(
6969
let pref = if last { " `- " } else { " |- " };
7070

7171
color!(stdout, Blue);
72-
write!(stdout, "{}", pref)?;
72+
write!(stdout, "{pref}")?;
7373

7474
if span.error {
7575
color!(stdout, Red, true);

src/output/dump.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn dump_tree_helper(
9292

9393
if display {
9494
color!(stdout, Blue);
95-
write!(stdout, "{}{}", prefix, pref)?;
95+
write!(stdout, "{prefix}{pref}")?;
9696

9797
color!(stdout, Yellow, true);
9898
write!(
@@ -123,7 +123,7 @@ fn dump_tree_helper(
123123
color!(stdout, Red, true);
124124
let code = &code[node.object().start_byte()..node.object().end_byte()];
125125
if let Ok(code) = String::from_utf8(code.to_vec()) {
126-
write!(stdout, "{} ", code)?;
126+
write!(stdout, "{code} ")?;
127127
} else {
128128
stdout.write_all(code).unwrap();
129129
}
@@ -134,7 +134,7 @@ fn dump_tree_helper(
134134

135135
let count = node.object().child_count();
136136
if count != 0 {
137-
let prefix = format!("{}{}", prefix, pref_child);
137+
let prefix = format!("{prefix}{pref_child}");
138138
let mut i = count;
139139
let mut cursor = node.object().walk();
140140
cursor.goto_first_child();

src/output/dump_metrics.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn dump_space(
6262
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
6363

6464
color!(stdout, Blue);
65-
write!(stdout, "{}{}", prefix, pref)?;
65+
write!(stdout, "{prefix}{pref}")?;
6666

6767
color!(stdout, Yellow, true);
6868
write!(stdout, "{}: ", space.kind)?;
@@ -73,7 +73,7 @@ fn dump_space(
7373
color!(stdout, Red, true);
7474
writeln!(stdout, " (@{})", space.start_line)?;
7575

76-
let prefix = format!("{}{}", prefix, pref_child);
76+
let prefix = format!("{prefix}{pref_child}");
7777
dump_metrics(&space.metrics, &prefix, space.spaces.is_empty(), stdout)?;
7878

7979
if let Some((last, spaces)) = space.spaces.split_last() {
@@ -95,12 +95,12 @@ fn dump_metrics(
9595
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
9696

9797
color!(stdout, Blue);
98-
write!(stdout, "{}{}", prefix, pref)?;
98+
write!(stdout, "{prefix}{pref}")?;
9999

100100
color!(stdout, Yellow, true);
101101
writeln!(stdout, "metrics")?;
102102

103-
let prefix = format!("{}{}", prefix, pref_child);
103+
let prefix = format!("{prefix}{pref_child}");
104104
dump_cognitive(&metrics.cognitive, &prefix, false, stdout)?;
105105
dump_cyclomatic(&metrics.cyclomatic, &prefix, false, stdout)?;
106106
dump_nargs(&metrics.nargs, &prefix, false, stdout)?;
@@ -124,12 +124,12 @@ fn dump_cognitive(
124124
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
125125

126126
color!(stdout, Blue);
127-
write!(stdout, "{}{}", prefix, pref)?;
127+
write!(stdout, "{prefix}{pref}")?;
128128

129129
color!(stdout, Green, true);
130130
writeln!(stdout, "cognitive")?;
131131

132-
let prefix = format!("{}{}", prefix, pref_child);
132+
let prefix = format!("{prefix}{pref_child}");
133133

134134
dump_value("sum", stats.cognitive(), &prefix, false, stdout)?;
135135
dump_value("average", stats.cognitive_average(), &prefix, true, stdout)
@@ -144,12 +144,12 @@ fn dump_cyclomatic(
144144
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
145145

146146
color!(stdout, Blue);
147-
write!(stdout, "{}{}", prefix, pref)?;
147+
write!(stdout, "{prefix}{pref}")?;
148148

149149
color!(stdout, Green, true);
150150
writeln!(stdout, "cyclomatic")?;
151151

152-
let prefix = format!("{}{}", prefix, pref_child);
152+
let prefix = format!("{prefix}{pref_child}");
153153

154154
dump_value("sum", stats.cyclomatic(), &prefix, false, stdout)?;
155155
dump_value("average", stats.cyclomatic_average(), &prefix, true, stdout)
@@ -164,12 +164,12 @@ fn dump_halstead(
164164
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
165165

166166
color!(stdout, Blue);
167-
write!(stdout, "{}{}", prefix, pref)?;
167+
write!(stdout, "{prefix}{pref}")?;
168168

169169
color!(stdout, Green, true);
170170
writeln!(stdout, "halstead")?;
171171

172-
let prefix = format!("{}{}", prefix, pref_child);
172+
let prefix = format!("{prefix}{pref_child}");
173173

174174
dump_value("n1", stats.u_operators(), &prefix, false, stdout)?;
175175
dump_value("N1", stats.operators(), &prefix, false, stdout)?;
@@ -203,12 +203,12 @@ fn dump_loc(
203203
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
204204

205205
color!(stdout, Blue);
206-
write!(stdout, "{}{}", prefix, pref)?;
206+
write!(stdout, "{prefix}{pref}")?;
207207

208208
color!(stdout, Green, true);
209209
writeln!(stdout, "loc")?;
210210

211-
let prefix = format!("{}{}", prefix, pref_child);
211+
let prefix = format!("{prefix}{pref_child}");
212212
dump_value("sloc", stats.sloc(), &prefix, false, stdout)?;
213213
dump_value("ploc", stats.ploc(), &prefix, false, stdout)?;
214214
dump_value("lloc", stats.lloc(), &prefix, false, stdout)?;
@@ -225,12 +225,12 @@ fn dump_nom(
225225
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
226226

227227
color!(stdout, Blue);
228-
write!(stdout, "{}{}", prefix, pref)?;
228+
write!(stdout, "{prefix}{pref}")?;
229229

230230
color!(stdout, Green, true);
231231
writeln!(stdout, "nom")?;
232232

233-
let prefix = format!("{}{}", prefix, pref_child);
233+
let prefix = format!("{prefix}{pref_child}");
234234
dump_value("functions", stats.functions(), &prefix, false, stdout)?;
235235
dump_value("closures", stats.closures(), &prefix, false, stdout)?;
236236
dump_value("total", stats.total(), &prefix, true, stdout)
@@ -245,12 +245,12 @@ fn dump_mi(
245245
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
246246

247247
color!(stdout, Blue);
248-
write!(stdout, "{}{}", prefix, pref)?;
248+
write!(stdout, "{prefix}{pref}")?;
249249

250250
color!(stdout, Green, true);
251251
writeln!(stdout, "mi")?;
252252

253-
let prefix = format!("{}{}", prefix, pref_child);
253+
let prefix = format!("{prefix}{pref_child}");
254254
dump_value("mi_original", stats.mi_original(), &prefix, false, stdout)?;
255255
dump_value("mi_sei", stats.mi_sei(), &prefix, false, stdout)?;
256256
dump_value(
@@ -271,12 +271,12 @@ fn dump_nargs(
271271
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
272272

273273
color!(stdout, Blue);
274-
write!(stdout, "{}{}", prefix, pref)?;
274+
write!(stdout, "{prefix}{pref}")?;
275275

276276
color!(stdout, Green, true);
277277
writeln!(stdout, "nargs")?;
278278

279-
let prefix = format!("{}{}", prefix, pref_child);
279+
let prefix = format!("{prefix}{pref_child}");
280280
dump_value("functions", stats.fn_args(), &prefix, false, stdout)?;
281281
dump_value("closures", stats.closure_args(), &prefix, false, stdout)?;
282282
dump_value("total", stats.nargs_total(), &prefix, false, stdout)?;
@@ -292,7 +292,7 @@ fn dump_nexits(
292292
let pref = if last { "`- " } else { "|- " };
293293

294294
color!(stdout, Blue);
295-
write!(stdout, "{}{}", prefix, pref)?;
295+
write!(stdout, "{prefix}{pref}")?;
296296

297297
color!(stdout, Green, true);
298298
write!(stdout, "nexits: ")?;
@@ -310,12 +310,12 @@ fn dump_abc(
310310
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
311311

312312
color!(stdout, Blue);
313-
write!(stdout, "{}{}", prefix, pref)?;
313+
write!(stdout, "{prefix}{pref}")?;
314314

315315
color!(stdout, Green, true);
316316
writeln!(stdout, "abc")?;
317317

318-
let prefix = format!("{}{}", prefix, pref_child);
318+
let prefix = format!("{prefix}{pref_child}");
319319

320320
dump_value(
321321
"assignments",
@@ -342,12 +342,12 @@ fn dump_wmc(
342342
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
343343

344344
color!(stdout, Blue);
345-
write!(stdout, "{}{}", prefix, pref)?;
345+
write!(stdout, "{prefix}{pref}")?;
346346

347347
color!(stdout, Green, true);
348348
writeln!(stdout, "wmc")?;
349349

350-
let prefix = format!("{}{}", prefix, pref_child);
350+
let prefix = format!("{prefix}{pref_child}");
351351
dump_value("classes", stats.class_wmc_sum(), &prefix, false, stdout)?;
352352
dump_value(
353353
"interfaces",
@@ -372,12 +372,12 @@ fn dump_npm(
372372
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
373373

374374
color!(stdout, Blue);
375-
write!(stdout, "{}{}", prefix, pref)?;
375+
write!(stdout, "{prefix}{pref}")?;
376376

377377
color!(stdout, Green, true);
378378
writeln!(stdout, "npm")?;
379379

380-
let prefix = format!("{}{}", prefix, pref_child);
380+
let prefix = format!("{prefix}{pref_child}");
381381
dump_value("classes", stats.class_npm_sum(), &prefix, false, stdout)?;
382382
dump_value(
383383
"interfaces",
@@ -403,12 +403,12 @@ fn dump_npa(
403403
let (pref_child, pref) = if last { (" ", "`- ") } else { ("| ", "|- ") };
404404

405405
color!(stdout, Blue);
406-
write!(stdout, "{}{}", prefix, pref)?;
406+
write!(stdout, "{prefix}{pref}")?;
407407

408408
color!(stdout, Green, true);
409409
writeln!(stdout, "npa")?;
410410

411-
let prefix = format!("{}{}", prefix, pref_child);
411+
let prefix = format!("{prefix}{pref_child}");
412412
dump_value("classes", stats.class_npa_sum(), &prefix, false, stdout)?;
413413
dump_value(
414414
"interfaces",
@@ -431,11 +431,11 @@ fn dump_value(
431431
let pref = if last { "`- " } else { "|- " };
432432

433433
color!(stdout, Blue);
434-
write!(stdout, "{}{}", prefix, pref)?;
434+
write!(stdout, "{prefix}{pref}")?;
435435

436436
color!(stdout, Magenta, true);
437-
write!(stdout, "{}: ", name)?;
437+
write!(stdout, "{name}: ")?;
438438

439439
color!(stdout, White);
440-
writeln!(stdout, "{}", val)
440+
writeln!(stdout, "{val}")
441441
}

0 commit comments

Comments
 (0)