Rule

Trait Rule 

Source
pub trait Rule: Send + Sync {
    // Required methods
    fn code(&self) -> &RuleCode;
    fn name(&self) -> &str;
    fn severity(&self) -> Severity;
    fn category(&self) -> RuleCategory;
    fn meta(&self) -> &RuleMeta;
    fn check(&self, context: &LintContext<'_>) -> Vec<CheckFailure>;

    // Provided methods
    fn is_fixable(&self) -> bool { ... }
    fn fix(&self, _source: &str) -> Option<String> { ... }
    fn get_message(&self, _details: &HashMap<String, String>) -> String { ... }
}
Expand description

A rule that can check Docker Compose files.

Required Methods§

Source

fn code(&self) -> &RuleCode

Get the rule code (e.g., “DCL001”).

Source

fn name(&self) -> &str

Get the human-readable rule name (e.g., “no-build-and-image”).

Source

fn severity(&self) -> Severity

Get the default severity.

Source

fn category(&self) -> RuleCategory

Get the rule category.

Source

fn meta(&self) -> &RuleMeta

Get the rule metadata (description, URL).

Source

fn check(&self, context: &LintContext<'_>) -> Vec<CheckFailure>

Check the compose file and return any failures.

Provided Methods§

Source

fn is_fixable(&self) -> bool

Whether this rule can auto-fix issues.

Source

fn fix(&self, _source: &str) -> Option<String>

Auto-fix the source content (if fixable). Returns the fixed content, or None if no fix was applied.

Source

fn get_message(&self, _details: &HashMap<String, String>) -> String

Get a message for this rule violation.

Implementors§

Source§

impl<C, X> Rule for FixableRule<C, X>
where C: Fn(&LintContext<'_>) -> Vec<CheckFailure> + Send + Sync, X: Fn(&str) -> Option<String> + Send + Sync,

Source§

impl<F> Rule for SimpleRule<F>
where F: Fn(&LintContext<'_>) -> Vec<CheckFailure> + Send + Sync,