mirror of https://github.com/astral-sh/ruff
Fix conflicting error message warning (#2182)
This commit is contained in:
parent
c00b8b6d2d
commit
fdccb6ec1c
|
|
@ -243,7 +243,7 @@ impl From<&Configuration> for RuleTable {
|
||||||
ignore: config.unfixable.as_deref().unwrap_or_default(),
|
ignore: config.unfixable.as_deref().unwrap_or_default(),
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
for code in validate_enabled(resolve_codes(
|
for code in resolve_codes(
|
||||||
[RuleCodeSpec {
|
[RuleCodeSpec {
|
||||||
select: config.select.as_deref().unwrap_or(defaults::PREFIXES),
|
select: config.select.as_deref().unwrap_or(defaults::PREFIXES),
|
||||||
ignore: config.ignore.as_deref().unwrap_or_default(),
|
ignore: config.ignore.as_deref().unwrap_or_default(),
|
||||||
|
|
@ -256,7 +256,7 @@ impl From<&Configuration> for RuleTable {
|
||||||
.zip(config.extend_ignore.iter())
|
.zip(config.extend_ignore.iter())
|
||||||
.map(|(select, ignore)| RuleCodeSpec { select, ignore }),
|
.map(|(select, ignore)| RuleCodeSpec { select, ignore }),
|
||||||
),
|
),
|
||||||
)) {
|
) {
|
||||||
let fix = fixable.contains(&code);
|
let fix = fixable.contains(&code);
|
||||||
rules.enable(code, fix);
|
rules.enable(code, fix);
|
||||||
}
|
}
|
||||||
|
|
@ -273,6 +273,13 @@ impl From<&Configuration> for RuleTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate that we didn't enable any incompatible rules.
|
||||||
|
for (a, b, message) in INCOMPATIBLE_CODES {
|
||||||
|
if rules.enabled(a) && rules.enabled(b) {
|
||||||
|
warn_user_once!("{}", message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rules
|
rules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -364,16 +371,6 @@ fn resolve_codes<'a>(specs: impl IntoIterator<Item = RuleCodeSpec<'a>>) -> FxHas
|
||||||
rules
|
rules
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Warn if the set of enabled codes contains any incompatibilities.
|
|
||||||
fn validate_enabled(enabled: FxHashSet<Rule>) -> FxHashSet<Rule> {
|
|
||||||
for (a, b, message) in INCOMPATIBLE_CODES {
|
|
||||||
if enabled.contains(a) && enabled.contains(b) {
|
|
||||||
warn_user_once!("{}", message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue