phpcheckstyle icon indicating copy to clipboard operation
phpcheckstyle copied to clipboard

Check the NPath calculation

Open tchule opened this issue 11 years ago • 5 comments

See http://codingswag.ghost.io/cyclomatic-and-npath-complexity-explained/.

We should add some test cases for this calculation.

tchule avatar Sep 03 '14 09:09 tchule

NPath is now included already. I'm not sure if it's 100% correct, but it's in. See #28 and #29

jbrooksuk avatar Sep 03 '14 10:09 jbrooksuk

I believe that NPath actually needs to consider ternary statements too, so this will need adding.

jbrooksuk avatar Sep 08 '14 07:09 jbrooksuk

I still have a doubt about this one, I think we need to multiply the _npathComplexity for each statement of the function (that's the difference with the cyclomatic). We should find some reference or some result to compare on a given test case.

tchule avatar Oct 28 '14 15:10 tchule

Ok, I've re-opened for now then.

jbrooksuk avatar Oct 28 '14 15:10 jbrooksuk

See https://modess.io/npath-complexity-cyclomatic-complexity-explained/

What we should do :

  • Consider the number of paths inside a context (use the statementStack)
  • Start at 1 as the default value for the number of paths
  • Add 1 when we encounter an ELSE, ELSEIF, CASE (after the first), ...
  • When going down a nesting level (closing a IF statement for exemple), multiply the number of paths of the current context by the number of paths we just closed.

tchule avatar Feb 10 '17 14:02 tchule