Fix regression with line-based rules not being ignored per-file (#2311)

This commit is contained in:
Samuel Cormier-Iijima 2023-01-28 14:48:32 -05:00 committed by GitHub
parent f308f9f27e
commit 1a32d873f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 9 deletions

View File

@ -132,15 +132,6 @@ pub fn check_path(
doc_lines.dedup();
}
// Ignore diagnostics based on per-file-ignores.
if !diagnostics.is_empty() && !settings.per_file_ignores.is_empty() {
let ignores = fs::ignores_from_path(path, &settings.per_file_ignores)?;
if !ignores.is_empty() {
diagnostics.retain(|diagnostic| !ignores.contains(&diagnostic.kind.rule()));
}
};
// Run the lines-based rules.
if settings
.rules
@ -158,6 +149,15 @@ pub fn check_path(
));
}
// Ignore diagnostics based on per-file-ignores.
if !diagnostics.is_empty() && !settings.per_file_ignores.is_empty() {
let ignores = fs::ignores_from_path(path, &settings.per_file_ignores)?;
if !ignores.is_empty() {
diagnostics.retain(|diagnostic| !ignores.contains(&diagnostic.kind.rule()));
}
};
// Enforce `noqa` directives.
if (matches!(noqa, flags::Noqa::Enabled) && !diagnostics.is_empty())
|| settings