{"action":"created","issue":{"url":"https://api.github.com/repos/wenns/sonar-cxx/issues/608","labels_url":"https://api.github.com/repos/wenns/sonar-cxx/issues/608/labels{/name}","comments_url":"https://api.github.com/repos/wenns/sonar-cxx/issues/608/comments","events_url":"https://api.github.com/repos/wenns/sonar-cxx/issues/608/events","html_url":"https://github.com/wenns/sonar-cxx/issues/608","id":99403346,"number":608,"title":"Complexity of a function","user":{"login":"schiean","id":243306,"avatar_url":"https://avatars.githubusercontent.com/u/243306?v=3","gravatar_id":"","url":"https://api.github.com/users/schiean","html_url":"https://github.com/schiean","followers_url":"https://api.github.com/users/schiean/followers","following_url":"https://api.github.com/users/schiean/following{/other_user}","gists_url":"https://api.github.com/users/schiean/gists{/gist_id}","starred_url":"https://api.github.com/users/schiean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schiean/subscriptions","organizations_url":"https://api.github.com/users/schiean/orgs","repos_url":"https://api.github.com/users/schiean/repos","events_url":"https://api.github.com/users/schiean/events{/privacy}","received_events_url":"https://api.github.com/users/schiean/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/wenns/sonar-cxx/labels/discussion","name":"discussion","color":"eb6420"},{"url":"https://api.github.com/repos/wenns/sonar-cxx/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"guwirth","id":6077367,"avatar_url":"https://avatars.githubusercontent.com/u/6077367?v=3","gravatar_id":"","url":"https://api.github.com/users/guwirth","html_url":"https://github.com/guwirth","followers_url":"https://api.github.com/users/guwirth/followers","following_url":"https://api.github.com/users/guwirth/following{/other_user}","gists_url":"https://api.github.com/users/guwirth/gists{/gist_id}","starred_url":"https://api.github.com/users/guwirth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guwirth/subscriptions","organizations_url":"https://api.github.com/users/guwirth/orgs","repos_url":"https://api.github.com/users/guwirth/repos","events_url":"https://api.github.com/users/guwirth/events{/privacy}","received_events_url":"https://api.github.com/users/guwirth/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/wenns/sonar-cxx/milestones/5","html_url":"https://github.com/wenns/sonar-cxx/milestones/M%200.9.4","labels_url":"https://api.github.com/repos/wenns/sonar-cxx/milestones/5/labels","id":1072549,"number":5,"title":"M 0.9.4","description":"Release with SQ 5.2 compatibility (https://jira.sonarsource.com/projects/SONAR?selectedItem=com.atlassian.jira.jira-projects-plugin:release-page)","creator":{"login":"guwirth","id":6077367,"avatar_url":"https://avatars.githubusercontent.com/u/6077367?v=3","gravatar_id":"","url":"https://api.github.com/users/guwirth","html_url":"https://github.com/guwirth","followers_url":"https://api.github.com/users/guwirth/followers","following_url":"https://api.github.com/users/guwirth/following{/other_user}","gists_url":"https://api.github.com/users/guwirth/gists{/gist_id}","starred_url":"https://api.github.com/users/guwirth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guwirth/subscriptions","organizations_url":"https://api.github.com/users/guwirth/orgs","repos_url":"https://api.github.com/users/guwirth/repos","events_url":"https://api.github.com/users/guwirth/events{/privacy}","received_events_url":"https://api.github.com/users/guwirth/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":110,"state":"open","created_at":"2015-04-17T17:34:43Z","updated_at":"2015-10-10T16:11:58Z","due_on":"2015-10-29T23:00:00Z","closed_at":null},"comments":8,"created_at":"2015-08-06T10:16:00Z","updated_at":"2015-10-10T16:11:58Z","closed_at":"2015-10-10T16:11:58Z","body":"Hi,\r\n\r\nI was looking at FunctionComplexityCheckTest which asserts the complexity of certain cpp code.\r\nHowever the score for this code is 8:\r\n\r\n```C++\r\nint func3(int a, int b) {        // +1\r\n   if( a ) {                            // +1                                  2\r\n      if( b ) {                         // +1                                  3\r\n         return a+b ? 1 : 2;   // +1(return)  +1 (short if)   5 \r\n      } else {\r\n         return a+b ? 3 : 4;   // +1  +1                             7 \r\n      }\r\n   } else {\r\n      if( b ) {                       // +1                                   8\r\n         return a+b ? 5 : 6;  // +1  +1                             10\r\n      } else {\r\n         return a+b ? 7 : 8;  // +1  +1                              12\r\n      }\r\n   }\r\n}\r\n```\r\n\r\non this page http://docs.sonarqube.org/display/SONAR/Metrics+-+Complexity\r\nwe see how the complexity can be calculated.\r\nIn java the above example scores 12 (after making the ints into booleans because java does not allow if(int))\r\n\r\nIn CXX this scores 8.\r\nIs there a reason for this ?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/wenns/sonar-cxx/issues/comments/147102716","html_url":"https://github.com/wenns/sonar-cxx/issues/608#issuecomment-147102716","issue_url":"https://api.github.com/repos/wenns/sonar-cxx/issues/608","id":147102716,"user":{"login":"guwirth","id":6077367,"avatar_url":"https://avatars.githubusercontent.com/u/6077367?v=3","gravatar_id":"","url":"https://api.github.com/users/guwirth","html_url":"https://github.com/guwirth","followers_url":"https://api.github.com/users/guwirth/followers","following_url":"https://api.github.com/users/guwirth/following{/other_user}","gists_url":"https://api.github.com/users/guwirth/gists{/gist_id}","starred_url":"https://api.github.com/users/guwirth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guwirth/subscriptions","organizations_url":"https://api.github.com/users/guwirth/orgs","repos_url":"https://api.github.com/users/guwirth/repos","events_url":"https://api.github.com/users/guwirth/events{/privacy}","received_events_url":"https://api.github.com/users/guwirth/received_events","type":"User","site_admin":false},"created_at":"2015-10-10T16:11:58Z","updated_at":"2015-10-10T16:11:58Z","body":"I'm closing this issue. Please re-open if still a problem. "}}