ruff/crates/ruff_linter/src
Lukasz Piatkowski 03303a9edd
Account for selector specificity when merging `extend_unsafe_fixes` and `override extend_safe_fixes` (#8444)
## Summary

Prior to this change `extend_unsafe_fixes` took precedence over
`extend_safe_fixes` selectors, so any conflicts were resolved in favour
of `extend_unsafe_fixes`. Thanks to that ruff were conservatively
assuming that if configs conlict the fix corresponding to selected rule
will be treated as unsafe.

After this change we take into account Specificity of the selectors. For
conflicts between selectors of the same Specificity we will treat the
corresponding fixes as unsafe. But if the conflicting selectors are of
different specificity the more specific one will win.

## Test Plan

Tests were added for the `FixSafetyTable` struct. The
`check_extend_unsafe_fixes_conflict_with_extend_safe_fixes_by_specificity`
integration test was added to test conflicting rules of different
specificity.

Fixes #8404

---------

Co-authored-by: Zanie <contact@zanie.dev>
2023-11-07 10:33:40 -06:00
..
checkers [`TRIO`] Add `TRIO115`: TrioZeroSleepCall (#8486) 2023-11-06 01:19:46 +00:00
comments Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
cst Rename `Autofix` to `Fix` (#7657) 2023-09-28 10:53:05 +00:00
docstrings Split `Constant` to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
fix Rename `tab-size` to `indent-width` (#8082) 2023-10-24 10:01:24 -04:00
importer Rename `Autofix` to `Fix` (#7657) 2023-09-28 10:53:05 +00:00
lex Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
message Update applicability messages for clarity in tests (#8541) 2023-11-07 16:11:43 +00:00
registry [`refurb`] Implement `implicit-cwd` (FURB177) (#7704) 2023-09-29 02:18:59 +00:00
rules Update applicability messages for clarity in tests (#8541) 2023-11-07 16:11:43 +00:00
settings Account for selector specificity when merging `extend_unsafe_fixes` and `override extend_safe_fixes` (#8444) 2023-11-07 10:33:40 -06:00
snapshots Update applicability messages for clarity in tests (#8541) 2023-11-07 16:11:43 +00:00
codes.rs [`TRIO`] Add `TRIO115`: TrioZeroSleepCall (#8486) 2023-11-06 01:19:46 +00:00
directives.rs Add support for PEP 701 (#7376) 2023-09-29 02:55:39 +00:00
doc_lines.rs Split `Constant` to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
fs.rs Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
lib.rs Rename `Autofix` to `Fix` (#7657) 2023-09-28 10:53:05 +00:00
line_width.rs Rename `tab-size` to `indent-width` (#8082) 2023-10-24 10:01:24 -04:00
linter.rs Account for selector specificity when merging `extend_unsafe_fixes` and `override extend_safe_fixes` (#8444) 2023-11-07 10:33:40 -06:00
logging.rs Use `OneIndexed` in `NotebookIndex` (#7921) 2023-10-13 06:23:49 +05:30
noqa.rs add instructions on line-level suppression to file-level suppression warning (#8052) 2023-10-18 18:46:59 -04:00
packaging.rs Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
pyproject_toml.rs Update pyproject-toml to 0.8 (#8351) 2023-10-30 10:05:37 +00:00
registry.rs Add initial flake8-trio rule (#8439) 2023-11-03 01:05:12 +00:00
renamer.rs Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
rule_redirects.rs Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
rule_selector.rs Add `explicit-preview-rules` to toggle explicit selection of preview rules (#7390) 2023-09-28 15:00:33 -05:00
source_kind.rs Use `SourceKind::diff` for formatter (#8240) 2023-10-26 11:08:13 +05:30
test.rs Update CLI to respect fix applicability (#7769) 2023-10-06 03:41:43 +00:00
upstream_categories.rs Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00