Skip to main content

rules_source

Function rules_source 

Source
pub fn rules_source(
    rules_file: Option<&str>,
    configured: Option<&OsStr>,
    repository_root: &Path,
) -> RulesSource
Expand description

What: Select the rules file: the configured rulesFile, else the variable’s value, else the default file, each relative to the repository root. Option<&str> is “the configured name or nothing”; Option<&OsStr> is “the variable’s value or nothing”. Why: The user decided on 2026-10-05 that configuration names the file first and the variable second. The spawned scanner ran with the repository root as its working directory, so a relative setting meant “relative to the root”. In-process there is no such directory change, so the root is joined explicitly; .join(..) keeps an absolute variable value as it is, and a configured name is relative by construction (config_rules_file.rs). A configured name or a set variable makes a missing file an error; only the default file may be missing.

In TS you’d write (pseudocode):

function rulesSource(rulesFile: string | undefined, variable: string | undefined, repositoryRoot: string): RulesSource;