mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
Move FURB145
from nursery to preview (#7364)
Moves the new rule from nursery to preview for the upcoming release. Adds new test coverage for selection of a single preview rule and fixes a bug where preview rules were incorrectly selectable with exact codes.
This commit is contained in:
parent
5347df4728
commit
4bff397318
3 changed files with 31 additions and 6 deletions
|
@ -764,7 +764,7 @@ pub fn resolve_src(src: &[String], project_root: &Path) -> Result<Vec<PathBuf>>
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::configuration::{Configuration, RuleSelection};
|
||||
use ruff::codes::{Flake8Copyright, Pycodestyle};
|
||||
use ruff::codes::{Flake8Copyright, Pycodestyle, Refurb};
|
||||
use ruff::registry::{Linter, Rule, RuleSet};
|
||||
use ruff::settings::types::PreviewMode;
|
||||
use ruff::RuleSelector;
|
||||
|
@ -811,10 +811,11 @@ mod tests {
|
|||
Rule::RepeatedAppend,
|
||||
Rule::DeleteFullSlice,
|
||||
Rule::CheckAndRemoveFromSet,
|
||||
Rule::SliceCopy,
|
||||
Rule::QuadraticListSummation,
|
||||
];
|
||||
|
||||
const PREVIEW_RULES: &[Rule] = &[Rule::SliceCopy];
|
||||
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
fn resolve_rules(
|
||||
selections: impl IntoIterator<Item = RuleSelection>,
|
||||
|
@ -1100,6 +1101,29 @@ mod tests {
|
|||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_rule_preview() {
|
||||
let actual = resolve_rules(
|
||||
[RuleSelection {
|
||||
select: Some(vec![Refurb::_145.into()]),
|
||||
..RuleSelection::default()
|
||||
}],
|
||||
Some(PreviewMode::Disabled),
|
||||
);
|
||||
let expected = RuleSet::empty();
|
||||
assert_eq!(actual, expected);
|
||||
|
||||
let actual = resolve_rules(
|
||||
[RuleSelection {
|
||||
select: Some(vec![Refurb::_145.into()]),
|
||||
..RuleSelection::default()
|
||||
}],
|
||||
Some(PreviewMode::Enabled),
|
||||
);
|
||||
let expected = RuleSet::from_rule(Rule::SliceCopy);
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_preview() {
|
||||
let actual = resolve_rules(
|
||||
|
@ -1119,7 +1143,9 @@ mod tests {
|
|||
}],
|
||||
Some(PreviewMode::Enabled),
|
||||
);
|
||||
let expected = RuleSet::from_rules(NURSERY_RULES);
|
||||
|
||||
let expected =
|
||||
RuleSet::from_rules(NURSERY_RULES).union(&RuleSet::from_rules(PREVIEW_RULES));
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue