diff --git a/crates/ruff_linter/src/codes.rs b/crates/ruff_linter/src/codes.rs index e9559fbfb8..f985b9a230 100644 --- a/crates/ruff_linter/src/codes.rs +++ b/crates/ruff_linter/src/codes.rs @@ -4,12 +4,12 @@ /// `--select`. For pylint this is e.g. C0414 and E0118 but also C and E01. use std::fmt::Formatter; -use strum_macros::{AsRefStr, EnumIter}; - use crate::registry::{AsRule, Linter}; use crate::rule_selector::is_single_rule_selector; use crate::rules; +use strum_macros::{AsRefStr, EnumIter}; + #[derive(PartialEq, Eq, PartialOrd, Ord)] pub struct NoqaCode(&'static str, &'static str); diff --git a/crates/ruff_linter/src/registry.rs b/crates/ruff_linter/src/registry.rs index a7a571e82b..7bd5ba4fae 100644 --- a/crates/ruff_linter/src/registry.rs +++ b/crates/ruff_linter/src/registry.rs @@ -427,7 +427,18 @@ mod tests { use super::{Linter, Rule, RuleNamespace}; #[test] - fn test_rule_naming_convention() { + fn documentation() { + for rule in Rule::iter() { + assert!( + rule.explanation().is_some(), + "Rule {} is missing documentation", + rule.as_ref() + ); + } + } + + #[test] + fn rule_naming_convention() { // The disallowed rule names are defined in a separate file so that they can also be picked up by add_rule.py. let patterns: Vec<_> = include_str!("../resources/test/disallowed_rule_names.txt") .trim() @@ -459,7 +470,7 @@ mod tests { } #[test] - fn test_linter_parse_code() { + fn linter_parse_code() { for rule in Rule::iter() { let code = format!("{}", rule.noqa_code()); let (linter, rest) = diff --git a/crates/ruff_macros/src/map_codes.rs b/crates/ruff_macros/src/map_codes.rs index d9d0c5112a..f85377dae3 100644 --- a/crates/ruff_macros/src/map_codes.rs +++ b/crates/ruff_macros/src/map_codes.rs @@ -416,6 +416,8 @@ fn register_rules<'a>(input: impl Iterator) -> TokenStream { } quote! { + use ruff_diagnostics::Violation; + #[derive( EnumIter, Debug,