diff --git a/.changeset/breezy-parrots-fold.md b/.changeset/breezy-parrots-fold.md new file mode 100644 index 000000000000..505ad176e059 --- /dev/null +++ b/.changeset/breezy-parrots-fold.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": patch +--- + +Fixed an issue where the JSON reporter didn't contain the duration of the command. diff --git a/crates/biome_cli/src/reporter/json.rs b/crates/biome_cli/src/reporter/json.rs index dac8fe9f2c60..220714907aa9 100644 --- a/crates/biome_cli/src/reporter/json.rs +++ b/crates/biome_cli/src/reporter/json.rs @@ -10,10 +10,8 @@ use biome_diagnostics::{ use biome_json_factory::make::*; use biome_json_syntax::{AnyJsonMemberName, AnyJsonValue, JsonRoot, JsonSyntaxKind, T}; use camino::{Utf8Path, Utf8PathBuf}; -use serde::Serialize; -#[derive(Debug, Default, Serialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug, Default)] pub(crate) struct JsonReporterVisitor { summary: TraversalSummary, diagnostics: Vec, @@ -212,13 +210,6 @@ fn report_to_json(report: &JsonReport) -> AnyJsonValue { )) } -impl Display for JsonReporterVisitor { - fn fmt(&self, fmt: &mut Formatter) -> std::io::Result<()> { - let content = serde_json::to_string(&self)?; - fmt.write_str(content.as_str()) - } -} - pub struct JsonReporter<'a> { pub execution: &'a dyn Execution, pub diagnostics_payload: &'a DiagnosticsPayload, @@ -344,34 +335,29 @@ fn to_location(location: &Location) -> Option { }) } -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug)] struct JsonReport { category: Option<&'static Category>, severity: Severity, message: String, advices: Vec, - #[serde(skip_serializing_if = "Option::is_none")] location: Option, } -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug)] struct LocationReport { path: String, start: LocationSpan, end: LocationSpan, } -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug)] struct LocationSpan { column: usize, line: usize, } -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] +#[derive(Debug)] struct JsonSuggestion { start: LocationSpan, end: LocationSpan, diff --git a/crates/biome_cli/src/reporter/mod.rs b/crates/biome_cli/src/reporter/mod.rs index 0e019eeb8437..8fb61aa0c653 100644 --- a/crates/biome_cli/src/reporter/mod.rs +++ b/crates/biome_cli/src/reporter/mod.rs @@ -16,7 +16,7 @@ use biome_diagnostics::{Diagnostic, Error, Severity}; use biome_fs::BiomePath; use biome_json_factory::make::{ json_member, json_member_list, json_member_name, json_number_literal, json_number_value, - json_object_value, json_string_literal, token, + json_object_value, json_string_literal, json_string_value, token, }; use biome_json_syntax::{AnyJsonMemberName, AnyJsonValue, JsonMember, T}; use camino::Utf8Path; @@ -55,7 +55,15 @@ pub struct TraversalSummary { impl TraversalSummary { pub(crate) fn json_member(&self) -> JsonMember { - let members = vec![ + #[cfg(debug_assertions)] + let duration_value = + AnyJsonValue::JsonStringValue(json_string_value(json_string_literal("