Class ConstructMetrics

java.lang.Object
org.ek9lang.compiler.phase7.generator.ConstructMetrics

public final class ConstructMetrics extends Object
THE resolver of phase-5 quality metrics for one operation, for every IR generator that registers a function entry with CoverageProbePlacer. Call this; do not re-derive the lookup, and do not pass FunctionMetrics.EMPTY as a placeholder.

Sibling to CoverageDisplayName, and used by exactly the same set of generators — OperationDfnGenerator, AggregateDfnGenerator, ServiceDfnGenerator, TextDfnGenerator. It exists because three of those four passed EMPTY, so every method and operator of every class, record, trait, component, service and text construct reported zero for all metrics — complexity, cognitive, nesting, statements, expressions, injections and coupling alike. Only free functions, which go through OperationDfnGenerator, ever carried real numbers. Any per-construct quality signal built on that data would have read every aggregate member as trivial and perfectly safe.

Two lookup rules, and they differ deliberately:

  • Body metrics (complexity, cognitive, nesting, statements, expressions, injections) are the operation's own, falling back to the enclosing scope only when the operation carries none at all — the synthetic-method case, where phase 5 measured the declaration rather than the generated _call.
  • Coupling is always inherited from the enclosing type, because efferent coupling is a property of the construct, not of an operation within it. Phase 5 chains its coupling check onto construct declarations only — never onto a method or operator — so an operation's own symbol never carries it. Every method of a twelve-dependency class is risky to change because the class is entangled; that is the sense in which coupling is change risk.
  • Defaulted is provenance rather than a metric, read straight off the phase-1 DEFAULTED marker. It travels with the metrics because the consumer that needs it (change-risk ranking) has only this record to go on, and the alternative — inferring "the compiler wrote this" from zero body metrics — is wrong for every trivial hand-written method.
  • Method Details

    • forSymbol

      public static FunctionMetrics forSymbol(ISymbol symbol)
      Resolve every phase-5 metric for one operation.
      Parameters:
      symbol - the operation's symbol
      Returns:
      its metrics, or FunctionMetrics.EMPTY when phase 5 recorded nothing for it