{"action":"created","comment":{"url":"https://api.github.com/repos/realm/SwiftLint/pulls/comments/31074145","id":31074145,"diff_hunk":"@@ -0,0 +1,62 @@\n+//\n+//  ControlStatementRule.swift\n+//  SwiftLint\n+//\n+//  Created by Andrea Mazzini on 26/05/15.\n+//  Copyright (c) 2015 Realm. All rights reserved.\n+//\n+\n+import SourceKittenFramework\n+\n+public struct ControlStatementRule: Rule {\n+    public init() {}\n+\n+    public let identifier = \"control_statement\"\n+\n+    public func validateFile(file: File) -> [StyleViolation] {\n+        let statement = file.matchPattern(\"\\\\s{0,}(if|for|while)\\\\s{0,}\\\\(\",\n+            withSyntaxKinds: [.Keyword])\n+        return statement.map { range in\n+            return StyleViolation(type: .ControlStatement,\n+                location: Location(file: file, offset: range.location),\n+                severity: .Low,\n+                reason: \"if,for,while,do statements shouldn't wrap their conditionals in parentheses.\")","path":"Source/SwiftLintFramework/Rules/ControlStatementRule.swift","position":23,"original_position":23,"commit_id":"383bd3de432c5d6248529c76890139388afcd7d9","original_commit_id":"383bd3de432c5d6248529c76890139388afcd7d9","user":{"login":"segiddins","id":1946610,"avatar_url":"https://avatars.githubusercontent.com/u/1946610?v=3","gravatar_id":"","url":"https://api.github.com/users/segiddins","html_url":"https://github.com/segiddins","followers_url":"https://api.github.com/users/segiddins/followers","following_url":"https://api.github.com/users/segiddins/following{/other_user}","gists_url":"https://api.github.com/users/segiddins/gists{/gist_id}","starred_url":"https://api.github.com/users/segiddins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segiddins/subscriptions","organizations_url":"https://api.github.com/users/segiddins/orgs","repos_url":"https://api.github.com/users/segiddins/repos","events_url":"https://api.github.com/users/segiddins/events{/privacy}","received_events_url":"https://api.github.com/users/segiddins/received_events","type":"User","site_admin":false},"body":"should probably use the regex match for the specific keyword instead of listing them all","created_at":"2015-05-26T20:09:46Z","updated_at":"2015-05-26T20:09:46Z","html_url":"https://github.com/realm/SwiftLint/pull/39#discussion_r31074145","pull_request_url":"https://api.github.com/repos/realm/SwiftLint/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/realm/SwiftLint/pulls/comments/31074145"},"html":{"href":"https://github.com/realm/SwiftLint/pull/39#discussion_r31074145"},"pull_request":{"href":"https://api.github.com/repos/realm/SwiftLint/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/realm/SwiftLint/pulls/39","id":36240308,"html_url":"https://github.com/realm/SwiftLint/pull/39","diff_url":"https://github.com/realm/SwiftLint/pull/39.diff","patch_url":"https://github.com/realm/SwiftLint/pull/39.patch","issue_url":"https://api.github.com/repos/realm/SwiftLint/issues/39","number":39,"state":"open","locked":false,"title":"Add ControlStatementRule","user":{"login":"andreamazz","id":570797,"avatar_url":"https://avatars.githubusercontent.com/u/570797?v=3","gravatar_id":"","url":"https://api.github.com/users/andreamazz","html_url":"https://github.com/andreamazz","followers_url":"https://api.github.com/users/andreamazz/followers","following_url":"https://api.github.com/users/andreamazz/following{/other_user}","gists_url":"https://api.github.com/users/andreamazz/gists{/gist_id}","starred_url":"https://api.github.com/users/andreamazz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreamazz/subscriptions","organizations_url":"https://api.github.com/users/andreamazz/orgs","repos_url":"https://api.github.com/users/andreamazz/repos","events_url":"https://api.github.com/users/andreamazz/events{/privacy}","received_events_url":"https://api.github.com/users/andreamazz/received_events","type":"User","site_admin":false},"body":"Hi @jpsim \r\nI've added the lint rule for `if`, `for`, `while` and `do` while statements as mentioned in one of the Todos in the test suite.","created_at":"2015-05-26T20:08:17Z","updated_at":"2015-05-26T20:09:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/realm/SwiftLint/pulls/39/commits","review_comments_url":"https://api.github.com/repos/realm/SwiftLint/pulls/39/comments","review_comment_url":"https://api.github.com/repos/realm/SwiftLint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/realm/SwiftLint/issues/39/comments","statuses_url":"https://api.github.com/repos/realm/SwiftLint/statuses/383bd3de432c5d6248529c76890139388afcd7d9","head":{"label":"andreamazz:control-statement","ref":"control-statement","sha":"383bd3de432c5d6248529c76890139388afcd7d9","user":{"login":"andreamazz","id":570797,"avatar_url":"https://avatars.githubusercontent.com/u/570797?v=3","gravatar_id":"","url":"https://api.github.com/users/andreamazz","html_url":"https://github.com/andreamazz","followers_url":"https://api.github.com/users/andreamazz/followers","following_url":"https://api.github.com/users/andreamazz/following{/other_user}","gists_url":"https://api.github.com/users/andreamazz/gists{/gist_id}","starred_url":"https://api.github.com/users/andreamazz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreamazz/subscriptions","organizations_url":"https://api.github.com/users/andreamazz/orgs","repos_url":"https://api.github.com/users/andreamazz/repos","events_url":"https://api.github.com/users/andreamazz/events{/privacy}","received_events_url":"https://api.github.com/users/andreamazz/received_events","type":"User","site_admin":false},"repo":{"id":36320583,"name":"SwiftLint","full_name":"andreamazz/SwiftLint","owner":{"login":"andreamazz","id":570797,"avatar_url":"https://avatars.githubusercontent.com/u/570797?v=3","gravatar_id":"","url":"https://api.github.com/users/andreamazz","html_url":"https://github.com/andreamazz","followers_url":"https://api.github.com/users/andreamazz/followers","following_url":"https://api.github.com/users/andreamazz/following{/other_user}","gists_url":"https://api.github.com/users/andreamazz/gists{/gist_id}","starred_url":"https://api.github.com/users/andreamazz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreamazz/subscriptions","organizations_url":"https://api.github.com/users/andreamazz/orgs","repos_url":"https://api.github.com/users/andreamazz/repos","events_url":"https://api.github.com/users/andreamazz/events{/privacy}","received_events_url":"https://api.github.com/users/andreamazz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andreamazz/SwiftLint","description":"An experimental tool to enforce Swift style and conventions.","fork":true,"url":"https://api.github.com/repos/andreamazz/SwiftLint","forks_url":"https://api.github.com/repos/andreamazz/SwiftLint/forks","keys_url":"https://api.github.com/repos/andreamazz/SwiftLint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andreamazz/SwiftLint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andreamazz/SwiftLint/teams","hooks_url":"https://api.github.com/repos/andreamazz/SwiftLint/hooks","issue_events_url":"https://api.github.com/repos/andreamazz/SwiftLint/issues/events{/number}","events_url":"https://api.github.com/repos/andreamazz/SwiftLint/events","assignees_url":"https://api.github.com/repos/andreamazz/SwiftLint/assignees{/user}","branches_url":"https://api.github.com/repos/andreamazz/SwiftLint/branches{/branch}","tags_url":"https://api.github.com/repos/andreamazz/SwiftLint/tags","blobs_url":"https://api.github.com/repos/andreamazz/SwiftLint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andreamazz/SwiftLint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andreamazz/SwiftLint/git/refs{/sha}","trees_url":"https://api.github.com/repos/andreamazz/SwiftLint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andreamazz/SwiftLint/statuses/{sha}","languages_url":"https://api.github.com/repos/andreamazz/SwiftLint/languages","stargazers_url":"https://api.github.com/repos/andreamazz/SwiftLint/stargazers","contributors_url":"https://api.github.com/repos/andreamazz/SwiftLint/contributors","subscribers_url":"https://api.github.com/repos/andreamazz/SwiftLint/subscribers","subscription_url":"https://api.github.com/repos/andreamazz/SwiftLint/subscription","commits_url":"https://api.github.com/repos/andreamazz/SwiftLint/commits{/sha}","git_commits_url":"https://api.github.com/repos/andreamazz/SwiftLint/git/commits{/sha}","comments_url":"https://api.github.com/repos/andreamazz/SwiftLint/comments{/number}","issue_comment_url":"https://api.github.com/repos/andreamazz/SwiftLint/issues/comments{/number}","contents_url":"https://api.github.com/repos/andreamazz/SwiftLint/contents/{+path}","compare_url":"https://api.github.com/repos/andreamazz/SwiftLint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andreamazz/SwiftLint/merges","archive_url":"https://api.github.com/repos/andreamazz/SwiftLint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andreamazz/SwiftLint/downloads","issues_url":"https://api.github.com/repos/andreamazz/SwiftLint/issues{/number}","pulls_url":"https://api.github.com/repos/andreamazz/SwiftLint/pulls{/number}","milestones_url":"https://api.github.com/repos/andreamazz/SwiftLint/milestones{/number}","notifications_url":"https://api.github.com/repos/andreamazz/SwiftLint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andreamazz/SwiftLint/labels{/name}","releases_url":"https://api.github.com/repos/andreamazz/SwiftLint/releases{/id}","created_at":"2015-05-26T20:02:46Z","updated_at":"2015-05-26T20:02:46Z","pushed_at":"2015-05-26T20:04:36Z","git_url":"git://github.com/andreamazz/SwiftLint.git","ssh_url":"git@github.com:andreamazz/SwiftLint.git","clone_url":"https://github.com/andreamazz/SwiftLint.git","svn_url":"https://github.com/andreamazz/SwiftLint","homepage":null,"size":708,"stargazers_count":0,"watchers_count":0,"language":"Swift","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":"realm:master","ref":"master","sha":"5bdd93dec88035089fefec5508bc7ad1d848fc11","user":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"repo":{"id":35732214,"name":"SwiftLint","full_name":"realm/SwiftLint","owner":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/realm/SwiftLint","description":"An experimental tool to enforce Swift style and conventions.","fork":false,"url":"https://api.github.com/repos/realm/SwiftLint","forks_url":"https://api.github.com/repos/realm/SwiftLint/forks","keys_url":"https://api.github.com/repos/realm/SwiftLint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realm/SwiftLint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realm/SwiftLint/teams","hooks_url":"https://api.github.com/repos/realm/SwiftLint/hooks","issue_events_url":"https://api.github.com/repos/realm/SwiftLint/issues/events{/number}","events_url":"https://api.github.com/repos/realm/SwiftLint/events","assignees_url":"https://api.github.com/repos/realm/SwiftLint/assignees{/user}","branches_url":"https://api.github.com/repos/realm/SwiftLint/branches{/branch}","tags_url":"https://api.github.com/repos/realm/SwiftLint/tags","blobs_url":"https://api.github.com/repos/realm/SwiftLint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realm/SwiftLint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realm/SwiftLint/git/refs{/sha}","trees_url":"https://api.github.com/repos/realm/SwiftLint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realm/SwiftLint/statuses/{sha}","languages_url":"https://api.github.com/repos/realm/SwiftLint/languages","stargazers_url":"https://api.github.com/repos/realm/SwiftLint/stargazers","contributors_url":"https://api.github.com/repos/realm/SwiftLint/contributors","subscribers_url":"https://api.github.com/repos/realm/SwiftLint/subscribers","subscription_url":"https://api.github.com/repos/realm/SwiftLint/subscription","commits_url":"https://api.github.com/repos/realm/SwiftLint/commits{/sha}","git_commits_url":"https://api.github.com/repos/realm/SwiftLint/git/commits{/sha}","comments_url":"https://api.github.com/repos/realm/SwiftLint/comments{/number}","issue_comment_url":"https://api.github.com/repos/realm/SwiftLint/issues/comments{/number}","contents_url":"https://api.github.com/repos/realm/SwiftLint/contents/{+path}","compare_url":"https://api.github.com/repos/realm/SwiftLint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realm/SwiftLint/merges","archive_url":"https://api.github.com/repos/realm/SwiftLint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realm/SwiftLint/downloads","issues_url":"https://api.github.com/repos/realm/SwiftLint/issues{/number}","pulls_url":"https://api.github.com/repos/realm/SwiftLint/pulls{/number}","milestones_url":"https://api.github.com/repos/realm/SwiftLint/milestones{/number}","notifications_url":"https://api.github.com/repos/realm/SwiftLint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realm/SwiftLint/labels{/name}","releases_url":"https://api.github.com/repos/realm/SwiftLint/releases{/id}","created_at":"2015-05-16T16:59:31Z","updated_at":"2015-05-26T19:37:46Z","pushed_at":"2015-05-26T20:08:17Z","git_url":"git://github.com/realm/SwiftLint.git","ssh_url":"git@github.com:realm/SwiftLint.git","clone_url":"https://github.com/realm/SwiftLint.git","svn_url":"https://github.com/realm/SwiftLint","homepage":null,"size":708,"stargazers_count":1298,"watchers_count":1298,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":21,"forks":45,"open_issues":21,"watchers":1298,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/realm/SwiftLint/pulls/39"},"html":{"href":"https://github.com/realm/SwiftLint/pull/39"},"issue":{"href":"https://api.github.com/repos/realm/SwiftLint/issues/39"},"comments":{"href":"https://api.github.com/repos/realm/SwiftLint/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/realm/SwiftLint/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/realm/SwiftLint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/realm/SwiftLint/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/realm/SwiftLint/statuses/383bd3de432c5d6248529c76890139388afcd7d9"}}}}