Skip to main content

Rule

Trait Rule 

Source
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§

Source

fn name(&self) -> &'static str

The unique identifier for this rule (e.g., “missing_implementation”)

Source

fn description(&self) -> &'static str

Human-readable description of what this rule checks

Source

fn category(&self) -> Category

Rule category

Provided Methods§

Source

fn long_description(&self) -> Option<&'static str>

Long-form markdown documentation (optional)

Source

fn fixable(&self) -> bool

Whether this rule supports automated fixes via –fix

Source

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.

Source

fn config_options(&self) -> &'static [ConfigOption]

Configuration options supported by this rule

Source

fn min_glib_version(&self) -> Option<(u32, u32)>

Minimum GLib version required by this rule. None means no version requirement (compatible with all versions).

Source

fn requires_auto_cleanup(&self) -> bool

Whether this rule suggests g_auto* macros (disabled when msvc_compatible=true)

Source

fn opt_in(&self) -> bool

Whether this rule is disabled by default (user must explicitly enable it)

Source

fn opt_in_reason(&self) -> Option<&'static str>

Why this rule is opt-in (only meaningful when opt_in() returns true)

Source

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

Source

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

Source

fn check_enum( &self, ast_context: &AstContext, config: &Config, enum_info: &EnumInfo, file: &FileModel, violations: &mut Vec<Violation>, )

Check an enum definition

Source

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

Source

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

Source

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.

Source

fn violation( &self, file: &Path, line: usize, column: usize, message: String, ) -> Violation

Helper to create a violation with the rule name automatically filled in

Source

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

Source

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

Source

fn violation_at( &self, file: &Path, location: &SourceLocation, message: String, ) -> Violation

Source

fn violation_with_fix_at( &self, file: &Path, location: &SourceLocation, message: String, fix: Fix, ) -> Violation

Source

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".

Implementors§

Source§

impl Rule for DeadCode

Source§

impl Rule for DeprecatedAddPrivate

Source§

impl Rule for GErrorInit

Source§

impl Rule for GErrorLeak

Source§

impl Rule for GObjectVirtualMethodsChainUp

Source§

impl Rule for GParamSpecNullNickBlurb

Source§

impl Rule for GParamSpecStaticStrings

Source§

impl Rule for GSourceIdNotStored

Source§

impl Rule for GTaskSourceTag

Source§

impl Rule for GiMissingSince

Source§

impl Rule for GiNotBindingsFriendly

Source§

impl Rule for IncludeOrder

Source§

impl Rule for InconsistentFunctionSignature

Source§

impl Rule for MatchingDeclareDefine

Source§

impl Rule for MissingAutoptrCleanup

Source§

impl Rule for MissingExportMacro

Source§

impl Rule for MissingGBeginDecls

Source§

impl Rule for MissingImplementation

Source§

impl Rule for NoGAutoMacros

Source§

impl Rule for PropertyCanonicalName

Source§

impl Rule for PropertyEnumConvention

Source§

impl Rule for PropertyEnumCoverage

Source§

impl Rule for PropertySwitchExhaustiveness

Source§

impl Rule for SignalCanonicalName

Source§

impl Rule for SignalEnumCoverage

Source§

impl Rule for StrcmpExplicitComparison

Source§

impl Rule for TypeStyle

Source§

impl Rule for UnnecessaryNullCheck

Source§

impl Rule for UntranslatedString

Source§

impl Rule for UnusedVfunc

Source§

impl Rule for UseAutoCleanup

Source§

impl Rule for UseClearFunctions

Source§

impl Rule for UseExplicitDefaultFlags

Source§

impl Rule for UseGAsciiFunctions

Source§

impl Rule for UseGBytesUnrefToData

Source§

impl Rule for UseGFileLoadBytes

Source§

impl Rule for UseGGnucFlagEnum

Source§

impl Rule for UseGNew

Source§

impl Rule for UseGObjectClassInstallProperties

Source§

impl Rule for UseGObjectNewWithProperties

Source§

impl Rule for UseGObjectNotifyByPspec

Source§

impl Rule for UseGSetObject

Source§

impl Rule for UseGSetStr

Source§

impl Rule for UseGSettingsTyped

Source§

impl Rule for UseGSourceConstants

Source§

impl Rule for UseGSourceOnce

Source§

impl Rule for UseGStealPointer

Source§

impl Rule for UseGStrHasPrefixSuffix

Source§

impl Rule for UseGStrcmp0

Source§

impl Rule for UseGStringFreeAndSteal

Source§

impl Rule for UseGStrlcpy

Source§

impl Rule for UseGValueSetStaticString

Source§

impl Rule for UseGVariantNewTyped

Source§

impl Rule for UsePragmaOnce