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

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy