{"action":"created","issue":{"url":"https://api.github.com/repos/OpenCover/opencover/issues/716","repository_url":"https://api.github.com/repos/OpenCover/opencover","labels_url":"https://api.github.com/repos/OpenCover/opencover/issues/716/labels{/name}","comments_url":"https://api.github.com/repos/OpenCover/opencover/issues/716/comments","events_url":"https://api.github.com/repos/OpenCover/opencover/issues/716/events","html_url":"https://github.com/OpenCover/opencover/issues/716","id":230902498,"number":716,"title":"NPath complexity is a larger value than expected.","user":{"login":"jswolf19","id":519875,"avatar_url":"https://avatars3.githubusercontent.com/u/519875?v=3","gravatar_id":"","url":"https://api.github.com/users/jswolf19","html_url":"https://github.com/jswolf19","followers_url":"https://api.github.com/users/jswolf19/followers","following_url":"https://api.github.com/users/jswolf19/following{/other_user}","gists_url":"https://api.github.com/users/jswolf19/gists{/gist_id}","starred_url":"https://api.github.com/users/jswolf19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jswolf19/subscriptions","organizations_url":"https://api.github.com/users/jswolf19/orgs","repos_url":"https://api.github.com/users/jswolf19/repos","events_url":"https://api.github.com/users/jswolf19/events{/privacy}","received_events_url":"https://api.github.com/users/jswolf19/received_events","type":"User","site_admin":false},"labels":[{"id":1774539,"url":"https://api.github.com/repos/OpenCover/opencover/labels/low","name":"low","color":"DDDDDD","default":false},{"id":95387,"url":"https://api.github.com/repos/OpenCover/opencover/labels/support","name":"support","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2017-05-24T02:26:30Z","updated_at":"2017-06-01T12:19:43Z","closed_at":null,"body":"### My Framework\r\n\r\n- [ ] .NET 2\r\n- [ ] .NET 3.5\r\n- [ ] .NET 4\r\n- [X] .NET 4.5\r\n- [ ] .NET 4.6\r\n- [ ] .NET 4.6.1\r\n- [ ] .NET 4.6.2\r\n- [ ] .NET Core 1.0.0\r\n- [ ] Something else\r\n\r\n### My Environment\r\n\r\n- [X] Windows 7 or below (not truly supported due to EOL)\r\n- [ ] Windows 8\r\n- [ ] Windows 8.1\r\n- [ ] Windows 10\r\n- [ ] Windows 10 IoT Core\r\n- [ ] Windows Server 2012\r\n- [ ] Windows Server 2012 R2\r\n- [ ] Windows Server 2016\r\n\r\n### I have already...\r\n\r\n- [X] repeated the problem using the latest stable release of OpenCover.\r\n- [X] reviewed the [usage guide](https://github.com/opencover/opencover/wiki/usage) and [usage document](https://github.com/opencover/opencover/blob/master/main/OpenCover.Documentation/Usage.pdf).\r\n- [X] have looked at the opencover output xml file in an attempt to resolve the issue.\r\n- [X] reviewed the [current issues](https://github.com/opencover/opencover/issues) to check that the issue isn't already known.\r\n\r\n### My issue is related to (check only those which apply):\r\n\r\n- [ ] no coverage being recorded\r\n- [ ] 32 or 64 bit support\r\n- [ ] feature request\r\n\r\n### Expected Behavior\r\n\r\nAccording to the [original source](https://phpmd.org/rules/codesize.html#npathcomplexity),\r\n> The NPath complexity of a method is the number of acyclic execution paths through that method.\r\nThus, the following code should have 4 acyclic execution paths, for a nPath complexity of 4.\r\n\r\n```\r\n       public static string NPathResultShouldBe4(bool a, bool b, bool c)\r\n        {\r\n            if(a) \r\n            {\r\n                if(b)\r\n                {\r\n                    if(c)\r\n                    {\r\n                        return \"Path 1\";\r\n                    }\r\n                    return \"Path 2\";\r\n                }\r\n                return \"Path 3\";\r\n            }\r\n            return \"Path 4\";\r\n        }\r\n```\r\n\r\n### Actual Behavior\r\n\r\nThe nPathComplexity value in the resulting xml file is 8. It appears that nested BranchPoints are not properly handled.\r\n\r\n### Steps to reproduce the problem:\r\n\r\n1. build the attached project. (Having trouble attaching a zip file... For now I'll just attach the source file as \r\n[NPathResultTest.txt](https://github.com/OpenCover/opencover/files/1024278/NPathResultTest.txt)\r\n)\r\n2. run opencover configured with xunit as follows:\r\n`-register:Path32 -target:\"%PathToXUnit%\\xunit.console.clr4.exe\" -targetargs:\"nPathTests.dll\"`\r\n3. observe the method `nPathTests.NPathResultTest::NPathResultShouldBe4(...)` as an nPathComplexity attribute equal to 8."},"comment":{"url":"https://api.github.com/repos/OpenCover/opencover/issues/comments/305476797","html_url":"https://github.com/OpenCover/opencover/issues/716#issuecomment-305476797","issue_url":"https://api.github.com/repos/OpenCover/opencover/issues/716","id":305476797,"user":{"login":"jswolf19","id":519875,"avatar_url":"https://avatars3.githubusercontent.com/u/519875?v=3","gravatar_id":"","url":"https://api.github.com/users/jswolf19","html_url":"https://github.com/jswolf19","followers_url":"https://api.github.com/users/jswolf19/followers","following_url":"https://api.github.com/users/jswolf19/following{/other_user}","gists_url":"https://api.github.com/users/jswolf19/gists{/gist_id}","starred_url":"https://api.github.com/users/jswolf19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jswolf19/subscriptions","organizations_url":"https://api.github.com/users/jswolf19/orgs","repos_url":"https://api.github.com/users/jswolf19/repos","events_url":"https://api.github.com/users/jswolf19/events{/privacy}","received_events_url":"https://api.github.com/users/jswolf19/received_events","type":"User","site_admin":false},"created_at":"2017-06-01T12:19:43Z","updated_at":"2017-06-01T12:19:43Z","body":"I may not have spent enough time looking, but it looked like the offsetend in the report told you where the branch would jump to. If that's the case, one path will go to the next offset after the branch, and the other path would go to offsetend and continue from there. Thus, a nested branch would have an offset between the next offset and offsetend and would only be in one of the two paths.\r\n\r\nI haven't spent a lot of time looking though, so there may be some nesting that would be missed. If that's the case, then the question is what to do: leave it as it is, get rid of it, improve what you can easily, or try to make it perfect. I do think it can be improved some with the current information, but I'm not going to push the issue if you don't want make the change."}}
{"actor":{"display_login":"jswolf19"}}