{"action":"created","comment":{"url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/comments/45997349","id":45997349,"diff_hunk":"@@ -44,26 +47,42 @@\n   @Override\n   public void visitIfStatement(IfStatementTree tree) {\n     if (tree.elseClause() == null) {\n-      StatementTree innerStatement = tree.statement();\n+      IfStatementTree innerIfStatement = getCollapsibleIfStatement(tree.statement());\n \n-      if (isBlockAndContainsOnlyOneIfStatement(innerStatement) || isIfStatementWithoutElse(innerStatement)) {\n-        getContext().addIssue(this, tree, \"Merge this if statement with the nested one.\");\n+      if (innerIfStatement != null) {\n+        IssueLocation primaryLocation = new IssueLocation(tree, \"Merge this if statement with the nested one.\");\n+        primaryLocation.lastTree(tree.closeParenthesis());\n+        IssueLocation secondaryLocation = new IssueLocation(innerIfStatement, \"Nested \\\"if\\\" statement\\n\");\n+        secondaryLocation.lastTree(innerIfStatement.closeParenthesis());\n+        getContext().addIssue(this, primaryLocation, Collections.singletonList(secondaryLocation), null);\n       }\n     }\n+\n     super.visitIfStatement(tree);\n   }\n \n-  private static boolean isBlockAndContainsOnlyOneIfStatement(StatementTree statement) {\n-    if (!statement.is(Kind.BLOCK)) {\n-      return false;\n+  @Nullable\n+  private IfStatementTree getCollapsibleIfStatement(StatementTree statement) {","path":"javascript-checks/src/main/java/org/sonar/javascript/checks/CollapsibleIfStatementsCheck.java","position":42,"original_position":42,"commit_id":"aa2dcdd45e49c33ef98f6b0502e3f0061fb69b4e","original_commit_id":"aa2dcdd45e49c33ef98f6b0502e3f0061fb69b4e","user":{"login":"SonarTech","id":1842438,"avatar_url":"https://avatars.githubusercontent.com/u/1842438?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarTech","html_url":"https://github.com/SonarTech","followers_url":"https://api.github.com/users/SonarTech/followers","following_url":"https://api.github.com/users/SonarTech/following{/other_user}","gists_url":"https://api.github.com/users/SonarTech/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarTech/subscriptions","organizations_url":"https://api.github.com/users/SonarTech/orgs","repos_url":"https://api.github.com/users/SonarTech/repos","events_url":"https://api.github.com/users/SonarTech/events{/privacy}","received_events_url":"https://api.github.com/users/SonarTech/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Make \"getCollapsibleIfStatement\" a \"static\" method. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://dory.sonarsource.com/coding_rules#rule_key=squid%3AS2325)\n","created_at":"2015-11-26T17:11:56Z","updated_at":"2015-11-26T17:11:56Z","html_url":"https://github.com/SonarCommunity/sonar-javascript/pull/126#discussion_r45997349","pull_request_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/126","_links":{"self":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/comments/45997349"},"html":{"href":"https://github.com/SonarCommunity/sonar-javascript/pull/126#discussion_r45997349"},"pull_request":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/126"}}},"pull_request":{"url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/126","id":51933569,"html_url":"https://github.com/SonarCommunity/sonar-javascript/pull/126","diff_url":"https://github.com/SonarCommunity/sonar-javascript/pull/126.diff","patch_url":"https://github.com/SonarCommunity/sonar-javascript/pull/126.patch","issue_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues/126","number":126,"state":"open","locked":false,"title":"SONARJS-567 Improve issue location for CollapsibleIfStatementsCheck","user":{"login":"vilchik-elena","id":10108186,"avatar_url":"https://avatars.githubusercontent.com/u/10108186?v=3","gravatar_id":"","url":"https://api.github.com/users/vilchik-elena","html_url":"https://github.com/vilchik-elena","followers_url":"https://api.github.com/users/vilchik-elena/followers","following_url":"https://api.github.com/users/vilchik-elena/following{/other_user}","gists_url":"https://api.github.com/users/vilchik-elena/gists{/gist_id}","starred_url":"https://api.github.com/users/vilchik-elena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vilchik-elena/subscriptions","organizations_url":"https://api.github.com/users/vilchik-elena/orgs","repos_url":"https://api.github.com/users/vilchik-elena/repos","events_url":"https://api.github.com/users/vilchik-elena/events{/privacy}","received_events_url":"https://api.github.com/users/vilchik-elena/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-26T17:02:15Z","updated_at":"2015-11-26T17:11:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3884296fce4456fde991b8981c5e088fc70398f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/126/commits","review_comments_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/126/comments","review_comment_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues/126/comments","statuses_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/statuses/aa2dcdd45e49c33ef98f6b0502e3f0061fb69b4e","head":{"label":"SonarCommunity:SONARJS-567","ref":"SONARJS-567","sha":"aa2dcdd45e49c33ef98f6b0502e3f0061fb69b4e","user":{"login":"SonarCommunity","id":1303819,"avatar_url":"https://avatars.githubusercontent.com/u/1303819?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarCommunity","html_url":"https://github.com/SonarCommunity","followers_url":"https://api.github.com/users/SonarCommunity/followers","following_url":"https://api.github.com/users/SonarCommunity/following{/other_user}","gists_url":"https://api.github.com/users/SonarCommunity/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarCommunity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarCommunity/subscriptions","organizations_url":"https://api.github.com/users/SonarCommunity/orgs","repos_url":"https://api.github.com/users/SonarCommunity/repos","events_url":"https://api.github.com/users/SonarCommunity/events{/privacy}","received_events_url":"https://api.github.com/users/SonarCommunity/received_events","type":"Organization","site_admin":false},"repo":{"id":4335519,"name":"sonar-javascript","full_name":"SonarCommunity/sonar-javascript","owner":{"login":"SonarCommunity","id":1303819,"avatar_url":"https://avatars.githubusercontent.com/u/1303819?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarCommunity","html_url":"https://github.com/SonarCommunity","followers_url":"https://api.github.com/users/SonarCommunity/followers","following_url":"https://api.github.com/users/SonarCommunity/following{/other_user}","gists_url":"https://api.github.com/users/SonarCommunity/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarCommunity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarCommunity/subscriptions","organizations_url":"https://api.github.com/users/SonarCommunity/orgs","repos_url":"https://api.github.com/users/SonarCommunity/repos","events_url":"https://api.github.com/users/SonarCommunity/events{/privacy}","received_events_url":"https://api.github.com/users/SonarCommunity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarCommunity/sonar-javascript","description":"","fork":false,"url":"https://api.github.com/repos/SonarCommunity/sonar-javascript","forks_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/forks","keys_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/teams","hooks_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/hooks","issue_events_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues/events{/number}","events_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/events","assignees_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/assignees{/user}","branches_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/branches{/branch}","tags_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/tags","blobs_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/languages","stargazers_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/stargazers","contributors_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/contributors","subscribers_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/subscribers","subscription_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/subscription","commits_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/contents/{+path}","compare_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/merges","archive_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/downloads","issues_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues{/number}","pulls_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/labels{/name}","releases_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/releases{/id}","created_at":"2012-05-15T12:35:38Z","updated_at":"2015-11-23T07:59:52Z","pushed_at":"2015-11-26T17:02:16Z","git_url":"git://github.com/SonarCommunity/sonar-javascript.git","ssh_url":"git@github.com:SonarCommunity/sonar-javascript.git","clone_url":"https://github.com/SonarCommunity/sonar-javascript.git","svn_url":"https://github.com/SonarCommunity/sonar-javascript","homepage":"http://docs.codehaus.org/display/SONAR/JavaScript+Plugin","size":7527,"stargazers_count":60,"watchers_count":60,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":52,"mirror_url":null,"open_issues_count":6,"forks":52,"open_issues":6,"watchers":60,"default_branch":"master"}},"base":{"label":"SonarCommunity:master","ref":"master","sha":"52189cf8ced883102aab0c23e53710bf55cf01e3","user":{"login":"SonarCommunity","id":1303819,"avatar_url":"https://avatars.githubusercontent.com/u/1303819?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarCommunity","html_url":"https://github.com/SonarCommunity","followers_url":"https://api.github.com/users/SonarCommunity/followers","following_url":"https://api.github.com/users/SonarCommunity/following{/other_user}","gists_url":"https://api.github.com/users/SonarCommunity/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarCommunity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarCommunity/subscriptions","organizations_url":"https://api.github.com/users/SonarCommunity/orgs","repos_url":"https://api.github.com/users/SonarCommunity/repos","events_url":"https://api.github.com/users/SonarCommunity/events{/privacy}","received_events_url":"https://api.github.com/users/SonarCommunity/received_events","type":"Organization","site_admin":false},"repo":{"id":4335519,"name":"sonar-javascript","full_name":"SonarCommunity/sonar-javascript","owner":{"login":"SonarCommunity","id":1303819,"avatar_url":"https://avatars.githubusercontent.com/u/1303819?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarCommunity","html_url":"https://github.com/SonarCommunity","followers_url":"https://api.github.com/users/SonarCommunity/followers","following_url":"https://api.github.com/users/SonarCommunity/following{/other_user}","gists_url":"https://api.github.com/users/SonarCommunity/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarCommunity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarCommunity/subscriptions","organizations_url":"https://api.github.com/users/SonarCommunity/orgs","repos_url":"https://api.github.com/users/SonarCommunity/repos","events_url":"https://api.github.com/users/SonarCommunity/events{/privacy}","received_events_url":"https://api.github.com/users/SonarCommunity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarCommunity/sonar-javascript","description":"","fork":false,"url":"https://api.github.com/repos/SonarCommunity/sonar-javascript","forks_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/forks","keys_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/teams","hooks_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/hooks","issue_events_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues/events{/number}","events_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/events","assignees_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/assignees{/user}","branches_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/branches{/branch}","tags_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/tags","blobs_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/languages","stargazers_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/stargazers","contributors_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/contributors","subscribers_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/subscribers","subscription_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/subscription","commits_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/contents/{+path}","compare_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/merges","archive_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/downloads","issues_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues{/number}","pulls_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/labels{/name}","releases_url":"https://api.github.com/repos/SonarCommunity/sonar-javascript/releases{/id}","created_at":"2012-05-15T12:35:38Z","updated_at":"2015-11-23T07:59:52Z","pushed_at":"2015-11-26T17:02:16Z","git_url":"git://github.com/SonarCommunity/sonar-javascript.git","ssh_url":"git@github.com:SonarCommunity/sonar-javascript.git","clone_url":"https://github.com/SonarCommunity/sonar-javascript.git","svn_url":"https://github.com/SonarCommunity/sonar-javascript","homepage":"http://docs.codehaus.org/display/SONAR/JavaScript+Plugin","size":7527,"stargazers_count":60,"watchers_count":60,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":52,"mirror_url":null,"open_issues_count":6,"forks":52,"open_issues":6,"watchers":60,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/126"},"html":{"href":"https://github.com/SonarCommunity/sonar-javascript/pull/126"},"issue":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues/126"},"comments":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/issues/126/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/126/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/pulls/126/commits"},"statuses":{"href":"https://api.github.com/repos/SonarCommunity/sonar-javascript/statuses/aa2dcdd45e49c33ef98f6b0502e3f0061fb69b4e"}}}}