pub trait TreeSitterRule: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn supported_languages(&self) -> &'static [Language];
fn check(&self, file: &ParsedFile) -> Vec<CodeIssue>;
// Provided methods
fn skips_test_files(&self) -> bool { ... }
fn check_with_context(
&self,
file: &ParsedFile,
_is_test_file: bool,
_context: &FileContext,
_config: &ProjectConfig,
) -> Vec<CodeIssue> { ... }
}Expand description
A code quality rule that analyzes source files using tree-sitter AST.
Unlike the original [crate::rules::Rule] trait which requires syn::File,
this trait works on tree-sitter’s language-agnostic CST. Rules declare
which languages they support via supported_languages.
Required Methods§
Sourcefn supported_languages(&self) -> &'static [Language]
fn supported_languages(&self) -> &'static [Language]
Languages supported by this rule.
Sourcefn check(&self, file: &ParsedFile) -> Vec<CodeIssue>
fn check(&self, file: &ParsedFile) -> Vec<CodeIssue>
Analyze a parsed file and return detected issues.
Provided Methods§
Sourcefn skips_test_files(&self) -> bool
fn skips_test_files(&self) -> bool
Whether to skip test files (default: true).
Sourcefn check_with_context(
&self,
file: &ParsedFile,
_is_test_file: bool,
_context: &FileContext,
_config: &ProjectConfig,
) -> Vec<CodeIssue>
fn check_with_context( &self, file: &ParsedFile, _is_test_file: bool, _context: &FileContext, _config: &ProjectConfig, ) -> Vec<CodeIssue>
Analyze a file with additional context about the file’s role in the project. Override this when the rule needs to adjust behavior based on file context (e.g. skipping UI files, relaxing thresholds for examples) or config.