{"action":"created","comment":{"url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments/33905985","id":33905985,"diff_hunk":"@@ -42,7 +46,67 @@ public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics\n         /// <inheritdoc/>\n         public override void Initialize(AnalysisContext context)\n         {\n-            // TODO: Implement analysis\n+            context.RegisterSyntaxTreeActionHonorExclusions(this.HandleSyntaxTree);\n+        }\n+\n+        private void HandleSyntaxTree(SyntaxTreeAnalysisContext context)\n+        {\n+            SyntaxNode root = context.Tree.GetCompilationUnitRoot(context.CancellationToken);\n+            foreach (var node in root.DescendantTrivia(descendIntoTrivia: true))\n+            {\n+                switch (node.Kind())\n+                {\n+                    case SyntaxKind.SingleLineCommentTrivia:\n+                        HandleSingleLineComment(context, node);\n+                        break;\n+                    case SyntaxKind.MultiLineCommentTrivia:\n+                        HandleMultiLineComment(context, node);\n+                        break;\n+                }\n+            }\n+        }\n+\n+        private static void HandleMultiLineComment(SyntaxTreeAnalysisContext context, SyntaxTrivia multiLineComment)\n+        {\n+            var nodeText = multiLineComment.ToString();\n+\n+            // We remove the /* and the */ and determine if the comment has any content.\n+            var commentText = nodeText.Substring(2, nodeText.Length - 4);\n+\n+            if (string.IsNullOrWhiteSpace(commentText))\n+            {\n+                var diagnostic = Diagnostic.Create(Descriptor, multiLineComment.GetLocation());\n+                context.ReportDiagnostic(diagnostic);\n+            }\n+        }\n+\n+        private static void HandleSingleLineComment(SyntaxTreeAnalysisContext context, SyntaxTrivia singleLineComment)\n+        {\n+            // Remove the leading // from the comment\n+            var commentText = singleLineComment.ToString().Substring(2);\n+            int index = 0;\n+\n+            var list = TriviaHelper.GetContainingTriviaList(singleLineComment, out index);\n+            var firstNonWhiteSpace = TriviaHelper.IndexOfFirstNonWhitespaceTrivia(list);\n+\n+            // This is -2 because we need to go back past the end of line trivia as well.\n+            var lastNonWhiteSpace = TriviaHelper.IndexOfTrailingWhitespace(list) - 2;\n+\n+            // When we enounter a block of single line comments, we only want to raise this diagnostic\n+            // on the first or last line.  This ensures that whitespace in code commented out using\n+            // the Comment Selection option in Visual Studio will not raise the diagnostic for every\n+            // blank line in the code which is commented out.\n+            bool isFirstOrLast = false;\n+            if (index == firstNonWhiteSpace || index == lastNonWhiteSpace)\n+            {\n+                isFirstOrLast = true;\n+            }","path":"StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1120CommentsMustContainText.cs","position":81,"original_position":81,"commit_id":"a0d0fc6e6cf14de4956b2fecb76b08137cbf309c","original_commit_id":"a0d0fc6e6cf14de4956b2fecb76b08137cbf309c","user":{"login":"Maxwe11","id":1083827,"avatar_url":"https://avatars.githubusercontent.com/u/1083827?v=3","gravatar_id":"","url":"https://api.github.com/users/Maxwe11","html_url":"https://github.com/Maxwe11","followers_url":"https://api.github.com/users/Maxwe11/followers","following_url":"https://api.github.com/users/Maxwe11/following{/other_user}","gists_url":"https://api.github.com/users/Maxwe11/gists{/gist_id}","starred_url":"https://api.github.com/users/Maxwe11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Maxwe11/subscriptions","organizations_url":"https://api.github.com/users/Maxwe11/orgs","repos_url":"https://api.github.com/users/Maxwe11/repos","events_url":"https://api.github.com/users/Maxwe11/events{/privacy}","received_events_url":"https://api.github.com/users/Maxwe11/received_events","type":"User","site_admin":false},"body":"we cold make it lazy\r\n```c#\r\nbool isFirstOrLast = index == firstNonWhiteSpace;\r\nif (!isFirstOrLast)\r\n{\r\n    var lastNonWhiteSpace = TriviaHelper.IndexOfTrailingWhitespace(list) - 2;\r\n    isFirstOrLast = index == lastNonWhiteSpace;\r\n}\r\n```","created_at":"2015-07-06T04:53:43Z","updated_at":"2015-07-06T04:53:43Z","html_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/944#discussion_r33905985","pull_request_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/944","_links":{"self":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments/33905985"},"html":{"href":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/944#discussion_r33905985"},"pull_request":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/944"}}},"pull_request":{"url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/944","id":39223722,"html_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/944","diff_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/944.diff","patch_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/944.patch","issue_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/944","number":944,"state":"open","locked":false,"title":"Initial implemetation of SA1120. ","user":{"login":"johnkoerner","id":3915000,"avatar_url":"https://avatars.githubusercontent.com/u/3915000?v=3","gravatar_id":"","url":"https://api.github.com/users/johnkoerner","html_url":"https://github.com/johnkoerner","followers_url":"https://api.github.com/users/johnkoerner/followers","following_url":"https://api.github.com/users/johnkoerner/following{/other_user}","gists_url":"https://api.github.com/users/johnkoerner/gists{/gist_id}","starred_url":"https://api.github.com/users/johnkoerner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnkoerner/subscriptions","organizations_url":"https://api.github.com/users/johnkoerner/orgs","repos_url":"https://api.github.com/users/johnkoerner/repos","events_url":"https://api.github.com/users/johnkoerner/events{/privacy}","received_events_url":"https://api.github.com/users/johnkoerner/received_events","type":"User","site_admin":false},"body":"Fixes #53 ","created_at":"2015-07-05T17:14:25Z","updated_at":"2015-07-06T04:53:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ff82bd629cba78fddbd9d10f4c82c64d2262344","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/944/commits","review_comments_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/944/comments","review_comment_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/944/comments","statuses_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/statuses/a0d0fc6e6cf14de4956b2fecb76b08137cbf309c","head":{"label":"johnkoerner:SA1120","ref":"SA1120","sha":"a0d0fc6e6cf14de4956b2fecb76b08137cbf309c","user":{"login":"johnkoerner","id":3915000,"avatar_url":"https://avatars.githubusercontent.com/u/3915000?v=3","gravatar_id":"","url":"https://api.github.com/users/johnkoerner","html_url":"https://github.com/johnkoerner","followers_url":"https://api.github.com/users/johnkoerner/followers","following_url":"https://api.github.com/users/johnkoerner/following{/other_user}","gists_url":"https://api.github.com/users/johnkoerner/gists{/gist_id}","starred_url":"https://api.github.com/users/johnkoerner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnkoerner/subscriptions","organizations_url":"https://api.github.com/users/johnkoerner/orgs","repos_url":"https://api.github.com/users/johnkoerner/repos","events_url":"https://api.github.com/users/johnkoerner/events{/privacy}","received_events_url":"https://api.github.com/users/johnkoerner/received_events","type":"User","site_admin":false},"repo":{"id":32495690,"name":"StyleCopAnalyzers","full_name":"johnkoerner/StyleCopAnalyzers","owner":{"login":"johnkoerner","id":3915000,"avatar_url":"https://avatars.githubusercontent.com/u/3915000?v=3","gravatar_id":"","url":"https://api.github.com/users/johnkoerner","html_url":"https://github.com/johnkoerner","followers_url":"https://api.github.com/users/johnkoerner/followers","following_url":"https://api.github.com/users/johnkoerner/following{/other_user}","gists_url":"https://api.github.com/users/johnkoerner/gists{/gist_id}","starred_url":"https://api.github.com/users/johnkoerner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnkoerner/subscriptions","organizations_url":"https://api.github.com/users/johnkoerner/orgs","repos_url":"https://api.github.com/users/johnkoerner/repos","events_url":"https://api.github.com/users/johnkoerner/events{/privacy}","received_events_url":"https://api.github.com/users/johnkoerner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johnkoerner/StyleCopAnalyzers","description":"An implementation of StyleCop rules using the .NET Compiler Platform","fork":true,"url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers","forks_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/forks","keys_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/teams","hooks_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/hooks","issue_events_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/issues/events{/number}","events_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/events","assignees_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/assignees{/user}","branches_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/branches{/branch}","tags_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/tags","blobs_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/git/refs{/sha}","trees_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/statuses/{sha}","languages_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/languages","stargazers_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/stargazers","contributors_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/contributors","subscribers_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/subscribers","subscription_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/subscription","commits_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/commits{/sha}","git_commits_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/git/commits{/sha}","comments_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/comments{/number}","issue_comment_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/issues/comments{/number}","contents_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/contents/{+path}","compare_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/merges","archive_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/downloads","issues_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/issues{/number}","pulls_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/pulls{/number}","milestones_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/milestones{/number}","notifications_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/labels{/name}","releases_url":"https://api.github.com/repos/johnkoerner/StyleCopAnalyzers/releases{/id}","created_at":"2015-03-19T02:14:13Z","updated_at":"2015-04-15T01:25:57Z","pushed_at":"2015-07-05T17:11:33Z","git_url":"git://github.com/johnkoerner/StyleCopAnalyzers.git","ssh_url":"git@github.com:johnkoerner/StyleCopAnalyzers.git","clone_url":"https://github.com/johnkoerner/StyleCopAnalyzers.git","svn_url":"https://github.com/johnkoerner/StyleCopAnalyzers","homepage":null,"size":3782,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"DotNetAnalyzers:master","ref":"master","sha":"5416493548d50c6e2f79911490fdb63966c701eb","user":{"login":"DotNetAnalyzers","id":9735576,"avatar_url":"https://avatars.githubusercontent.com/u/9735576?v=3","gravatar_id":"","url":"https://api.github.com/users/DotNetAnalyzers","html_url":"https://github.com/DotNetAnalyzers","followers_url":"https://api.github.com/users/DotNetAnalyzers/followers","following_url":"https://api.github.com/users/DotNetAnalyzers/following{/other_user}","gists_url":"https://api.github.com/users/DotNetAnalyzers/gists{/gist_id}","starred_url":"https://api.github.com/users/DotNetAnalyzers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DotNetAnalyzers/subscriptions","organizations_url":"https://api.github.com/users/DotNetAnalyzers/orgs","repos_url":"https://api.github.com/users/DotNetAnalyzers/repos","events_url":"https://api.github.com/users/DotNetAnalyzers/events{/privacy}","received_events_url":"https://api.github.com/users/DotNetAnalyzers/received_events","type":"Organization","site_admin":false},"repo":{"id":26768275,"name":"StyleCopAnalyzers","full_name":"DotNetAnalyzers/StyleCopAnalyzers","owner":{"login":"DotNetAnalyzers","id":9735576,"avatar_url":"https://avatars.githubusercontent.com/u/9735576?v=3","gravatar_id":"","url":"https://api.github.com/users/DotNetAnalyzers","html_url":"https://github.com/DotNetAnalyzers","followers_url":"https://api.github.com/users/DotNetAnalyzers/followers","following_url":"https://api.github.com/users/DotNetAnalyzers/following{/other_user}","gists_url":"https://api.github.com/users/DotNetAnalyzers/gists{/gist_id}","starred_url":"https://api.github.com/users/DotNetAnalyzers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DotNetAnalyzers/subscriptions","organizations_url":"https://api.github.com/users/DotNetAnalyzers/orgs","repos_url":"https://api.github.com/users/DotNetAnalyzers/repos","events_url":"https://api.github.com/users/DotNetAnalyzers/events{/privacy}","received_events_url":"https://api.github.com/users/DotNetAnalyzers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers","description":"An implementation of StyleCop rules using the .NET Compiler Platform","fork":false,"url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers","forks_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/forks","keys_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/teams","hooks_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/hooks","issue_events_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/events{/number}","events_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/events","assignees_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/assignees{/user}","branches_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/branches{/branch}","tags_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/tags","blobs_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/refs{/sha}","trees_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/statuses/{sha}","languages_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/languages","stargazers_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/stargazers","contributors_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/contributors","subscribers_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/subscribers","subscription_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/subscription","commits_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/commits{/sha}","git_commits_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/git/commits{/sha}","comments_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/comments{/number}","issue_comment_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/comments{/number}","contents_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/contents/{+path}","compare_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/merges","archive_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/downloads","issues_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues{/number}","pulls_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls{/number}","milestones_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/milestones{/number}","notifications_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/labels{/name}","releases_url":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/releases{/id}","created_at":"2014-11-17T17:29:54Z","updated_at":"2015-06-25T19:19:28Z","pushed_at":"2015-07-05T17:14:25Z","git_url":"git://github.com/DotNetAnalyzers/StyleCopAnalyzers.git","ssh_url":"git@github.com:DotNetAnalyzers/StyleCopAnalyzers.git","clone_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers.git","svn_url":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers","homepage":null,"size":6471,"stargazers_count":98,"watchers_count":98,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":27,"mirror_url":null,"open_issues_count":197,"forks":27,"open_issues":197,"watchers":98,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/944"},"html":{"href":"https://github.com/DotNetAnalyzers/StyleCopAnalyzers/pull/944"},"issue":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/944"},"comments":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/issues/944/comments"},"review_comments":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/944/comments"},"review_comment":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/pulls/944/commits"},"statuses":{"href":"https://api.github.com/repos/DotNetAnalyzers/StyleCopAnalyzers/statuses/a0d0fc6e6cf14de4956b2fecb76b08137cbf309c"}}}}