{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments/71300392","id":71300392,"diff_hunk":"@@ -0,0 +1,110 @@\n+/*\n+ * SonarQube Java\n+ * Copyright (C) 2012-2016 SonarSource SA\n+ * mailto:contact AT sonarsource DOT com\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 License\n+ * along with this program; if not, write to the Free Software Foundation,\n+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n+ */\n+package org.sonar.java.checks;\n+\n+import com.google.common.collect.ImmutableList;\n+import java.util.List;\n+import org.sonar.check.Rule;\n+import org.sonar.java.checks.helpers.ValueBasedUtils;\n+import org.sonar.java.checks.serialization.SerializableContract;\n+import org.sonar.java.model.ModifiersUtils;\n+import org.sonar.java.resolve.JavaType;\n+import org.sonar.java.resolve.ParametrizedTypeJavaType;\n+import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;\n+import org.sonar.plugins.java.api.semantic.Type;\n+import org.sonar.plugins.java.api.tree.ClassTree;\n+import org.sonar.plugins.java.api.tree.MethodTree;\n+import org.sonar.plugins.java.api.tree.Modifier;\n+import org.sonar.plugins.java.api.tree.Tree;\n+import org.sonar.plugins.java.api.tree.Tree.Kind;\n+import org.sonar.plugins.java.api.tree.VariableTree;\n+\n+@Rule(key = \"S3437\")\n+public class ValueBasedObjectsShouldNotBeSerializedCheck extends IssuableSubscriptionVisitor {\n+\n+  private static final String MESSAGE = \"Make this value-based field transient so it is not included in the serialization of this class.\";\n+  \n+  @Override\n+  public List<Kind> nodesToVisit() {\n+    return ImmutableList.of(Tree.Kind.CLASS, Tree.Kind.ENUM, Tree.Kind.ANNOTATION_TYPE);\n+  }\n+\n+  @Override\n+  public void visitNode(Tree tree) {\n+    ClassTree classTree = (ClassTree) tree;\n+\n+    if (classTree.is(Tree.Kind.ANNOTATION_TYPE)) {\n+      classTree.members().stream()\n+        .map(member -> (MethodTree) member)\n+        .filter(meth -> isReturnTypeValueBased(meth))\n+        .forEach(meth -> reportIssue(meth.simpleName(), MESSAGE));\n+    } else if (isSerializable(classTree) && !SerializableContract.hasSpecialHandlingSerializationMethods(classTree)) {\n+      classTree.members().stream()\n+        .filter(ValueBasedObjectsShouldNotBeSerializedCheck::isVariable)\n+        .map(member -> (VariableTree) member)\n+        .filter(var -> !isStatic(var))\n+        .filter(var -> !isTransient(var))\n+        .filter(var -> isVarSerializableAndValueBased(var))\n+        .forEach(var -> reportIssue(var.simpleName(), MESSAGE));","path":"java-checks/src/main/java/org/sonar/java/checks/ValueBasedObjectsShouldNotBeSerializedCheck.java","position":65,"original_position":65,"commit_id":"39578f96bbe1bfb6e8ed7f7423304436efc649c9","original_commit_id":"39578f96bbe1bfb6e8ed7f7423304436efc649c9","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) Unknown method [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://dory.sonarsource.com/sonarqube/coding_rules#rule_key=java-debugging-rules%3AUnknownMethodInvocation)\n![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Unknown method [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://dory.sonarsource.com/sonarqube/coding_rules#rule_key=java-debugging-rules%3AUnknownMethodInvocation)\n![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Unknown method [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://dory.sonarsource.com/sonarqube/coding_rules#rule_key=java-debugging-rules%3AUnknownMethodInvocation)\n","created_at":"2016-07-19T09:18:05Z","updated_at":"2016-07-19T09:18:05Z","html_url":"https://github.com/SonarSource/sonar-java/pull/930#discussion_r71300392","pull_request_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/930","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/comments/71300392"},"html":{"href":"https://github.com/SonarSource/sonar-java/pull/930#discussion_r71300392"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/930"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/930","id":77799182,"html_url":"https://github.com/SonarSource/sonar-java/pull/930","diff_url":"https://github.com/SonarSource/sonar-java/pull/930.diff","patch_url":"https://github.com/SonarSource/sonar-java/pull/930.patch","issue_url":"https://api.github.com/repos/SonarSource/sonar-java/issues/930","number":930,"state":"open","locked":false,"title":"SONARJAVA-1758 Rule S3437: Value-based classes should not be serialized","user":{"login":"ivandalbosco","id":19170614,"avatar_url":"https://avatars.githubusercontent.com/u/19170614?v=3","gravatar_id":"","url":"https://api.github.com/users/ivandalbosco","html_url":"https://github.com/ivandalbosco","followers_url":"https://api.github.com/users/ivandalbosco/followers","following_url":"https://api.github.com/users/ivandalbosco/following{/other_user}","gists_url":"https://api.github.com/users/ivandalbosco/gists{/gist_id}","starred_url":"https://api.github.com/users/ivandalbosco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivandalbosco/subscriptions","organizations_url":"https://api.github.com/users/ivandalbosco/orgs","repos_url":"https://api.github.com/users/ivandalbosco/repos","events_url":"https://api.github.com/users/ivandalbosco/events{/privacy}","received_events_url":"https://api.github.com/users/ivandalbosco/received_events","type":"User","site_admin":false},"body":"Please ensure your pull request adheres to the following guidelines: \r\n\r\n- [ ] Use the following formatting style: [SonarSource/sonar-developer-toolset](https://github.com/SonarSource/sonar-developer-toolset#code-style)\r\n- [ ] Unit tests are passing and you provided a unit test for your fix\r\n- [ ] ITs should pass : To run ITs locally, checkout the [README](https://github.com/SonarSource/sonar-java/blob/master/README.md) of the project.\r\n- [ ] If there is a [Jira](http://jira.sonarsource.com/browse/SONARJAVA) ticket available, please make your commits and pull request start with the ticket number (SONARJAVA-XXXX)\r\n\r\n","created_at":"2016-07-18T12:20:59Z","updated_at":"2016-07-19T09:18:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"392de11b844a0d5575e565d313589593c705d3e6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/930/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sonar-java/pulls/930/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/930/comments","statuses_url":"https://api.github.com/repos/SonarSource/sonar-java/statuses/39578f96bbe1bfb6e8ed7f7423304436efc649c9","head":{"label":"SonarSource:SONARJAVA-1758","ref":"SONARJAVA-1758","sha":"39578f96bbe1bfb6e8ed7f7423304436efc649c9","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":":coffee: SonarQube Java language plugin","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}","deployments_url":"https://api.github.com/repos/SonarSource/sonar-java/deployments","created_at":"2012-09-04T15:53:13Z","updated_at":"2016-07-10T11:49:54Z","pushed_at":"2016-07-19T09:10:50Z","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":35541,"stargazers_count":104,"watchers_count":104,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":129,"mirror_url":null,"open_issues_count":7,"forks":129,"open_issues":7,"watchers":104,"default_branch":"master"}},"base":{"label":"SonarSource:master","ref":"master","sha":"0f385ecf70356a08fc3f3d763d4584cf4dab646d","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":":coffee: SonarQube Java language plugin","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}","deployments_url":"https://api.github.com/repos/SonarSource/sonar-java/deployments","created_at":"2012-09-04T15:53:13Z","updated_at":"2016-07-10T11:49:54Z","pushed_at":"2016-07-19T09:10:50Z","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":35541,"stargazers_count":104,"watchers_count":104,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":129,"mirror_url":null,"open_issues_count":7,"forks":129,"open_issues":7,"watchers":104,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/930"},"html":{"href":"https://github.com/SonarSource/sonar-java/pull/930"},"issue":{"href":"https://api.github.com/repos/SonarSource/sonar-java/issues/930"},"comments":{"href":"https://api.github.com/repos/SonarSource/sonar-java/issues/930/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sonar-java/pulls/930/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/930/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sonar-java/statuses/39578f96bbe1bfb6e8ed7f7423304436efc649c9"}}}}
{"actor":{"display_login":"SonarTech"}}