scitools.com

← Metric catalog

Paths is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.

Paths

API ID: CountPath
Also Known As: NPATH
Languages: Ada, Basic, C#, C++, Fortran, Java, Jovial, Pascal, Python, Rust, Web
Targets: Files, Functions, Modules, Packages, Subprograms

Number of unique paths through a body of code, not counting abnormal exits or gotos.

For example:


void pathDemo() {
  if (a)
    dothis();
  if (b)
    dothat();
}

The two if statements are independent, and each has 2 outcomes (taken or not), so there are 2 × 2 = 4 possible paths through the function: (a, b), (a, not b), (not a, b), and (not a, not b). That gives pathDemo a Paths count of 4.

Path counts are capped at 999,999,999 — functions with more paths than that all report the same maximum value. See Paths Log(x) for a version of this value that isn't capped the same way, and scales better for functions with many paths.

Also known as NPATH.

Introduced by Nejmeh, Brian A. "NPATH: A Measure of Execution Path Complexity and Its Applications." Communications of the ACM, vol. 31, no. 2, 1988, pp. 188-200.


Targets By Language: Configuration: