pub struct FunctionComplexity {Show 14 fields
pub name: String,
pub is_private_member: bool,
pub context_named: Option<AnonymousFunctionKind>,
pub line: u32,
pub col: u32,
pub cyclomatic: u16,
pub cognitive: u16,
pub line_count: u32,
pub param_count: u8,
pub react_hook_count: u16,
pub react_jsx_max_depth: u16,
pub react_prop_count: u16,
pub source_hash: Option<String>,
pub contributions: Vec<ComplexityContribution>,
}Expand description
Complexity metrics for a single function/method/arrow.
Fields§
§name: StringFunction name, or a placeholder ("<anonymous>", "<arrow>") for a
function that has no name.
is_private_member: boolWhether this function is an ECMAScript #-private class member.
Kept separately from name because a public string-named method may
legally begin with # and remains eligible for runtime coverage.
context_named: Option<AnonymousFunctionKind>Some when name comes from the call or the function that holds this
function, not from its own declaration, binding, or key. Examples:
Command.make("setup") for a callback argument, the Effect.fn span
name, or the name of the function that returns Effect.gen(...). The
value is the kind of placeholder that the function had before.
Coverage producers and runtime identities record such a function
without a name, so they use Self::identity_name.
line: u321-based line number where the function starts.
col: u320-based byte column where the function starts.
cyclomatic: u16McCabe cyclomatic complexity (1 + decision points).
cognitive: u16SonarSource cognitive complexity (structural + nesting penalty).
line_count: u32Number of lines in the function body.
param_count: u8Number of parameters (excluding TypeScript’s this parameter).
react_hook_count: u16Number of React hook calls (useState / useEffect / useMemo /
useCallback / custom use*) made directly in this function’s body.
Non-zero only for React components/hooks; descriptive context surfaced in
the hotspot drill-down, never a tunable threshold (anti-numerology).
react_jsx_max_depth: u16Maximum JSX element nesting depth reached in this function’s body (the
deepest chain of element-inside-element). 0 when the function renders
no JSX. Descriptive context surfaced in the hotspot drill-down, never a
tunable threshold (anti-numerology).
react_prop_count: u16Number of props destructured from this component’s first parameter (the
{ a, b, c } props object). 0 for non-component functions and for
components taking a bare props identifier (not statically countable).
Descriptive context surfaced in the hotspot drill-down, never a tunable
threshold (anti-numerology).
source_hash: Option<String>Content digest of the function’s full-span source slice.
contributions: Vec<ComplexityContribution>Per-decision-point breakdown explaining WHICH constructs drove the
cyclomatic and cognitive scores. One entry per increment event (an if
emits one cyclomatic and one cognitive entry at the same line, because
the two metrics accrue at different granularities). Always computed and
cached; surfaced in JSON only behind health --complexity-breakdown.
Implementations§
Source§impl FunctionComplexity
impl FunctionComplexity
Sourcepub fn identity_name(&self) -> &str
pub fn identity_name(&self) -> &str
The name that coverage producers and runtime identities use: the
placeholder for a function with a context name, else name.