abstract class ConventionRule
- ConventionRule
- Reference
- Object
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
- ControllerClassNamingRule
- ControllerFileSuffixRule
- ScreenClassNamingRule
- ScreenFileSuffixRule
- SpecPlatformDirectoryRule
- ViewSubclassUnderViewsDirRule
Defined in:
lsp_rules/convention_rule.crClass Method Summary
-
.registered_rules : Array(ConventionRule.class)
Registry of every subclass loaded into the process.
Instance Method Summary
- #check(file_path : String, content : String) : Array(Diagnostic)
-
#configure(config : ConventionConfig) : Nil
Subclasses MAY override to receive the runner-loaded config at construction time.
-
#find_line(content : String, pattern : Regex) : Int32 | Nil
Returns the 1-based line number of the first match of
patternincontent, ornilif the pattern is not found. - #rule_name : String
-
#snake_case(identifier : String) : String
Converts
PascalCase/camelCaseidentifiers to#snake_case.
Class Method Detail
Registry of every subclass loaded into the process.
Instance Method Detail
Subclasses MAY override to receive the runner-loaded config at construction time. Default no-op so existing rules without config dependence keep working unchanged.
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.
Converts PascalCase / camelCase identifiers to #snake_case.