McCabe's cyclomatic complexity


McCabe’s cyclomatic complexity

– first “distill” the sole PHP code, dropping everything outside ‘php’ tags (that is HTML and Javascript), comments, strings, etc.,
– then find the functions inside, and compute the McCabe’s cyclomatic complexity for each one. The code outside any function will account for a virtual main function, and will always be present;
– an indented version of the input code (sole PHP code) will be output, hilighting the lines that contribute to increase complexity: this can help you to refactor your code and split it into smaller functions, whose single complexity is smaller.

Related Posts