Skip to content

Case in switch should not increment nesting level #3

Open
@bkdotcom

Description

@bkdotcom

I don't know what this method's cognitive-complexity should be, but I know it shouldn't be 11

public function foo()
{
    $blah = array();
    for ($i = 0, $count = \count($this->things); $i < $count; $i++) {
        switch ($this->things[$i]['method']) {
            case 'foo':
            case 'bar':
                $blah[] = $i;
                break;
            case 'baz':
                \array_pop($blah);
                break;
            case 'ding':
            case 'dong':
                if ($this->something === false) {
                    break;
                }
                foreach ($blah as $i2) {
                    $this->things[$i2]['method'] = 'foo';
                }
                break;
        }
    }
}

9 maybe?
¯\_(ツ)_/¯

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions