Skip to content

Commit

Permalink
File exclusion: Reduce code duplication (#8336)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Oct 30, 2023
1 parent 221f7cd commit 1f2d4f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/settings/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl FilePattern {

// Add basename path.
if !pattern.contains(std::path::MAIN_SEPARATOR) {
builder.add(Glob::from_str(&pattern)?);
builder.add(Glob::new(&pattern)?);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions crates/ruff_workspace/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,15 +547,17 @@ fn is_file_excluded(

/// Return `true` if the given file should be ignored based on the exclusion
/// criteria.
#[inline]
pub fn match_exclusion<P: AsRef<Path>, R: AsRef<Path>>(
file_path: P,
file_basename: R,
exclusion: &GlobSet,
) -> bool {
if exclusion.is_empty() {
return false;
}
exclusion.is_match(file_path) || exclusion.is_match(file_basename)
match_candidate_exclusion(
&Candidate::new(file_path.as_ref()),
&Candidate::new(file_basename.as_ref()),
exclusion,
)
}

/// Return `true` if the given candidates should be ignored based on the exclusion
Expand Down

0 comments on commit 1f2d4f3

Please sign in to comment.