mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
refactor(cli): remove unnecessary format! calls (#8315)
This commit is contained in:
parent
8b7f5531ee
commit
aaf7166a9d
11 changed files with 42 additions and 42 deletions
|
@ -299,5 +299,5 @@ fn node_tcp() -> Result<HttpBenchmarkResult> {
|
|||
fn hyper_http(exe: &str) -> Result<HttpBenchmarkResult> {
|
||||
let port = get_port();
|
||||
println!("http_benchmark testing RUST hyper");
|
||||
run(&[exe, &format!("{}", port)], port, None, None)
|
||||
run(&[exe, &port.to_string()], port, None, None)
|
||||
}
|
||||
|
|
|
@ -546,7 +546,7 @@ mod tests {
|
|||
}
|
||||
]);
|
||||
let diagnostics: Diagnostics = serde_json::from_value(value).unwrap();
|
||||
let actual = format!("{}", diagnostics);
|
||||
let actual = diagnostics.to_string();
|
||||
assert_eq!(
|
||||
strip_ansi_codes(&actual),
|
||||
"TS5023 [ERROR]: Unknown compiler option \'invalid\'."
|
||||
|
@ -573,7 +573,7 @@ mod tests {
|
|||
}
|
||||
]);
|
||||
let diagnostics: Diagnostics = serde_json::from_value(value).unwrap();
|
||||
let actual = format!("{}", diagnostics);
|
||||
let actual = diagnostics.to_string();
|
||||
assert_eq!(strip_ansi_codes(&actual), "TS2584 [ERROR]: Cannot find name \'console\'. Do you need to change your target library? Try changing the `lib` compiler option to include \'dom\'.\nconsole.log(\"a\");\n~~~~~~~\n at test.ts:1:1");
|
||||
}
|
||||
|
||||
|
@ -614,7 +614,7 @@ mod tests {
|
|||
}
|
||||
]);
|
||||
let diagnostics: Diagnostics = serde_json::from_value(value).unwrap();
|
||||
let actual = format!("{}", diagnostics);
|
||||
let actual = diagnostics.to_string();
|
||||
assert_eq!(strip_ansi_codes(&actual), "TS2552 [ERROR]: Cannot find name \'foo_Bar\'. Did you mean \'foo_bar\'?\nfoo_Bar();\n~~~~~~~\n at test.ts:8:1\n\n \'foo_bar\' is declared here.\n function foo_bar() {\n ~~~~~~~\n at test.ts:4:10");
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,7 @@ mod tests {
|
|||
}
|
||||
];
|
||||
let diagnostics: Diagnostic = serde_json::from_value(value).unwrap();
|
||||
let actual = format!("{}", diagnostics);
|
||||
let actual = diagnostics.to_string();
|
||||
assert_eq!(strip_ansi_codes(&actual), "TS2551 [ERROR]: Property \'ppid\' does not exist on type \'typeof Deno\'. \'Deno.ppid\' is an unstable API. Did you forget to run with the \'--unstable\' flag, or did you mean \'pid\'?\nconsole.log(Deno.ppid);\n ~~~~\n at file:///cli/tests/unstable_ts2551.ts:1:18\n\n \'pid\' is declared here.\n export const pid: number;\n ~~~\n at asset:///lib.deno.ns.d.ts:90:16");
|
||||
}
|
||||
}
|
||||
|
|
12
cli/diff.rs
12
cli/diff.rs
|
@ -6,27 +6,27 @@ use std::fmt;
|
|||
use std::fmt::Write;
|
||||
|
||||
fn fmt_add() -> String {
|
||||
format!("{}", colors::green_bold("+"))
|
||||
colors::green_bold("+").to_string()
|
||||
}
|
||||
|
||||
fn fmt_add_text(x: &str) -> String {
|
||||
format!("{}", colors::green(x))
|
||||
colors::green(x).to_string()
|
||||
}
|
||||
|
||||
fn fmt_add_text_highlight(x: &str) -> String {
|
||||
format!("{}", colors::black_on_green(x))
|
||||
colors::black_on_green(x).to_string()
|
||||
}
|
||||
|
||||
fn fmt_rem() -> String {
|
||||
format!("{}", colors::red_bold("-"))
|
||||
colors::red_bold("-").to_string()
|
||||
}
|
||||
|
||||
fn fmt_rem_text(x: &str) -> String {
|
||||
format!("{}", colors::red(x))
|
||||
colors::red(x).to_string()
|
||||
}
|
||||
|
||||
fn fmt_rem_text_highlight(x: &str) -> String {
|
||||
format!("{}", colors::white_on_red(x))
|
||||
colors::white_on_red(x).to_string()
|
||||
}
|
||||
|
||||
fn write_line_diff(
|
||||
|
|
|
@ -272,7 +272,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_module_graph_info_display() {
|
||||
let fixture = get_fixture();
|
||||
let actual = format!("{}", fixture);
|
||||
let actual = fixture.to_string();
|
||||
assert!(actual.contains(" /a/b/c.ts"));
|
||||
assert!(actual.contains(" 99 unique"));
|
||||
assert!(actual.contains("(12.06KB)"));
|
||||
|
|
|
@ -934,7 +934,7 @@ impl InspectorSession {
|
|||
|
||||
let response = response_rx.await.unwrap();
|
||||
if let Some(error) = response.get("error") {
|
||||
return Err(generic_error(format!("{}", error)));
|
||||
return Err(generic_error(error.to_string()));
|
||||
}
|
||||
|
||||
let result = response.get("result").unwrap().clone();
|
||||
|
|
|
@ -276,9 +276,9 @@ pub fn format_diagnostic(
|
|||
colors::red(&"^".repeat(line_len - range.start.col))
|
||||
));
|
||||
} else if range.end.line == i {
|
||||
lines.push(format!("{}", colors::red(&"^".repeat(range.end.col))));
|
||||
lines.push(colors::red(&"^".repeat(range.end.col)).to_string());
|
||||
} else if line_len != 0 {
|
||||
lines.push(format!("{}", colors::red(&"^".repeat(line_len))));
|
||||
lines.push(colors::red(&"^".repeat(line_len)).to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ async fn info_command(
|
|||
if json {
|
||||
write_json_to_stdout(&json!(info))?;
|
||||
} else {
|
||||
write_to_stdout_ignore_sigpipe(format!("{}", info).as_bytes())?;
|
||||
write_to_stdout_ignore_sigpipe(info.to_string().as_bytes())?;
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
|
|
|
@ -194,7 +194,7 @@ pub fn serialize_media_type<S>(mt: &MediaType, s: S) -> Result<S::Ok, S::Error>
|
|||
where
|
||||
S: Serializer,
|
||||
{
|
||||
s.serialize_str(&format!("{}", mt))
|
||||
s.serialize_str(&mt.to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -269,15 +269,15 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_display() {
|
||||
assert_eq!(format!("{}", MediaType::JavaScript), "JavaScript");
|
||||
assert_eq!(format!("{}", MediaType::JSX), "JSX");
|
||||
assert_eq!(format!("{}", MediaType::TypeScript), "TypeScript");
|
||||
assert_eq!(format!("{}", MediaType::Dts), "Dts");
|
||||
assert_eq!(format!("{}", MediaType::TSX), "TSX");
|
||||
assert_eq!(format!("{}", MediaType::Json), "Json");
|
||||
assert_eq!(format!("{}", MediaType::Wasm), "Wasm");
|
||||
assert_eq!(format!("{}", MediaType::TsBuildInfo), "TsBuildInfo");
|
||||
assert_eq!(format!("{}", MediaType::SourceMap), "SourceMap");
|
||||
assert_eq!(format!("{}", MediaType::Unknown), "Unknown");
|
||||
assert_eq!(MediaType::JavaScript.to_string(), "JavaScript");
|
||||
assert_eq!(MediaType::JSX.to_string(), "JSX");
|
||||
assert_eq!(MediaType::TypeScript.to_string(), "TypeScript");
|
||||
assert_eq!(MediaType::Dts.to_string(), "Dts");
|
||||
assert_eq!(MediaType::TSX.to_string(), "TSX");
|
||||
assert_eq!(MediaType::Json.to_string(), "Json");
|
||||
assert_eq!(MediaType::Wasm.to_string(), "Wasm");
|
||||
assert_eq!(MediaType::TsBuildInfo.to_string(), "TsBuildInfo");
|
||||
assert_eq!(MediaType::SourceMap.to_string(), "SourceMap");
|
||||
assert_eq!(MediaType::Unknown.to_string(), "Unknown");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ impl Permissions {
|
|||
));
|
||||
}
|
||||
Ok(self.query_net(
|
||||
&format!("{}", parsed.host().unwrap()),
|
||||
&parsed.host().unwrap().to_string(),
|
||||
parsed.port_or_known_default(),
|
||||
))
|
||||
}
|
||||
|
|
26
cli/repl.rs
26
cli/repl.rs
|
@ -245,31 +245,31 @@ impl Highlighter for LineHighlighter {
|
|||
.regex
|
||||
.replace_all(&line.to_string(), |caps: &Captures<'_>| {
|
||||
if let Some(cap) = caps.name("comment") {
|
||||
format!("{}", colors::gray(cap.as_str()))
|
||||
colors::gray(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("string") {
|
||||
format!("{}", colors::green(cap.as_str()))
|
||||
colors::green(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("regexp") {
|
||||
format!("{}", colors::red(cap.as_str()))
|
||||
colors::red(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("number") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
colors::yellow(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("boolean") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
colors::yellow(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("null") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
colors::yellow(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("undefined") {
|
||||
format!("{}", colors::gray(cap.as_str()))
|
||||
colors::gray(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("keyword") {
|
||||
format!("{}", colors::cyan(cap.as_str()))
|
||||
colors::cyan(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("infinity") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
colors::yellow(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("classes") {
|
||||
format!("{}", colors::green_bold(cap.as_str()))
|
||||
colors::green_bold(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("hexnumber") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
colors::yellow(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("octalnumber") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
colors::yellow(cap.as_str()).to_string()
|
||||
} else if let Some(cap) = caps.name("binarynumber") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
colors::yellow(cap.as_str()).to_string()
|
||||
} else {
|
||||
caps[0].to_string()
|
||||
}
|
||||
|
|
|
@ -3814,7 +3814,7 @@ async fn inspector_does_not_hang() {
|
|||
for i in 0..128u32 {
|
||||
let request_id = i + 10;
|
||||
// Expect the number {i} on stdout.
|
||||
let s = format!("{}", i);
|
||||
let s = i.to_string();
|
||||
assert_eq!(stdout_lines.next().unwrap(), s);
|
||||
// Expect hitting the `debugger` statement.
|
||||
let s = r#"{"method":"Debugger.paused","#;
|
||||
|
|
Loading…
Reference in a new issue