object

# `halstead_metric(Stroud)`

- `Stroud` - Coefficient for computing the time required to program.

Computes Halstead complexity numbers for an entity.

Author: Paulo Moura
Version: 0:8:0
Date: 2022-05-05
Compilation flags:
`static, context_switching_calls`
Imports:
`public` code_metrics_utilities
`public` code_metric
Uses:
list
numberlist
pairs
Remarks:

> - Definition of operators: Predicates declared, user-defined, and called are interpreted as operators. Built-in predicates and built-in control constructs are ignored.

> - Definition of operands: Predicate arguments are abstracted and interpreted as operands. Note that this definition of operands is a significant deviation from the original definition, which used syntactic literals.

> - Pn: Number of distinct predicates (declared, defined, called, or updated).

> - PAn: Number of predicate arguments (assumed distinct).

> - Cn: Number of predicate calls/updates + number of clauses.

> - CAn: Number of predicate call/update arguments + number of clause head arguments.

> - EV: Entity vocabulary: `EV = Pn + PAn`.

> - EL: Entity length: `EL = Cn + CAn`.

> - V: Volume: `V = EL * log2(EV)`.

> - D: Difficulty: `D = (Pn/2) * (CAn/An)`.

> - E: Effort: `E = D * V`.

> - T: Time required to program: `T = E/k` seconds (`k` is the Stroud number; defaults to 18).

> - B: Number of delivered bugs: `B = V/3000`.

> - Entity score: Represented as the compound term `pn_pan_cn_can_ev_el_v_d_e_t_b/11`.

Inherited public predicates:
all/0 all_score/1 directory/1 directory_score/2 entity/1 entity_score/2 file/1 file_score/2 format_entity_score//2 library/1 library_score/2 rdirectory/1 rdirectory_score/2 rlibrary/1 rlibrary_score/2

## Public predicates

(no local declarations; see entity ancestors if any)

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

(no local declarations; see entity ancestors if any)

## Operators

(none)