HalsteadMetrics class

Halstead software science metrics.

Measures program complexity by analyzing operators and operands:

  • Operators: Keywords, punctuation, arithmetic/logical operators
  • Operands: Variables, literals, identifiers

Key derived metrics:

  • volume: Information content of the code
  • difficulty: How hard the code is to write/understand
  • effort: Mental effort required to develop

Reference: Maurice Halstead, "Elements of Software Science" (1977)

Constructors

HalsteadMetrics({required int n1, required int n2, required int operatorTotal, required int operandTotal})
const

Properties

bugs double
Estimated bugs: B = V / 3000
no setter
difficulty double
Difficulty: D = (n₁/2) × (N₂/n₂)
no setter
effort double
Effort: E = D × V
no setter
hashCode int
The hash code for this object.
no setterinherited
length int
Program length: N = N₁ + N₂
no setter
n1 int
Unique operators count (n₁).
final
n2 int
Unique operands count (n₂).
final
operandTotal int
Total operands count (N₂).
final
operatorTotal int
Total operators count (N₁).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
time double
Estimated time to program (seconds): T = E / 18
no setter
vocabulary int
Program vocabulary: n = n₁ + n₂
no setter
volume double
Halstead volume: V = N × log₂(n)
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited