PHPStorm not showing Cyclomatic complexity with PHPMD

Hello,

 

I have installed PHPMD globally through composer and configured PHPMD under Settings > Inspections > PHP > PHP Mess Detector Validation

 

There I have selected all optionsm including the 'Code Size Rules'. According to the documentation this code rule should also enable the Cyclomatic Complexity validation.

https://phpmd.org/rules/index.html#code-size-rules

The strange thing is that all the other rules are in effect though.

Could really use some help with this.

The path I am using for Mess detector:

/home/<user>/.composer/vendor/phpmd/phpmd/src/bin/phpmd

Running on ubuntu 16.04

 

 

 

3 comments

What code sample are you using?
I've tried with a default one from here, and it seems to work (Ubuntu 16.04, global PHPMD 2.5.0 installed with Composer):

<?php

// Cyclomatic Complexity = 11

function fiddle() {}
class Foo {

public function example() {
$a = 1;
$b = 2;
if ($a == $b) {
if ($a == $b) {
fiddle();
} elseif ($a == $b) {
fiddle();
} else {
fiddle();
}
} elseif ($a == $b) {
while ($a == $b) {
fiddle();
}
} elseif ($a == $b) {
for ($n = 0; $n < $b; $n++) {
fiddle();
}
} else {
switch ($a) {
case 1:
fiddle();
break;
case 2:
fiddle();
break;
case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
0

I tried it with your example, while I was fidgeting around with it my cyclomatic complexity showed up. It took a really long time though. So I guess the problem is that whenever I open a file it takes a long to for the CCN to show up. Could anything be done about that? 

0

You can run Code > Inspect Code & select an Inspection profile you've configured. How long would it take to pass?

0

Please sign in to leave a comment.