What mehen emits
Definitions
The classical Halstead derived quantities follow:
18 in the time formula is Halstead’s “Stroud number” — the number of mental
discriminations per second a programmer is assumed to make.
Per-language operator/operand split
What counts as an operator vs. an operand is language-specific. mehen’s analyzers follow the prevailing convention:- Operators: keywords (
if,for,return, …), arithmetic and logical symbols (+,&&, …), parentheses pair(), brackets[], and assignment operators. - Operands: identifiers, literal values (numbers, strings, booleans, null/undefined), and type names.
crates/mehen-<lang>/.
How to read it
halstead.bugs and halstead.time are rough estimates with limited empirical backing. Treat them as
order-of-magnitude signals, not promises.
References
- Halstead, M. H. (1977). Elements of Software Science. Operating and Programming Systems Series. Elsevier. OSTI record.
- Kearney, J. K., et al. Software Complexity Measurement — MIT lecture notes that summarize the Halstead operator/operand formulation alongside McCabe. PDF (MIT OCW 16.355).
- Christensen, K., Fitsos, G. P. & Smith, C. P. (1981). A perspective on software science. IBM Systems Journal 20(4): 372–387. DOI.
- Sonar: Halstead in the metrics definitions.
- Radon: Halstead — Python reference implementation of the formulas.
See also
- Maintainability Index — uses Halstead volume.
- Cyclomatic complexity — control-flow complexity.
- Cognitive complexity — readability complexity.