Skip to content

Commit

Permalink
fix(cli): error count
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant committed Apr 3, 2024
1 parent 2c5e309 commit ae69645
Show file tree
Hide file tree
Showing 84 changed files with 103 additions and 247 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions crates/biome_cli/src/execute/process_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
22 changes: 11 additions & 11 deletions crates/biome_cli/src/execute/process_file/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
}
}
}
Expand All @@ -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;
}
}
}
Expand All @@ -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)
Expand Down
7 changes: 1 addition & 6 deletions crates/biome_cli/src/execute/process_file/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand All @@ -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() {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,5 @@ test.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ test.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
Found 1 warning.
```


Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,5 @@ test.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 2 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ src/index.js format ━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ src/file.js format ━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,5 @@ src/folder_0/package-lock.json project VERBOSE ━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ file.astro:2:1 lint/suspicious/noDebugger FIXABLE ━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ file.astro organizeImports ━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ file.svelte organizeImports ━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ file.vue:4:1 lint/style/noVar FIXABLE ━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 3 errors.
```
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ file.vue:4:1 lint/style/noVar FIXABLE ━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 5 errors.
Found 4 errors.
```
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ file.vue organizeImports ━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,5 @@ fix.js format ━━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 2 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,5 @@ fix.js format ━━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 3 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ test2.js:3:16 lint/style/noArguments ━━━━━━━━━━━━━━
```

```block
Checked 2 files in <TIME>. No fixes needed.
Found 6 errors.
Checked 2 files in <TIME>. Fixed 2 files.
Found 2 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,5 @@ test.json format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 2 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,5 @@ check.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 2 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ file.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 3 errors.
Found 2 errors.
```
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ file.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
Found 1 warning.
```


Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,5 @@ fix.js format ━━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,5 @@ file1.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 2 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,5 @@ file1.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 2 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,5 @@ file1.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,5 @@ test.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,5 @@ check.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 5 errors.
Found 3 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,5 @@ Diagnostics not shown: 50.

```block
Checked 20 files in <TIME>. No fixes needed.
Found 100 errors.
Found 60 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,5 @@ Diagnostics not shown: 100.

```block
Checked 40 files in <TIME>. No fixes needed.
Found 200 errors.
Found 120 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,5 @@ Diagnostics not shown: 77.

```block
Checked 1 file in <TIME>. No fixes needed.
Found 23 errors.
Found 21 errors.
```


Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,5 @@ fix.js format ━━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 2 errors.
Found 1 error.
```


Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,5 @@ check.js format ━━━━━━━━━━━━━━━━━━━━━

```block
Checked 1 file in <TIME>. No fixes needed.
Found 4 errors.
Found 2 errors.
```


Loading

0 comments on commit ae69645

Please sign in to comment.