Skip to main content

MetricInfo

Struct MetricInfo 

Source
#[non_exhaustive]
pub struct MetricInfo { pub id: &'static str, pub family: &'static str, pub long_description: &'static str, pub direction: Direction, pub skip_at_unit: bool, pub scope: MetricScope, }
Expand description

Catalog entry for one offender-emitting sub-metric id.

The id is the dotted key the threshold engine emits for an offender (halstead.volume); family groups ids under a top-level metric (halstead) and must match a MetricFamily::name.

#[non_exhaustive]: these are read-only records the library constructs (downstream consumers read fields, never build them), so a new field can be added in a future minor without a SemVer break.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: &'static str

Dotted offender id, e.g. "halstead.volume" or "cognitive".

§family: &'static str

Top-level family this id belongs to, e.g. "halstead".

§long_description: &'static str

Long-form sentence for SARIF rule.shortDescription.text and the Code Climate description prefix.

§direction: Direction

Whether a higher or lower value is the unhealthy direction.

§skip_at_unit: bool

Whether the metric’s JSON headline is an aggregate across descendant spaces (a sum/*_sum field) that does not match the CLI threshold accessor’s per-space scalar at any interior space.

true for the four metrics whose serialized JSON value diverges from the per-space accessor — cognitive, cyclomatic, cyclomatic.modified, and abc (#441). The aggregate equals the per-space scalar only at a leaf space (no descendant function/closure spaces); at any interior space — the file-level unit or a container with descendants — it is larger.

This flag describes the sum/*_sum aggregate field, which still diverges. As of #958 the wire shape also serializes each of these four metrics’ per-space own value (cyclomatic.value, cyclomatic.modified.value, cognitive.value, abc.value), so a JSON-walking front-end no longer needs this flag to stay correct: it reads the own value directly and emits at every space exactly like the CLI. The Python to_sarif binding was switched to that path in #958; before it, the binding emitted these only at leaf spaces to avoid subtree-wide values masquerading as per-space findings the CLI never produces (#855). The flag name retains its original unit-only framing.

The flag is not derivable from the JSON path string: nexits also serialises a sum field, but its CLI accessor (nexits_sum()) reads that same aggregate, so it does not diverge and is false. The divergence is between the JSON field and the CLI accessor, which only this registry now records once for both front-ends to share (#442).

§scope: MetricScope

The space kind this metric’s threshold gates (issue #969). Both the CLI threshold engine and the Python to_sarif binding read this to skip spaces a metric does not measure, so a metric’s file-wide or impl-wide aggregate never fires as a per-function limit. See MetricScope.

Trait Implementations§

Source§

impl Clone for MetricInfo

Source§

fn clone(&self) -> MetricInfo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MetricInfo

Source§

impl Debug for MetricInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.