Skip to content

tochilinak/ocaml_metrics

Repository files navigation

Ocaml metrics

Run tool:

ocaml_metrics <DIR> [-met-list <M1>,<M2>,<M3>] [-sec-list <L1>,<L2>,<L3>] [-v-list <V1>,<V2>,<V3>]

<DIR> - directory with dune-based project

-met-list <M1>,<M2>,<M3> - metrics to show (metrics is shown if it contains a substring from this list)

-sec-list <L1>,<L2>,<L3> - dune libraries and executables from project to analyze

-v-list <V1>,<V2>,<V3> - print verbose output of metrics groups from this list

Metrics names are printed in the following format: [metrics group id]_[metrics id].

Metrics group id Description Metrics id Description
cohesion Class cohesion metrics
Alternative to class is a module.
Alternative to both attributes and methods are functions.
"Methods share attributes" -> "Functions call the same function or one of them calls the other"
LCOM1 Original definition: Number of pairs of methods that do not share attributes
LCOM2 Original definition:
P = Number of pairs of methods that do not share attributes
Q = Number of pairs of methods that share attributes
LCOM2 = max(P - Q, 0)
LCOM34 LCOM3 = Number of disjoint components in the graph that represents each method as a node and the sharing of at least one attribute as an edge
LCOM4 = Similar to LCOM3 and additional edges are used to represent method invocations
In our interpretation LCOM3 and LCOM4 give the same values.
LCOM5 Original definition: , where is the number of attributes, is the number of methods, and is the summation of the number of distinct attributes accessed by each method in a class
Our interpretation: Instead of we use maximum possible number of edges in graph where nodes are functions and edges are used to represent one function calling another.
When denominator is >= 0, LCOM5 is -1.
COH Original definition: , where , , and have the same definitions as above
Our interpretation: Like in LCOM5.
coupling Coupling metrics
Note: Fan-in, Fan-out and APIU are calculated only for public modules;
EXT is calculated for both modules and functions.
Fan-in Number of modules that depend on given module
Fan-out Numbers of modules that the given module depends on
APIU API Function Usage Index.
Suppose that module has public functions, in project other modules call one or more function from .
or 0 if
EXT External method calls.
Number of external functions called by a function or a module (only functions defined in the project are considered).
AC Association-Induced Coupling Metrics.
M = modules in project;
Mod_ext(m) = modules that have functions that use functions from m;
F = functions in project;
F(m) = functions in module m;
Func_ext(m) = functions that use functions from m;
Func_int(m) = functions in m that use functions from other modules in M;



CC-based McCabe's cyclomatic complexity based
Read more about CC: https://en.wikipedia.org/wiki/Cyclomatic_complexity
ord Traditional cyclomatic complexity
rec CC-ord + [Number of recursive calls]
mod Modified cyclomatic complexity.
Like CC-ord but count
match E0 with | P1 -> E1 ... | PN -> EN
as 1 decision point instead of (N - 1) (but still count guards).
mod-ord-max Maximum of CC-based_ord in module
mod-ord-avg Average of CC-based_ord in module
Halstead Halstead complexity measures
n1 = the number of distinct operators
n2 = the number of distinct operands
N1 = the total number of operators
N2 = the total number of operands
n Program vocabulary: n1 + n2
N Program length: N1 + N2
V Volume: N * log2(n)
D Difficulty: (n1 / 2) * (N2 / n2)
E Effort: V * D
LOC-based Lines of code
all Number of lines in function
code Exclude comment and blank lines

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published