diff --git a/CHANGELOG.md b/CHANGELOG.md index f2774cb21fe5..f2fbdbe99f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b ### CLI +#### Bug fixes + +- Fix the printed error count ([#2048](https://github.com/biomejs/biome/issues/2048)). Contributed by @Sec-ant + ### Configuration #### Bug fixes diff --git a/crates/biome_cli/src/execute/process_file.rs b/crates/biome_cli/src/execute/process_file.rs index 0b050defe528..2f86270836e1 100644 --- a/crates/biome_cli/src/execute/process_file.rs +++ b/crates/biome_cli/src/execute/process_file.rs @@ -63,11 +63,8 @@ pub(crate) enum Message { } impl Message { - pub(crate) const fn is_error(&self) -> bool { - matches!( - self, - Message::Diff { .. } | Message::Diagnostics { .. } | Message::Failure - ) + pub(crate) const fn is_failure(&self) -> bool { + matches!(self, Message::Failure) } } diff --git a/crates/biome_cli/src/execute/process_file/check.rs b/crates/biome_cli/src/execute/process_file/check.rs index 02567da8bff7..7978d987ccfb 100644 --- a/crates/biome_cli/src/execute/process_file/check.rs +++ b/crates/biome_cli/src/execute/process_file/check.rs @@ -11,7 +11,7 @@ pub(crate) fn check_file<'ctx>( path: &Path, file_features: &'ctx FileFeaturesResult, ) -> FileResult { - let mut has_errors = false; + let mut has_failures = false; let mut workspace_file = WorkspaceFile::new(ctx, path)?; let mut changed = false; tracing::info_span!("Process check", path =? workspace_file.path.display()).in_scope( @@ -24,15 +24,15 @@ pub(crate) fn check_file<'ctx>( changed = true } if let FileStatus::Message(msg) = status { - if msg.is_error() { - has_errors = true + if msg.is_failure() { + has_failures = true; } ctx.push_message(msg); } } Err(err) => { ctx.push_message(err); - has_errors = true; + has_failures = true; } } } @@ -44,15 +44,15 @@ pub(crate) fn check_file<'ctx>( changed = true } if let FileStatus::Message(msg) = status { - if msg.is_error() { - has_errors = true + if msg.is_failure() { + has_failures = true; } ctx.push_message(msg); } } Err(err) => { ctx.push_message(err); - has_errors = true; + has_failures = true; } } } @@ -65,20 +65,20 @@ pub(crate) fn check_file<'ctx>( changed = true } if let FileStatus::Message(msg) = status { - if msg.is_error() { - has_errors = true + if msg.is_failure() { + has_failures = true; } ctx.push_message(msg); } } Err(err) => { ctx.push_message(err); - has_errors = true; + has_failures = true; } } } - if has_errors { + if has_failures { Ok(FileStatus::Message(Message::Failure)) } else if changed { Ok(FileStatus::Changed) diff --git a/crates/biome_cli/src/execute/process_file/lint.rs b/crates/biome_cli/src/execute/process_file/lint.rs index a9aeed54b69f..7e6cd42b669e 100644 --- a/crates/biome_cli/src/execute/process_file/lint.rs +++ b/crates/biome_cli/src/execute/process_file/lint.rs @@ -19,7 +19,6 @@ pub(crate) fn lint_with_guard<'ctx>( ) -> FileResult { tracing::info_span!("Processes linting", path =? workspace_file.path.display()).in_scope( move || { - let mut errors = 0; let mut input = workspace_file.input()?; let mut changed = false; if let Some(fix_mode) = ctx.execution.as_fix_file_mode() { @@ -54,7 +53,6 @@ pub(crate) fn lint_with_guard<'ctx>( workspace_file.update_file(output)?; input = workspace_file.input()?; } - errors = fix_result.errors; } let max_diagnostics = ctx.remaining_diagnostics.load(Ordering::Relaxed); @@ -71,7 +69,6 @@ pub(crate) fn lint_with_guard<'ctx>( let no_diagnostics = pull_diagnostics_result.diagnostics.is_empty() && pull_diagnostics_result.skipped_diagnostics == 0; - errors += pull_diagnostics_result.errors; if !no_diagnostics { let input = match workspace_file.as_extension() { @@ -93,9 +90,7 @@ pub(crate) fn lint_with_guard<'ctx>( }); } - if errors > 0 { - Ok(FileStatus::Message(Message::Failure)) - } else if changed { + if changed { Ok(FileStatus::Changed) } else { Ok(FileStatus::Unchanged) diff --git a/crates/biome_cli/tests/snapshots/main_cases_config_extends/extends_config_ok_formatter_no_linter.snap b/crates/biome_cli/tests/snapshots/main_cases_config_extends/extends_config_ok_formatter_no_linter.snap index 91030867f644..2807dced706d 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_config_extends/extends_config_ok_formatter_no_linter.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_config_extends/extends_config_ok_formatter_no_linter.snap @@ -54,7 +54,5 @@ test.js format ━━━━━━━━━━━━━━━━━━━━━ ```block Checked 1 file in