struct Noir::ExcludePath

Overview

Compiled --exclude-path patterns, and the single implementation of what they mean.

The option used to be spelled out inline in the detector's walk (src/detector/detector.cr), which is the only place that sees every file — so it protected exactly the analyzers that take their file set from CodeLocator. The six adapters that enumerate the filesystem themselves (Spring/Quarkus static resources, Dropwizard config, the Go static-dir resolver, the Android/iOS resource walks) never went through it and happily reported files the user had excluded. Analyzer#excluded_path? applies this to them, which is only correct as long as both sides agree on what a pattern means — hence one type, used by both.

Pattern semantics (unchanged from the detector's original inline form):

Defined in:

utils/exclude_path.cr

Constant Summary

CASE_INSENSITIVE = {% if (flag?(:darwin)) || (flag?(:windows)) %} true {% else %} false {% end %}

Mirrors the detector's original exclude_case_insensitive.

Constructors

Instance Method Summary

Constructor Detail

def self.new(raw : String) #

raw is the comma-separated option value. Windows-style backslashes are normalized before the / classification, so src\legacy is treated as a path pattern (and matches) instead of an unmatchable basename.


[View source]

Instance Method Detail

def active? : Bool #

True when the user supplied at least one usable pattern. Callers should check this before computing a relative path per file — with no --exclude-path there is nothing to compute it for.


[View source]
def excluded?(relative_path : String) : Bool #

relative_path is the file's location relative to the scan base that owns it. A leading / is accepted (that is the shape Analyzer#base_relative_path returns) and ignored, so both callers can hand over their own spelling.

Raises File::BadPatternError on a malformed glob, which the detector converts into Noir::InvalidExcludePathError — a bad pattern must stop the scan rather than silently exclude nothing.


[View source]