I’m new here and can’t find another thread about this.
We use SonarQube to analyze our PHP project and the Cyclomatic Complexity rule does not seem to show the same results on our computer (with phpmessdetector) and on the Sonar reports.
It appears “elseif” statements are ignored, while “else if” statements (with a space) are correctly interpreted.
Hello Nicolas, welcome to the community, and thanks for bringing out this issue!
You’re right, the cyclomatic complexity rule (S1541) does not detect the elseif clauses. This is a bug in our analyzer. The fix should be part of one of the next SQS releases.
In the meantime, you might want to rely on the cognitive complexity rule (S3776). While it does not work exactly the same as cyclomatic complexity, it is our main rule for calculating “brain overload”, and does work properly with elseif clauses.
If you find any other bugs, please let us know! Thanks for your investment in our products
The Cyclomatic Complexity rule S1541 was updated to consider elseif clauses.
This is fixed on SonarQube Cloud and will be part of the next Community Build.