Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RuleSet.remove #3685

Merged
merged 3 commits into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/ruff/src/registry/rule_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl RuleSet {
let mut i = 0;

while i < self.0.len() {
self.0[i] ^= other.0[i];
self.0[i] &= !other.0[i];
i += 1;
}

Expand Down Expand Up @@ -362,4 +362,15 @@ mod tests {
let expected_rules: Vec<_> = Rule::iter().collect();
assert_eq!(all_rules, expected_rules);
}

#[test]
fn remove_not_existing_rule_from_set() {
let mut set = RuleSet::default();

set.remove(Rule::AmbiguousFunctionName);

assert!(!set.contains(Rule::AmbiguousFunctionName));
assert!(set.is_empty());
assert_eq!(set.into_iter().collect::<Vec<_>>(), vec![]);
}
}