Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Aug 4, 2024
1 parent a515007 commit f06611f
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 43 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
```shell
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

List of files that were evaluated
Files processed:

- biome/biome.json
- biome/packages/@biomejs/cli-win32-arm64/package.json
- biome/packages/tailwindcss-config-analyzer/package.json

VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

List of files that were fixed
Files fixed:

- biome/biome/packages/tailwindcss-config-analyzer/src/generate-tailwind-preset.ts
```
Expand Down
14 changes: 5 additions & 9 deletions crates/biome_cli/src/execute/traverse.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::process_file::{process_file, DiffKind, FileResult, FileStatus, Message};
use super::process_file::{process_file, DiffKind, FileStatus, Message};
use super::{Execution, TraversalMode};
use crate::cli_options::CliOptions;
use crate::execute::diagnostics::{
Expand All @@ -15,7 +15,6 @@ use biome_service::workspace::{DropPatternParams, IsPathIgnoredParams};
use biome_service::{extension_error, workspace::SupportsFeatureParams, Workspace, WorkspaceError};
use crossbeam::channel::{unbounded, Receiver, Sender};
use rustc_hash::FxHashSet;
use std::panic::UnwindSafe;
use std::sync::atomic::AtomicU32;
use std::sync::RwLock;
use std::{
Expand Down Expand Up @@ -180,7 +179,7 @@ fn traverse_inputs(

fs.traversal(Box::new(|scope: &dyn TraversalScope| {
for path in paths.clone() {
scope.handle(ctx, path.to_bath_buf());
scope.handle(ctx, path.to_path_buf());
}
}));

Expand Down Expand Up @@ -620,7 +619,7 @@ impl<'ctx, 'app> TraversalContext for TraversalOptions<'ctx, 'app> {
}

fn handle_path(&self, path: &Path) {
handle_file(self, path, process_file)
handle_file(self, path)
}

fn store_path(&self, path: &Path) {
Expand All @@ -631,11 +630,8 @@ impl<'ctx, 'app> TraversalContext for TraversalOptions<'ctx, 'app> {
/// This function wraps the [process_file] function implementing the traversal
/// in a [catch_unwind] block and emit diagnostics in case of error (either the
/// traversal function returns Err or panics)
fn handle_file<F>(ctx: &TraversalOptions, path: &Path, func: F)
where
F: Fn(&TraversalOptions, &Path) -> FileResult + UnwindSafe,
{
match catch_unwind(move || func(ctx, path)) {
fn handle_file(ctx: &TraversalOptions, path: &Path) {
match catch_unwind(move || process_file(ctx, path)) {
Ok(Ok(FileStatus::Changed)) => {
ctx.increment_changed(path);
}
Expand Down
1 change: 0 additions & 1 deletion crates/biome_cli/src/reporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub trait ReporterVisitor {
) -> io::Result<()>;

/// Writes the paths that were handled during a run.
/// The fist list represents the paths that were evaluated, the second list represents the paths that were fixed
fn report_handled_paths(
&mut self,
evaluated_paths: FxHashSet<EvaluatedPath>,
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_cli/src/reporter/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Reporter for ConsoleReporter {
#[diagnostic(
tags(VERBOSE),
severity = Information,
message = "List of files that were evaluated:"
message = "Files processed:"
)]
struct EvaluatedPathsDiagnostic {
#[advice]
Expand All @@ -44,7 +44,7 @@ struct EvaluatedPathsDiagnostic {
#[diagnostic(
tags(VERBOSE),
severity = Information,
message = "List of files that were fixed:"
message = "Files fixed:"
)]
struct FixedPathsDiagnostic {
#[advice]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Found 1 error.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
- src/file.js
Expand All @@ -147,7 +147,7 @@ Found 1 error.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Checked 0 files in <TIME>. No fixes applied.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
! The list is empty.
Expand All @@ -50,7 +50,7 @@ Checked 0 files in <TIME>. No fixes applied.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Found 1 error.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
- other.json
Expand All @@ -63,7 +63,7 @@ Found 1 error.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Found 1 error.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
- other.json
Expand All @@ -63,7 +63,7 @@ Found 1 error.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Found 3 errors.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
- check.js
Expand All @@ -82,7 +82,7 @@ Found 3 errors.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Found 1 warning.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
! The list is empty.
Expand All @@ -52,7 +52,7 @@ Found 1 warning.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Found 3 errors.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
- ci.js
Expand All @@ -82,7 +82,7 @@ Found 3 errors.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Found 1 error.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
- format.js
Expand All @@ -51,7 +51,7 @@ Found 1 error.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Found 2 errors.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
- check.js
Expand All @@ -72,7 +72,7 @@ Found 2 errors.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Found 1 warning.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were evaluated:
i Files processed:
! The list is empty.
Expand All @@ -52,7 +52,7 @@ Found 1 warning.
```block
VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i List of files that were fixed:
i Files fixed:
! The list is empty.
Expand Down
27 changes: 18 additions & 9 deletions crates/biome_fs/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,35 +343,41 @@ pub trait TraversalContext: Sync {
}

#[derive(Debug, Eq, Clone)]
pub struct EvaluatedPath(PathBuf, bool);
pub struct EvaluatedPath {
path: PathBuf,
is_fixed: bool,
}

impl PartialEq for EvaluatedPath {
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
self.path.eq(&other.path)
}
}

impl Hash for EvaluatedPath {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.hash(state)
self.path.hash(state)
}
}

impl EvaluatedPath {
pub fn new_evaluated(path: impl Into<PathBuf>) -> Self {
Self(path.into(), true)
Self {
path: path.into(),
is_fixed: true,
}
}

pub fn is_fixed(&self) -> bool {
self.1
self.is_fixed
}

pub fn as_path(&self) -> &Path {
self.0.as_path()
self.path.as_path()
}

pub fn to_bath_buf(&self) -> PathBuf {
self.0.clone()
pub fn to_path_buf(&self) -> PathBuf {
self.path.clone()
}
}

Expand All @@ -383,7 +389,10 @@ impl AsRef<Path> for EvaluatedPath {

impl<T: Into<PathBuf>> From<T> for EvaluatedPath {
fn from(value: T) -> Self {
Self(value.into(), false)
Self {
path: value.into(),
is_fixed: false,
}
}
}

Expand Down

0 comments on commit f06611f

Please sign in to comment.