Skip to content

Commit 1f2d4f3

Browse files
authored
File exclusion: Reduce code duplication (#8336)
1 parent 221f7cd commit 1f2d4f3

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

crates/ruff_linter/src/settings/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl FilePattern {
161161

162162
// Add basename path.
163163
if !pattern.contains(std::path::MAIN_SEPARATOR) {
164-
builder.add(Glob::from_str(&pattern)?);
164+
builder.add(Glob::new(&pattern)?);
165165
}
166166
}
167167
}

crates/ruff_workspace/src/resolver.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,17 @@ fn is_file_excluded(
547547

548548
/// Return `true` if the given file should be ignored based on the exclusion
549549
/// criteria.
550+
#[inline]
550551
pub fn match_exclusion<P: AsRef<Path>, R: AsRef<Path>>(
551552
file_path: P,
552553
file_basename: R,
553554
exclusion: &GlobSet,
554555
) -> bool {
555-
if exclusion.is_empty() {
556-
return false;
557-
}
558-
exclusion.is_match(file_path) || exclusion.is_match(file_basename)
556+
match_candidate_exclusion(
557+
&Candidate::new(file_path.as_ref()),
558+
&Candidate::new(file_basename.as_ref()),
559+
exclusion,
560+
)
559561
}
560562

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

0 commit comments

Comments
 (0)