#[non_exhaustive]pub struct Stats { /* private fields */ }Expand description
The Mi metric.
Implementations§
Source§impl Stats
impl Stats
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true when the space holds no code to measure: its
Halstead volume or its size term is zero.
Every variant then returns the in-band sentinel 0.0, which
cannot be told from a genuine 0 or from mi.visual_studio’s
clamp. Consumers that aggregate MI must skip these spaces. The
wire/JSON value stays 0.0 in 2.x; serialising null is
deferred to 3.0 (#1621).
Sourcepub fn original(&self) -> f64
pub fn original(&self) -> f64
Returns the Mi metric calculated using the original formula,
171 − 5.2·ln(V) − 0.23·G − 16.2·ln(L) with V the Halstead
volume, G the cyclomatic sum and L the space’s ploc.
Its value can be negative.
Sourcepub fn sei(&self) -> f64
pub fn sei(&self) -> f64
Returns the Mi metric calculated using the derivative formula
employed by the Software Engineering Institute (SEI): the
original value plus 50·sin(√(2.4·CM)), with
CM the comment ratio in [0, 1]. The comment term rises
monotonically from 0 to 50·sin(√2.4) ≈ 49.99, so sei is never
below original and equals it when the space has no comment.
Its value can be negative.
Sourcepub fn visual_studio(&self) -> f64
pub fn visual_studio(&self) -> f64
Returns the Mi metric calculated using the derivative formula
employed by Microsoft Visual Studio: the
original value rescaled to [0, 100] as
max(0, original·100/171).