Module Metrics_base.BasicMetrics

module BasicMetrics: sig .. end

Defining base metrics and operations on those


type t = {
   cfile_name : string; (*

Filename

*)
   cfunc_name : string; (*

Function name if applicable, eg. not for global metrics

*)
   cslocs : int; (*

Lines of code w.r.t. statements

*)
   cifs : int; (*

If / cases of switch

*)
   cloops : int; (*

Loops: for, while, do...while

*)
   ccalls : int; (*

Function calls

*)
   cgotos : int; (*

Gotos

*)
   cassigns : int; (*

Assignments

*)
   cexits : int; (*

Exit points: return

*)
   cfuncs : int; (*

Functions defined: 1 in the case of a single function, possibly more for a file.

*)
   cptrs : int; (*

Access to pointers

*)
   cdecision_points : int; (*

Decision points of the program: ifs, switch cases, exception handlers, ...

*)
   cglob_vars : int; (*

Global variables

*)
   ccyclo : int; (*

Cyclomatic complexity

*)
}

Simple type of metrics.

val incr_funcs : t -> t

Helpers for metrics purposes for single increment steps

val incr_slocs : t -> t
val incr_ptrs : t -> t
val incr_ifs : t -> t
val incr_dpoints : t -> t
val incr_loops : t -> t
val incr_gotos : t -> t
val incr_exits : t -> t
val incr_assigns : t -> t
val incr_calls : t -> t
val incr_glob_vars : t -> t
val set_cyclo : t -> int -> t
val apply_then_set : (t -> t) ->
t Pervasives.ref -> unit

Update a reference from a pure functional function. Used in particular in combination with helper functions above.

val empty_metrics : t

Initial empty values for metrics computing.

val compute_cyclo : t -> int

Compute cyclomatic complexity from base_metrics record type.

val to_list : t -> string list list

Matrix-like representation of the record in "Title: value" style

val pp_base_metrics : Format.formatter -> t -> unit

Pretty printers for base metrics as text or html.

val pp_base_metrics_as_html_row : Format.formatter -> t -> unit