Skip to main content

SignalDetector

Trait SignalDetector 

Source
pub trait SignalDetector: Send + Sync {
    // Required methods
    fn signal(&self) -> StyleSignal;
    fn supported_languages(&self) -> &'static [Language];
    fn count_violations(&self, file: &ParsedFile) -> usize;

    // Provided methods
    fn count_violations_with_ir(
        &self,
        _ir: &StyleIr,
        file: &ParsedFile,
    ) -> usize { ... }
    fn skips_test_files(&self) -> bool { ... }
    fn detect_findings(
        &self,
        file: &ParsedFile,
        is_test_file: bool,
        skip_tests_config: bool,
    ) -> Vec<(StyleSignal, usize)> { ... }
    fn detect_findings_with_ir(
        &self,
        ir: &StyleIr,
        file: &ParsedFile,
        is_test_file: bool,
        skip_tests_config: bool,
    ) -> Vec<(StyleSignal, usize)> { ... }
}
Expand description

Direct signal detector that produces StyleSignal scores from parsed code.

Unlike rules that produce CodeIssues, a SignalDetector directly scores a file for a specific style signal without going through Rule → Issue pipeline. This enables the “few rules + strong aggregation” approach by replacing many small rules with one signal detector per behavioral dimension.

Required Methods§

Source

fn signal(&self) -> StyleSignal

Source

fn supported_languages(&self) -> &'static [Language]

Source

fn count_violations(&self, file: &ParsedFile) -> usize

Run detection on a parsed file. Returns the number of signal violations found.

Provided Methods§

Source

fn count_violations_with_ir(&self, _ir: &StyleIr, file: &ParsedFile) -> usize

Run detection using a pre-computed StyleIr (avoids redundant from_parsed calls). Default: falls back to count_violations which recomputes the IR.

Source

fn skips_test_files(&self) -> bool

Whether this detector should be skipped for test files. Override to false for signals that apply to test code too.

Source

fn detect_findings( &self, file: &ParsedFile, is_test_file: bool, skip_tests_config: bool, ) -> Vec<(StyleSignal, usize)>

Produce per-file signal findings with violation counts.

is_test_file: whether the file is identified as test code. skip_tests_config: user config flag to skip tests (from config.toml).

Default implementation: if the file is a test file AND the detector skips tests AND the user config agrees, returns empty. Otherwise wraps count_violations into a (signal, count) pair.

Source

fn detect_findings_with_ir( &self, ir: &StyleIr, file: &ParsedFile, is_test_file: bool, skip_tests_config: bool, ) -> Vec<(StyleSignal, usize)>

Produce per-file signal findings using a pre-computed StyleIr.

Implementors§