{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments/31663570","id":31663570,"diff_hunk":"@@ -0,0 +1,119 @@\n+/*\r\n+ * SonarQube Java\r\n+ * Copyright (C) 2012 SonarSource\r\n+ * dev@sonar.codehaus.org\r\n+ *\r\n+ * This program is free software; you can redistribute it and/or\r\n+ * modify it under the terms of the GNU Lesser General Public\r\n+ * License as published by the Free Software Foundation; either\r\n+ * version 3 of the License, or (at your option) any later version.\r\n+ *\r\n+ * This program is distributed in the hope that it will be useful,\r\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r\n+ * Lesser General Public License for more details.\r\n+ *\r\n+ * You should have received a copy of the GNU Lesser General Public\r\n+ * License along with this program; if not, write to the Free Software\r\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02\r\n+ */\r\n+package org.sonar.java.checks;\r\n+\r\n+import com.google.common.collect.ImmutableList;\r\n+import java.util.HashSet;\r\n+import java.util.List;\r\n+import org.apache.commons.lang.StringUtils;\r\n+import org.sonar.api.server.rule.RulesDefinition;\r\n+import org.sonar.check.Priority;\r\n+import org.sonar.check.Rule;\r\n+import org.sonar.check.RuleProperty;\r\n+import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;\r\n+import org.sonar.plugins.java.api.tree.IdentifierTree;\r\n+import org.sonar.plugins.java.api.tree.ImportTree;\r\n+import org.sonar.plugins.java.api.tree.MemberSelectExpressionTree;\r\n+import org.sonar.plugins.java.api.tree.Tree;\r\n+import org.sonar.plugins.java.api.tree.Tree.Kind;\r\n+import org.sonar.squidbridge.annotations.SqaleConstantRemediation;\r\n+import org.sonar.squidbridge.annotations.SqaleSubCharacteristic;\r\n+\r\n+/**\r\n+ *\r\n+ * Squid implementation for checkstyle <a href=\"checkstyle.sourceforge.net/config_imports.html#AvoidStarImport\">AvoidStarImport</a> rule\r\n+ *\r\n+ */\r\n+@Rule(\r\n+  key = \"AvoidStarImportCheck\",\r\n+  name = \"Checks that there are no import statements that use the * notation\",\r\n+  tags = {\"convention\", \"bug\"},\r\n+  priority = Priority.MINOR)\r\n+@SqaleSubCharacteristic(RulesDefinition.SubCharacteristics.READABILITY)\r\n+@SqaleConstantRemediation(\"1min\")\r\n+public class AvoidStarImportCheck extends IssuableSubscriptionVisitor {\r\n+\r\n+  private static final String DEFAULT_EXCLUDE = \"\";\r\n+\r\n+  private static final boolean DEFAULT_ALLOW = false;\r\n+\r\n+  @RuleProperty(\r\n+    key = \"AllowClassImports\",\r\n+    description = \"Whether to allow starred class imports like import java.util.*;\",\r\n+    defaultValue = \"\" + DEFAULT_ALLOW)\r\n+  public boolean allowClassImports = DEFAULT_ALLOW;\r\n+\r\n+  @RuleProperty(\r\n+    key = \"AllowStaticMemberImports\",\r\n+    description = \"whether to allow starred static member imports like import static org.junit.Assert.*\",\r\n+    defaultValue = \"\" + DEFAULT_ALLOW)\r\n+  public boolean allowStaticMemberImports = DEFAULT_ALLOW;\r\n+\r\n+  @RuleProperty(\r\n+    key = \"Exclude\",\r\n+    description = \"Comma separated list of packages where star imports are allowed (Note that this property is not recursive, subpackages of excluded packages are not automatically excluded)\",\r\n+    defaultValue = \"\" + DEFAULT_EXCLUDE)\r\n+  public String exclude = DEFAULT_EXCLUDE;\r\n+  private HashSet<String> excludePackages = new HashSet<>();\r\n+\r\n+  @Override\r\n+  public List<Kind> nodesToVisit() {\r\n+    if (StringUtils.isNotBlank(exclude)) {\r","path":"java-checks/src/main/java/org/sonar/java/checks/AvoidStarImportCheck.java","position":78,"original_position":78,"commit_id":"517bf52f65d7dea98b20e3692832143f1fd2148b","original_commit_id":"517bf52f65d7dea98b20e3692832143f1fd2148b","user":{"login":"benzonico","id":1199708,"avatar_url":"https://avatars.githubusercontent.com/u/1199708?v=3","gravatar_id":"","url":"https://api.github.com/users/benzonico","html_url":"https://github.com/benzonico","followers_url":"https://api.github.com/users/benzonico/followers","following_url":"https://api.github.com/users/benzonico/following{/other_user}","gists_url":"https://api.github.com/users/benzonico/gists{/gist_id}","starred_url":"https://api.github.com/users/benzonico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benzonico/subscriptions","organizations_url":"https://api.github.com/users/benzonico/orgs","repos_url":"https://api.github.com/users/benzonico/repos","events_url":"https://api.github.com/users/benzonico/events{/privacy}","received_events_url":"https://api.github.com/users/benzonico/received_events","type":"User","site_admin":false},"body":"This method is not really designed to handle initialiazation stuff. Moreover, adding behaviour introduces side effect in a method that should not have any. It is better to override `scanFile` method (and do not forget to call `super` implementation)","created_at":"2015-06-03T20:00:54Z","updated_at":"2015-06-03T20:00:54Z","html_url":"https://github.com/SonarSource/sonar-java/pull/263#discussion_r31663570","pull_request_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/263","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments/31663570"},"html":{"href":"https://github.com/SonarSource/sonar-java/pull/263#discussion_r31663570"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/263"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/263","id":36855120,"html_url":"https://github.com/SonarSource/sonar-java/pull/263","diff_url":"https://github.com/SonarSource/sonar-java/pull/263.diff","patch_url":"https://github.com/SonarSource/sonar-java/pull/263.patch","issue_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/263","number":263,"state":"open","locked":false,"title":"Checkstyle:AvoidStarImport Squid implementation","user":{"login":"axel3rd","id":2912441,"avatar_url":"https://avatars.githubusercontent.com/u/2912441?v=3","gravatar_id":"","url":"https://api.github.com/users/axel3rd","html_url":"https://github.com/axel3rd","followers_url":"https://api.github.com/users/axel3rd/followers","following_url":"https://api.github.com/users/axel3rd/following{/other_user}","gists_url":"https://api.github.com/users/axel3rd/gists{/gist_id}","starred_url":"https://api.github.com/users/axel3rd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axel3rd/subscriptions","organizations_url":"https://api.github.com/users/axel3rd/orgs","repos_url":"https://api.github.com/users/axel3rd/repos","events_url":"https://api.github.com/users/axel3rd/events{/privacy}","received_events_url":"https://api.github.com/users/axel3rd/received_events","type":"User","site_admin":false},"body":"Origin : [SUPPORT-550](http://jira.sonarsource.com/servicedesk/customer/portal/1/SUPPORT-550).\r\n\r\nRule key like checkstyle / old rules and not _Sxxxx_ ... but I don't know the naming strategy :(.","created_at":"2015-06-03T17:08:17Z","updated_at":"2015-06-03T20:00:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"18073dbb3ef71ef82d61e911d96ef8b691334cb4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/263/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/263/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/263/comments","statuses_url":"https://api.github.com/repos/SonarSource/sonar-java/statuses/517bf52f65d7dea98b20e3692832143f1fd2148b","head":{"label":"axel3rd:master","ref":"master","sha":"517bf52f65d7dea98b20e3692832143f1fd2148b","user":{"login":"axel3rd","id":2912441,"avatar_url":"https://avatars.githubusercontent.com/u/2912441?v=3","gravatar_id":"","url":"https://api.github.com/users/axel3rd","html_url":"https://github.com/axel3rd","followers_url":"https://api.github.com/users/axel3rd/followers","following_url":"https://api.github.com/users/axel3rd/following{/other_user}","gists_url":"https://api.github.com/users/axel3rd/gists{/gist_id}","starred_url":"https://api.github.com/users/axel3rd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axel3rd/subscriptions","organizations_url":"https://api.github.com/users/axel3rd/orgs","repos_url":"https://api.github.com/users/axel3rd/repos","events_url":"https://api.github.com/users/axel3rd/events{/privacy}","received_events_url":"https://api.github.com/users/axel3rd/received_events","type":"User","site_admin":false},"repo":{"id":36803387,"name":"sonar-java-avoid-star-import","full_name":"axel3rd/sonar-java-avoid-star-import","owner":{"login":"axel3rd","id":2912441,"avatar_url":"https://avatars.githubusercontent.com/u/2912441?v=3","gravatar_id":"","url":"https://api.github.com/users/axel3rd","html_url":"https://github.com/axel3rd","followers_url":"https://api.github.com/users/axel3rd/followers","following_url":"https://api.github.com/users/axel3rd/following{/other_user}","gists_url":"https://api.github.com/users/axel3rd/gists{/gist_id}","starred_url":"https://api.github.com/users/axel3rd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axel3rd/subscriptions","organizations_url":"https://api.github.com/users/axel3rd/orgs","repos_url":"https://api.github.com/users/axel3rd/repos","events_url":"https://api.github.com/users/axel3rd/events{/privacy}","received_events_url":"https://api.github.com/users/axel3rd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/axel3rd/sonar-java-avoid-star-import","description":"","fork":true,"url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import","forks_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/forks","keys_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/keys{/key_id}","collaborators_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/teams","hooks_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/hooks","issue_events_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/issues/events{/number}","events_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/events","assignees_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/assignees{/user}","branches_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/branches{/branch}","tags_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/tags","blobs_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/git/refs{/sha}","trees_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/git/trees{/sha}","statuses_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/statuses/{sha}","languages_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/languages","stargazers_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/stargazers","contributors_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/contributors","subscribers_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/subscribers","subscription_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/subscription","commits_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/commits{/sha}","git_commits_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/git/commits{/sha}","comments_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/comments{/number}","issue_comment_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/issues/comments{/number}","contents_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/contents/{+path}","compare_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/compare/{base}...{head}","merges_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/merges","archive_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/downloads","issues_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/issues{/number}","pulls_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/pulls{/number}","milestones_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/milestones{/number}","notifications_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/labels{/name}","releases_url":"https://api.github.com/repos/axel3rd/sonar-java-avoid-star-import/releases{/id}","created_at":"2015-06-03T12:53:51Z","updated_at":"2015-06-03T12:56:30Z","pushed_at":"2015-06-03T17:02:56Z","git_url":"git://github.com/axel3rd/sonar-java-avoid-star-import.git","ssh_url":"git@github.com:axel3rd/sonar-java-avoid-star-import.git","clone_url":"https://github.com/axel3rd/sonar-java-avoid-star-import.git","svn_url":"https://github.com/axel3rd/sonar-java-avoid-star-import","homepage":"","size":35157,"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":"fc07a4c974e9b93599f0af801966f0cc756b2e3c","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-06-02T12:36:40Z","pushed_at":"2015-06-03T17:08:17Z","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":35157,"stargazers_count":44,"watchers_count":44,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":84,"mirror_url":null,"open_issues_count":7,"forks":84,"open_issues":7,"watchers":44,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/263"},"html":{"href":"https://github.com/SonarSource/sonar-java/pull/263"},"issue":{"href":"https://api.github.com/repos/SonarSource/sonar-java/issues/263"},"comments":{"href":"https://api.github.com/repos/SonarSource/sonar-java/issues/263/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/263/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/263/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sonar-java/statuses/517bf52f65d7dea98b20e3692832143f1fd2148b"}}}}