refactor: Move resolve_select to converter module

The function is only used there and is not plugin-specific
since it also specifies the default rule selectors (F, E, W).
This commit is contained in:
Martin Fischer
2023-01-24 06:29:00 +01:00
committed by Charlie Marsh
parent 3de2a57416
commit f5ddec0fb3
2 changed files with 9 additions and 9 deletions

View File

@@ -76,7 +76,7 @@ pub fn convert(
.as_ref()
.map(|value| BTreeSet::from_iter(parser::parse_prefix_codes(value)))
})
.unwrap_or_else(|| plugin::resolve_select(&plugins));
.unwrap_or_else(|| resolve_select(&plugins));
let mut ignore = flake8
.get("ignore")
.and_then(|value| {
@@ -406,6 +406,14 @@ pub fn convert(
Ok(Pyproject::new(options))
}
/// Resolve the set of enabled `RuleSelector` values for the given
/// plugins.
fn resolve_select(plugins: &[Plugin]) -> BTreeSet<RuleSelector> {
let mut select = BTreeSet::from([RuleSelector::F, RuleSelector::E, RuleSelector::W]);
select.extend(plugins.iter().map(Plugin::selector));
select
}
#[cfg(test)]
mod tests {
use std::collections::HashMap;

View File

@@ -286,14 +286,6 @@ pub fn infer_plugins_from_codes(selectors: &BTreeSet<RuleSelector>) -> Vec<Plugi
.collect()
}
/// Resolve the set of enabled `RuleSelector` values for the given
/// plugins.
pub fn resolve_select(plugins: &[Plugin]) -> BTreeSet<RuleSelector> {
let mut select = BTreeSet::from([RuleSelector::F, RuleSelector::E, RuleSelector::W]);
select.extend(plugins.iter().map(Plugin::selector));
select
}
#[cfg(test)]
mod tests {
use std::collections::HashMap;