pub trait Rule: Send + Sync {
Show 23 methods
// Required methods
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn category(&self) -> Category;
// Provided methods
fn long_description(&self) -> Option<&'static str> { ... }
fn fixable(&self) -> bool { ... }
fn requires_meson(&self) -> bool { ... }
fn config_options(&self) -> &'static [ConfigOption] { ... }
fn min_glib_version(&self) -> Option<(u32, u32)> { ... }
fn requires_auto_cleanup(&self) -> bool { ... }
fn opt_in(&self) -> bool { ... }
fn opt_in_reason(&self) -> Option<&'static str> { ... }
fn check_func_impl(
&self,
ast_context: &AstContext,
config: &Config,
func: &FunctionDefItem,
file: &FileModel,
violations: &mut Vec<Violation>,
) { ... }
fn check_func_decl(
&self,
ast_context: &AstContext,
config: &Config,
func: &FunctionDeclItem,
file: &FileModel,
violations: &mut Vec<Violation>,
) { ... }
fn check_enum(
&self,
ast_context: &AstContext,
config: &Config,
enum_info: &EnumInfo,
file: &FileModel,
violations: &mut Vec<Violation>,
) { ... }
fn check_gobject_type(
&self,
ast_context: &AstContext,
config: &Config,
gobject_type: &GObjectType,
file: &FileModel,
violations: &mut Vec<Violation>,
) { ... }
fn check_all(
&self,
ast_context: &AstContext,
config: &Config,
violations: &mut Vec<Violation>,
) { ... }
fn check_function_renames(
&self,
func: &FunctionDefItem,
file: &FileModel,
config: &Config,
violations: &mut Vec<Violation>,
renames: &[FunctionRename],
) { ... }
fn violation(
&self,
file: &Path,
line: usize,
column: usize,
message: String,
) -> Violation { ... }
fn violation_with_fix(
&self,
file: &Path,
line: usize,
column: usize,
message: String,
fix: Fix,
) -> Violation { ... }
fn violation_with_fixes(
&self,
file: &Path,
line: usize,
column: usize,
message: String,
fixes: Vec<Fix>,
) -> Violation { ... }
fn violation_at(
&self,
file: &Path,
location: &SourceLocation,
message: String,
) -> Violation { ... }
fn violation_with_fix_at(
&self,
file: &Path,
location: &SourceLocation,
message: String,
fix: Fix,
) -> Violation { ... }
fn violation_with_fixes_at(
&self,
file: &Path,
location: &SourceLocation,
message: String,
fixes: Vec<Fix>,
) -> Violation { ... }
}Expand description
Trait that all linting rules must implement
Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
The unique identifier for this rule (e.g., “missing_implementation”)
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
Human-readable description of what this rule checks
Provided Methods§
Sourcefn long_description(&self) -> Option<&'static str>
fn long_description(&self) -> Option<&'static str>
Long-form markdown documentation (optional)
Sourcefn requires_meson(&self) -> bool
fn requires_meson(&self) -> bool
Whether this rule requires meson introspection to produce results. Rules returning true silently skip when no build directory is found.
Sourcefn config_options(&self) -> &'static [ConfigOption]
fn config_options(&self) -> &'static [ConfigOption]
Configuration options supported by this rule
Sourcefn min_glib_version(&self) -> Option<(u32, u32)>
fn min_glib_version(&self) -> Option<(u32, u32)>
Minimum GLib version required by this rule.
None means no version requirement (compatible with all versions).
Sourcefn requires_auto_cleanup(&self) -> bool
fn requires_auto_cleanup(&self) -> bool
Whether this rule suggests g_auto* macros (disabled when msvc_compatible=true)
Sourcefn opt_in(&self) -> bool
fn opt_in(&self) -> bool
Whether this rule is disabled by default (user must explicitly enable it)
Sourcefn opt_in_reason(&self) -> Option<&'static str>
fn opt_in_reason(&self) -> Option<&'static str>
Why this rule is opt-in (only meaningful when opt_in() returns true)
Sourcefn check_func_impl(
&self,
ast_context: &AstContext,
config: &Config,
func: &FunctionDefItem,
file: &FileModel,
violations: &mut Vec<Violation>,
)
fn check_func_impl( &self, ast_context: &AstContext, config: &Config, func: &FunctionDefItem, file: &FileModel, violations: &mut Vec<Violation>, )
Check a function implementation (from C files) Override this to check function bodies and implementations
Sourcefn check_func_decl(
&self,
ast_context: &AstContext,
config: &Config,
func: &FunctionDeclItem,
file: &FileModel,
violations: &mut Vec<Violation>,
)
fn check_func_decl( &self, ast_context: &AstContext, config: &Config, func: &FunctionDeclItem, file: &FileModel, violations: &mut Vec<Violation>, )
Check a function declaration (from header files) Override this to check function declarations and signatures
Sourcefn check_enum(
&self,
ast_context: &AstContext,
config: &Config,
enum_info: &EnumInfo,
file: &FileModel,
violations: &mut Vec<Violation>,
)
fn check_enum( &self, ast_context: &AstContext, config: &Config, enum_info: &EnumInfo, file: &FileModel, violations: &mut Vec<Violation>, )
Check an enum definition
Sourcefn check_gobject_type(
&self,
ast_context: &AstContext,
config: &Config,
gobject_type: &GObjectType,
file: &FileModel,
violations: &mut Vec<Violation>,
)
fn check_gobject_type( &self, ast_context: &AstContext, config: &Config, gobject_type: &GObjectType, file: &FileModel, violations: &mut Vec<Violation>, )
Check a GObject type declaration/definition Override this to check properties, signals, or other GObject-level concerns
Sourcefn check_all(
&self,
ast_context: &AstContext,
config: &Config,
violations: &mut Vec<Violation>,
)
fn check_all( &self, ast_context: &AstContext, config: &Config, violations: &mut Vec<Violation>, )
Check the AST and add violations to the provided vector Default implementation calls check_func_impl for C files, check_func_decl for headers, and check_gobject_type for all files. Override this if you need custom iteration logic beyond per-item checking
Sourcefn check_function_renames(
&self,
func: &FunctionDefItem,
file: &FileModel,
config: &Config,
violations: &mut Vec<Violation>,
renames: &[FunctionRename],
)
fn check_function_renames( &self, func: &FunctionDefItem, file: &FileModel, config: &Config, violations: &mut Vec<Violation>, renames: &[FunctionRename], )
Find calls to functions listed in renames and emit violations.
When to is Some, generates a fix that reformats the entire call.
Sourcefn violation(
&self,
file: &Path,
line: usize,
column: usize,
message: String,
) -> Violation
fn violation( &self, file: &Path, line: usize, column: usize, message: String, ) -> Violation
Helper to create a violation with the rule name automatically filled in
Sourcefn violation_with_fix(
&self,
file: &Path,
line: usize,
column: usize,
message: String,
fix: Fix,
) -> Violation
fn violation_with_fix( &self, file: &Path, line: usize, column: usize, message: String, fix: Fix, ) -> Violation
Helper to create a violation with an automated fix
Sourcefn violation_with_fixes(
&self,
file: &Path,
line: usize,
column: usize,
message: String,
fixes: Vec<Fix>,
) -> Violation
fn violation_with_fixes( &self, file: &Path, line: usize, column: usize, message: String, fixes: Vec<Fix>, ) -> Violation
Helper to create a violation with multiple automated fixes
fn violation_at( &self, file: &Path, location: &SourceLocation, message: String, ) -> Violation
fn violation_with_fix_at( &self, file: &Path, location: &SourceLocation, message: String, fix: Fix, ) -> Violation
fn violation_with_fixes_at( &self, file: &Path, location: &SourceLocation, message: String, fixes: Vec<Fix>, ) -> Violation
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".