{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments/26293017","id":26293017,"diff_hunk":"@@ -0,0 +1,147 @@\n+/*\n+ * SonarQube Java\n+ * Copyright (C) 2012 SonarSource\n+ * dev@sonar.codehaus.org\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU Lesser General Public\n+ * License as published by the Free Software Foundation; either\n+ * version 3 of the License, or (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ * Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public\n+ * License along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02\n+ */\n+package org.sonar.java.checks;\n+\n+import org.sonar.api.rule.RuleKey;\n+import org.sonar.api.server.rule.RulesDefinition;\n+import org.sonar.check.Priority;\n+import org.sonar.check.Rule;\n+import org.sonar.java.model.expression.MethodInvocationTreeImpl;\n+import org.sonar.java.resolve.AnnotationInstance;\n+import org.sonar.java.resolve.SemanticModel;\n+import org.sonar.java.resolve.Symbol;\n+import org.sonar.plugins.java.api.JavaFileScanner;\n+import org.sonar.plugins.java.api.JavaFileScannerContext;\n+import org.sonar.plugins.java.api.tree.ArrayAccessExpressionTree;\n+import org.sonar.plugins.java.api.tree.BaseTreeVisitor;\n+import org.sonar.plugins.java.api.tree.ExpressionTree;\n+import org.sonar.plugins.java.api.tree.IdentifierTree;\n+import org.sonar.plugins.java.api.tree.MemberSelectExpressionTree;\n+import org.sonar.plugins.java.api.tree.MethodInvocationTree;\n+import org.sonar.plugins.java.api.tree.Tree;\n+import org.sonar.squidbridge.annotations.SqaleConstantRemediation;\n+import org.sonar.squidbridge.annotations.SqaleSubCharacteristic;\n+\n+import javax.annotation.Nullable;\n+\n+@Rule(\n+  key = \"S2259\",\n+  name = \"Null pointers should not be dereferenced\",\n+  tags = {\"bug\", \"cert\", \"cwe\", \"owasp-a1\", \"owasp-a2\", \"owasp-a6\", \"security\"},\n+  priority = Priority.BLOCKER)\n+@SqaleSubCharacteristic(RulesDefinition.SubCharacteristics.ERRORS)\n+@SqaleConstantRemediation(\"20min\")\n+public class NullPointerCheck implements JavaFileScanner {\n+\n+  public static final String KEY = \"S2259\";\n+  private static final RuleKey RULE_KEY = RuleKey.of(CheckList.REPOSITORY_KEY, KEY);\n+\n+  private JavaFileScannerContext context;\n+  private ExpressionVisitor expressionVisitor = new ExpressionVisitor();\n+  private IssueVisitor issueVisitor = new IssueVisitor();\n+\n+  @Override\n+  public void scanFile(final JavaFileScannerContext context) {\n+    this.context = context;\n+    if (context.getSemanticModel() != null) {\n+      expressionVisitor.scan(context.getTree());\n+    }\n+  }\n+\n+  /** this visitor invokes issueVisitor for the base expressions of array access, member selectm and method invocation expressions. */\n+  private class ExpressionVisitor extends BaseTreeVisitor {\n+    @Override\n+    public void scan(@Nullable Tree tree) {","path":"java-checks/src/main/java/org/sonar/java/checks/NullPointerCheck.java","position":71,"original_position":71,"commit_id":"13961ca16998046a0f0a1745e2382d672ed0399a","original_commit_id":"13961ca16998046a0f0a1745e2382d672ed0399a","user":{"login":"merciesa","id":8008916,"avatar_url":"https://avatars.githubusercontent.com/u/8008916?v=3","gravatar_id":"","url":"https://api.github.com/users/merciesa","html_url":"https://github.com/merciesa","followers_url":"https://api.github.com/users/merciesa/followers","following_url":"https://api.github.com/users/merciesa/following{/other_user}","gists_url":"https://api.github.com/users/merciesa/gists{/gist_id}","starred_url":"https://api.github.com/users/merciesa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merciesa/subscriptions","organizations_url":"https://api.github.com/users/merciesa/orgs","repos_url":"https://api.github.com/users/merciesa/repos","events_url":"https://api.github.com/users/merciesa/events{/privacy}","received_events_url":"https://api.github.com/users/merciesa/received_events","type":"User","site_admin":false},"body":"Same as above","created_at":"2015-03-12T11:06:38Z","updated_at":"2015-03-12T11:06:38Z","html_url":"https://github.com/SonarSource/sonar-java/pull/93#discussion_r26293017","pull_request_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/93","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments/26293017"},"html":{"href":"https://github.com/SonarSource/sonar-java/pull/93#discussion_r26293017"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/93"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/93","id":31016852,"html_url":"https://github.com/SonarSource/sonar-java/pull/93","diff_url":"https://github.com/SonarSource/sonar-java/pull/93.diff","patch_url":"https://github.com/SonarSource/sonar-java/pull/93.patch","issue_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/93","number":93,"state":"open","locked":false,"title":"SONARJAVA-928 RSPEC-2259 Null pointers should not be dereferenced","user":{"login":"merciesa","id":8008916,"avatar_url":"https://avatars.githubusercontent.com/u/8008916?v=3","gravatar_id":"","url":"https://api.github.com/users/merciesa","html_url":"https://github.com/merciesa","followers_url":"https://api.github.com/users/merciesa/followers","following_url":"https://api.github.com/users/merciesa/following{/other_user}","gists_url":"https://api.github.com/users/merciesa/gists{/gist_id}","starred_url":"https://api.github.com/users/merciesa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merciesa/subscriptions","organizations_url":"https://api.github.com/users/merciesa/orgs","repos_url":"https://api.github.com/users/merciesa/repos","events_url":"https://api.github.com/users/merciesa/events{/privacy}","received_events_url":"https://api.github.com/users/merciesa/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-12T08:48:15Z","updated_at":"2015-03-12T11:06:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e3fe36e612735ae3777725150daf320217f0d1e","assignee":{"login":"merciesa","id":8008916,"avatar_url":"https://avatars.githubusercontent.com/u/8008916?v=3","gravatar_id":"","url":"https://api.github.com/users/merciesa","html_url":"https://github.com/merciesa","followers_url":"https://api.github.com/users/merciesa/followers","following_url":"https://api.github.com/users/merciesa/following{/other_user}","gists_url":"https://api.github.com/users/merciesa/gists{/gist_id}","starred_url":"https://api.github.com/users/merciesa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merciesa/subscriptions","organizations_url":"https://api.github.com/users/merciesa/orgs","repos_url":"https://api.github.com/users/merciesa/repos","events_url":"https://api.github.com/users/merciesa/events{/privacy}","received_events_url":"https://api.github.com/users/merciesa/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/93/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/93/comments","review_comment_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/93/comments","statuses_url":"https://api.github.com/repos/SonarSource/sonar-java/statuses/13961ca16998046a0f0a1745e2382d672ed0399a","head":{"label":"merciesa:SONARJAVA-928","ref":"SONARJAVA-928","sha":"13961ca16998046a0f0a1745e2382d672ed0399a","user":{"login":"merciesa","id":8008916,"avatar_url":"https://avatars.githubusercontent.com/u/8008916?v=3","gravatar_id":"","url":"https://api.github.com/users/merciesa","html_url":"https://github.com/merciesa","followers_url":"https://api.github.com/users/merciesa/followers","following_url":"https://api.github.com/users/merciesa/following{/other_user}","gists_url":"https://api.github.com/users/merciesa/gists{/gist_id}","starred_url":"https://api.github.com/users/merciesa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merciesa/subscriptions","organizations_url":"https://api.github.com/users/merciesa/orgs","repos_url":"https://api.github.com/users/merciesa/repos","events_url":"https://api.github.com/users/merciesa/events{/privacy}","received_events_url":"https://api.github.com/users/merciesa/received_events","type":"User","site_admin":false},"repo":{"id":31966358,"name":"sonar-java","full_name":"merciesa/sonar-java","owner":{"login":"merciesa","id":8008916,"avatar_url":"https://avatars.githubusercontent.com/u/8008916?v=3","gravatar_id":"","url":"https://api.github.com/users/merciesa","html_url":"https://github.com/merciesa","followers_url":"https://api.github.com/users/merciesa/followers","following_url":"https://api.github.com/users/merciesa/following{/other_user}","gists_url":"https://api.github.com/users/merciesa/gists{/gist_id}","starred_url":"https://api.github.com/users/merciesa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/merciesa/subscriptions","organizations_url":"https://api.github.com/users/merciesa/orgs","repos_url":"https://api.github.com/users/merciesa/repos","events_url":"https://api.github.com/users/merciesa/events{/privacy}","received_events_url":"https://api.github.com/users/merciesa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/merciesa/sonar-java","description":"","fork":true,"url":"https://api.github.com/repos/merciesa/sonar-java","forks_url":"https://api.github.com/repos/merciesa/sonar-java/forks","keys_url":"https://api.github.com/repos/merciesa/sonar-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/merciesa/sonar-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/merciesa/sonar-java/teams","hooks_url":"https://api.github.com/repos/merciesa/sonar-java/hooks","issue_events_url":"https://api.github.com/repos/merciesa/sonar-java/issues/events{/number}","events_url":"https://api.github.com/repos/merciesa/sonar-java/events","assignees_url":"https://api.github.com/repos/merciesa/sonar-java/assignees{/user}","branches_url":"https://api.github.com/repos/merciesa/sonar-java/branches{/branch}","tags_url":"https://api.github.com/repos/merciesa/sonar-java/tags","blobs_url":"https://api.github.com/repos/merciesa/sonar-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/merciesa/sonar-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/merciesa/sonar-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/merciesa/sonar-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/merciesa/sonar-java/statuses/{sha}","languages_url":"https://api.github.com/repos/merciesa/sonar-java/languages","stargazers_url":"https://api.github.com/repos/merciesa/sonar-java/stargazers","contributors_url":"https://api.github.com/repos/merciesa/sonar-java/contributors","subscribers_url":"https://api.github.com/repos/merciesa/sonar-java/subscribers","subscription_url":"https://api.github.com/repos/merciesa/sonar-java/subscription","commits_url":"https://api.github.com/repos/merciesa/sonar-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/merciesa/sonar-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/merciesa/sonar-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/merciesa/sonar-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/merciesa/sonar-java/contents/{+path}","compare_url":"https://api.github.com/repos/merciesa/sonar-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/merciesa/sonar-java/merges","archive_url":"https://api.github.com/repos/merciesa/sonar-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/merciesa/sonar-java/downloads","issues_url":"https://api.github.com/repos/merciesa/sonar-java/issues{/number}","pulls_url":"https://api.github.com/repos/merciesa/sonar-java/pulls{/number}","milestones_url":"https://api.github.com/repos/merciesa/sonar-java/milestones{/number}","notifications_url":"https://api.github.com/repos/merciesa/sonar-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/merciesa/sonar-java/labels{/name}","releases_url":"https://api.github.com/repos/merciesa/sonar-java/releases{/id}","created_at":"2015-03-10T15:51:38Z","updated_at":"2015-03-10T15:51:41Z","pushed_at":"2015-03-12T08:58:18Z","git_url":"git://github.com/merciesa/sonar-java.git","ssh_url":"git@github.com:merciesa/sonar-java.git","clone_url":"https://github.com/merciesa/sonar-java.git","svn_url":"https://github.com/merciesa/sonar-java","homepage":"","size":26235,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"SonarSource:master","ref":"master","sha":"67af9ddc9e02cdbc882fe56db11c9a756835010d","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":5674787,"name":"sonar-java","full_name":"SonarSource/sonar-java","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonar-java","description":"","fork":false,"url":"https://api.github.com/repos/SonarSource/sonar-java","forks_url":"https://api.github.com/repos/SonarSource/sonar-java/forks","keys_url":"https://api.github.com/repos/SonarSource/sonar-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonar-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonar-java/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonar-java/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonar-java/events","assignees_url":"https://api.github.com/repos/SonarSource/sonar-java/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonar-java/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonar-java/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonar-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonar-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonar-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonar-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonar-java/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonar-java/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonar-java/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonar-java/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonar-java/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonar-java/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonar-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonar-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonar-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonar-java/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonar-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonar-java/merges","archive_url":"https://api.github.com/repos/SonarSource/sonar-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonar-java/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonar-java/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonar-java/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonar-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonar-java/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonar-java/releases{/id}","created_at":"2012-09-04T15:53:13Z","updated_at":"2015-03-12T09:06:27Z","pushed_at":"2015-03-12T09:06:27Z","git_url":"git://github.com/SonarSource/sonar-java.git","ssh_url":"git@github.com:SonarSource/sonar-java.git","clone_url":"https://github.com/SonarSource/sonar-java.git","svn_url":"https://github.com/SonarSource/sonar-java","homepage":"","size":26235,"stargazers_count":36,"watchers_count":36,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":65,"mirror_url":null,"open_issues_count":2,"forks":65,"open_issues":2,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/93"},"html":{"href":"https://github.com/SonarSource/sonar-java/pull/93"},"issue":{"href":"https://api.github.com/repos/SonarSource/sonar-java/issues/93"},"comments":{"href":"https://api.github.com/repos/SonarSource/sonar-java/issues/93/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/93/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/93/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sonar-java/statuses/13961ca16998046a0f0a1745e2382d672ed0399a"}}}}