Struct Thresholds
pub struct Thresholds {
pub gates: Gates,
pub diff: DiffGates,
pub calibration: CalibrationConfig,
pub new_code: Option<NewCodeGates>,
}Fields§
§gates: Gates§diff: DiffGates§calibration: CalibrationConfig§new_code: Option<NewCodeGates>The optional [new_code] section — a period-scoped two-band gate.
None when the section is absent (byte-identical to no feature);
Some enables it. See NewCodeGates.
Implementations§
§impl Thresholds
impl Thresholds
pub fn discover(repo_root: &Path) -> Result<Self>
pub fn discover(repo_root: &Path) -> Result<Self>
Auto-discover .codelore-thresholds.toml at the repo root.
Returns the default (no gates configured) when the file is
absent — gates are opt-in.
§Errors
CodeLoreError::Analysis on I/O or parse errors.
pub fn from_path(path: &Path) -> Result<Self>
pub fn from_path(path: &Path) -> Result<Self>
Parse a thresholds file from disk and validate its values.
§Errors
CodeLoreError::RepoIo(exit 3) when the file cannot be read.CodeLoreError::Analysis(exit 4) when the TOML fails to parse.CodeLoreError::InvalidOptions(exit 2, the configuration-error bucket) when a threshold value is non-finite or out of range — the value-level sibling of thedeny_unknown_fieldstypo guard.
pub fn from_text(raw: &str) -> Result<Self, String>
pub fn from_text(raw: &str) -> Result<Self, String>
Parse from in-memory TOML text. Used by tests + from_path.
§Errors
Returns a String description of the parse failure.
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True when no gate is configured. Callers can short-circuit the check entirely on empty config.
pub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate every numeric threshold’s value. A bare toml::from_str
accepts TOML’s nan/inf float literals and any out-of-range
magnitude, and every gate comparison is a bare >/<: a nan
floor can never fire, an inf ceiling vacuous-passes, and a negative
or overshot bound is silently degenerate. This is the value-level
sibling of the struct’s deny_unknown_fields typo guard.
Each field’s domain is derived from its own documented semantics:
scores and percentages on [0, 100], ratios on [0, 1], health
deltas on [-100, 100] (a [0, 100] score can move at most a full
span either way), and the three open-topped ceilings (cognitive_max,
hotspot_score_max, hotspot_anchored_max) require only finiteness and
non-negativity.
u32 counts (max_dependency_cycles, new_hotspot_max,
max_findings_in_hot_files) cannot express a non-finite or negative
value, so the type already guards them.
Every offending key is collected in one pass so a degenerate config surfaces all its problems at once rather than one re-run at a time.
§Errors
Returns a String naming each offending key, its value, and the
accepted domain. Ok(()) when every configured threshold is in range.
Trait Implementations§
§impl Clone for Thresholds
impl Clone for Thresholds
§fn clone(&self) -> Thresholds
fn clone(&self) -> Thresholds
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for Thresholds
impl Debug for Thresholds
§impl Default for Thresholds
impl Default for Thresholds
§fn default() -> Thresholds
fn default() -> Thresholds
§impl<'de> Deserialize<'de> for Thresholds
impl<'de> Deserialize<'de> for Thresholds
§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Thresholds
impl RefUnwindSafe for Thresholds
impl Send for Thresholds
impl Sync for Thresholds
impl Unpin for Thresholds
impl UnsafeUnpin for Thresholds
impl UnwindSafe for Thresholds
Blanket Implementations§
impl<T> Allocation for T
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more