From da1921b4d005b2cdcf26ad49ada050123fd54b22 Mon Sep 17 00:00:00 2001
From: Roman Ivanov
+ The NPATH metric was designed base on Cyclomatic complexity to
+ avoid problem of Cyclomatic complexity metric like nesting level within a function.
+
+ Metic wsa described at "NPATH: a measure of execution path complexity and its applications". If you need detaled description of algorithm, please read that article, + it well written and have number of examples and details.
+Here is some quotes:
+ +An NPATH threshold value of 200 has been established + for a function. The value 200 is based on studies done + at AT&T Bell Laboratories [1988 year]. ++ +
+ Some of the most effective methods of reducing the NPATH value include+ +
+ - distributing functionality,
+ - implementing multiple if statements as a switch statement
+ - creating a separate function for logical expressions with a high count of and (&&) and or (||) operators. +
+ Although strategies to reduce the NPATH complexity + of functions are important, care must be taken not to + distort the logical clarity of the software by applying a + strategy to reduce the complexity of functions. That is, + there is a point of diminishing return beyond which a + further attempt at reduction of complexity distorts the + logical clarity of the system structure. ++ +
| Structure | Complexity expression |
|---|---|
| if | NP((if-range))+NP((expr))+1 |
| if-else | NP((if-range))+NP((else-range))+NP((expr)) |
| while | NP((while-range))+NP((expr))+1 |
| do while | NP((do-range))+NP((expr))+1 |
| for | NP((for-range))+NP((exprl))+NP((expr2))+NP((expr3))+1 |
| switch | NP((expr))+ S(i=1:i=n)NP((case-range(i)))+ NP((default-range)) |
| ? | NP((exprl))+NP((expr2))+NP((expr3))+2 |
| goto label | 1 |
| break | 1 |
| Expressions | Number of && and || operators in expression |
| continue | 1 |
| return | 1 |
| sequential | 1 |
| Function call | 1 |
| C function | P(i=1:i=N) NP(Statement(i)) |
- Rationale: Nejmeh says that his group had an informal NPATH + Rationale: Nejmeh says that his group had an informal NPATH limit of 200 on individual routines; functions that exceeded this value were candidates for further decomposition - or at - least a closer look. + least a closer look. + Please do not be fanatic with limit 200 + - choose number that suites your project style. Limit 200 is + empirical number base on some sources of at AT&T Bell Laboratories + of 1988 year.
@@ -452,11 +507,11 @@ class CC {- To configure the check with a threshold of 20: + To configure the check with a threshold of 1000: