abstract class ConventionRule

Overview

Abstract base class for every Phase 10 convention rule.

Subclasses implement #check(file_path, content) returning zero or more Diagnostic values. Rules should be stateless — instances are reused across files. Heuristics are regex/string level; we do not parse Crystal.

Subclasses are auto-registered into ConventionRule.registered_rules at class-definition time via the inherited macro hook. The runner instantiates each registered class with the current ConventionConfig.

Direct Known Subclasses

Defined in:

lsp_rules/convention_rule.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.registered_rules : Array(ConventionRule.class) #

Registry of every subclass loaded into the process.


[View source]

Instance Method Detail

abstract def check(file_path : String, content : String) : Array(Diagnostic) #

[View source]
def configure(config : ConventionConfig) : Nil #

Subclasses MAY override to receive the runner-loaded config at construction time. Default no-op so existing rules without config dependence keep working unchanged.


[View source]
def find_line(content : String, pattern : Regex) : Int32 | Nil #

Returns the 1-based line number of the first match of pattern in content, or nil if the pattern is not found. Helper for rules.


[View source]
abstract def rule_name : String #

[View source]
def snake_case(identifier : String) : String #

Converts PascalCase / camelCase identifiers to #snake_case.


[View source]