{"action":"opened","issue":{"url":"https://api.github.com/repos/phpmd/phpmd/issues/282","labels_url":"https://api.github.com/repos/phpmd/phpmd/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/phpmd/phpmd/issues/282/comments","events_url":"https://api.github.com/repos/phpmd/phpmd/issues/282/events","html_url":"https://github.com/phpmd/phpmd/issues/282","id":76961867,"number":282,"title":"NPath complexity are increased after \"else\" branch was removed and \"return\" statement was added","user":{"login":"EvgenyUnvsoft","id":6170386,"avatar_url":"https://avatars.githubusercontent.com/u/6170386?v=3","gravatar_id":"","url":"https://api.github.com/users/EvgenyUnvsoft","html_url":"https://github.com/EvgenyUnvsoft","followers_url":"https://api.github.com/users/EvgenyUnvsoft/followers","following_url":"https://api.github.com/users/EvgenyUnvsoft/following{/other_user}","gists_url":"https://api.github.com/users/EvgenyUnvsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/EvgenyUnvsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EvgenyUnvsoft/subscriptions","organizations_url":"https://api.github.com/users/EvgenyUnvsoft/orgs","repos_url":"https://api.github.com/users/EvgenyUnvsoft/repos","events_url":"https://api.github.com/users/EvgenyUnvsoft/events{/privacy}","received_events_url":"https://api.github.com/users/EvgenyUnvsoft/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-16T06:34:04Z","updated_at":"2015-05-16T06:34:04Z","closed_at":null,"body":"First example\r\n\r\n```\r\nfunction Test($a, $b)\r\n{\r\n    if ($a > $b) {\r\n        $result = $a;\r\n    } else {\r\n        if ($a > 5) {\r\n            $result = 6;\r\n        } else {\r\n            $result = 4\r\n        }\r\n    }\r\n\r\n    return $result;\r\n}\r\n```\r\n\r\nFor this function PHPMD return NPath complexity 3.\r\n\r\n\r\nMake some changes - remove \"else\" branches and add return statement to the if branches.\r\n\r\n```\r\nfunction Test($a, $b)\r\n{\r\n    if ($a > $b) {\r\n        $result = $a;\r\n\r\n        return $result;\r\n    }\r\n\r\n    if ($a > 5) {\r\n        $result = 6;\r\n\r\n        return $result;\r\n    }\r\n\r\n    $result = 4\r\n\r\n    return $result;\r\n}\r\n```\r\n\r\nFor this function PHPMD return NPath complexity 4.\r\n\r\nWhy NPath complexity increased?\r\n"}}