NPATH is a metric introduced by Brian A. Nejmeh in [13] that is aimed at overcoming some important limitations of McCabe's cyclomatic complexity. Despite the fact that the declared NPATH objective is to count the number of acyclic execution paths through a function, the definition given for the C language in [13] fails to do so even for very simple programs. We show that counting the number of acyclic paths in CFG is unfeasible in general. Then we define a new metric for C-like languages, called ACPATH, that allows to quickly compute a very good estimation of the number of acyclic execution paths through the given function. We show that, if the function body does not contain backward gotos and does not contain jumps into a loop from outside the loop, then such estimation is actually exact.
翻译:NPATH是由Brian A. Nejmeh在文献[13]中提出的一种指标,旨在克服McCabe循环复杂度的一些重要局限性。尽管NPATH的声明目标是统计函数中无环执行路径的数量,但文献[13]针对C语言给出的定义即使对非常简单的程序也无法实现这一目标。我们证明在控制流图中统计无环路径的数量通常是不可行的。随后我们为C类语言定义了一种新的指标——ACPATH,该指标能够快速计算出给定函数中无环执行路径数量的极优估计值。我们表明,若函数体不包含反向goto语句,也不包含从循环外部跳入循环的跳转,则此估计值实际上是精确的。