Skip to content

Cognitive complexity calculation error #87

Open
@bkdotcom

Description

@bkdotcom

I apologize if this isn't the correct repo to report this

CodeClimate reports the Cognitive Complexity of the following function as 14
I believe the value should be 12

It seems that CodeClimate is incorrectly incrementing the continue statements

function testFunction($array)
{
    if (false) {
        return;
    }
    $file = '';
    $line = 0;
    if (false) {
        throw new \RuntimeException('false was true! ');
    }
    foreach ($array as $key => $val) {
        if (\is_int($key)) {
            continue;
        }
        if (\is_string($val)) {
            continue;
        }
        if (\is_array($val)) {
            foreach ($val as $val2) {
                // empty
            }
        }
    }
}

continue; should not increment

continue LABEL; should increment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions