The Pear CodeSniffer seems to come with a Cyclomatic Complexity Sniff (CyclomaticComplexitySniff.php). Does anyone know how to use it? I'd like to calculate the complexity of the code I'm analyzing. I'd like to use the Zend coding standard, but no matter what standard I use though, I don't see complexity information being output.
If anyone has advice regarding this, please let me know.
Thanks.
I have managed to make it work by using the following command:
phpcs <dir|file> -p -s
--sniffs=Generic.Metrics.CyclomaticComplexity --standard=Squiz
If you want to see the cyclomatic complexity for all functions instead of only the ones that exceed the default threshold, you have to set the value for complexity to 0 in the file "PEAR\PHP\CodeSniffer\Standards\Squiz\ruleset.xml":
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="0"/>