{"action":"created","comment":{"url":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/comments/227152219","pull_request_review_id":167126634,"id":227152219,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzE1MjIxOQ==","diff_hunk":"@@ -309,15 +313,16 @@ private class FindAndModifyOptions {\n             }\n         }\n \n-        if extra.keys.count > 0 && !mongoc_find_and_modify_opts_append(self._options, extra.data) {\n+        let appendSuccess = extra.keys.count <= 0 || mongoc_find_and_modify_opts_append(self._options, extra.data)","path":"Sources/MongoSwift/MongoCollection+FindAndModify.swift","position":42,"original_position":42,"commit_id":"9daf9dfb08987c8a68191e54eb89e59c8a75869d","original_commit_id":"9daf9dfb08987c8a68191e54eb89e59c8a75869d","user":{"login":"kmahar","id":5976377,"node_id":"MDQ6VXNlcjU5NzYzNzc=","avatar_url":"https://avatars0.githubusercontent.com/u/5976377?v=4","gravatar_id":"","url":"https://api.github.com/users/kmahar","html_url":"https://github.com/kmahar","followers_url":"https://api.github.com/users/kmahar/followers","following_url":"https://api.github.com/users/kmahar/following{/other_user}","gists_url":"https://api.github.com/users/kmahar/gists{/gist_id}","starred_url":"https://api.github.com/users/kmahar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmahar/subscriptions","organizations_url":"https://api.github.com/users/kmahar/orgs","repos_url":"https://api.github.com/users/kmahar/repos","events_url":"https://api.github.com/users/kmahar/events{/privacy}","received_events_url":"https://api.github.com/users/kmahar/received_events","type":"User","site_admin":false},"body":"lol oops didn't see your comment came in as I was writing mine :) \r\n\r\nI'm fine with either suggestion of yours, so long as we use `isEmpty` directly on the doc rather than on the keys array, for the reasons explained in my above comment.","created_at":"2018-10-22T21:54:50Z","updated_at":"2018-10-22T21:54:50Z","html_url":"https://github.com/mongodb/mongo-swift-driver/pull/125#discussion_r227152219","pull_request_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/125","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/comments/227152219"},"html":{"href":"https://github.com/mongodb/mongo-swift-driver/pull/125#discussion_r227152219"},"pull_request":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/125"}},"in_reply_to_id":227141624},"pull_request":{"url":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/125","id":224781231,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI0NzgxMjMx","html_url":"https://github.com/mongodb/mongo-swift-driver/pull/125","diff_url":"https://github.com/mongodb/mongo-swift-driver/pull/125.diff","patch_url":"https://github.com/mongodb/mongo-swift-driver/pull/125.patch","issue_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/issues/125","number":125,"state":"open","locked":false,"title":"SWIFT-201: Refactor \"if failure\" conditions with guard statements","user":{"login":"Utagai","id":10730394,"node_id":"MDQ6VXNlcjEwNzMwMzk0","avatar_url":"https://avatars2.githubusercontent.com/u/10730394?v=4","gravatar_id":"","url":"https://api.github.com/users/Utagai","html_url":"https://github.com/Utagai","followers_url":"https://api.github.com/users/Utagai/followers","following_url":"https://api.github.com/users/Utagai/following{/other_user}","gists_url":"https://api.github.com/users/Utagai/gists{/gist_id}","starred_url":"https://api.github.com/users/Utagai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Utagai/subscriptions","organizations_url":"https://api.github.com/users/Utagai/orgs","repos_url":"https://api.github.com/users/Utagai/repos","events_url":"https://api.github.com/users/Utagai/events{/privacy}","received_events_url":"https://api.github.com/users/Utagai/received_events","type":"User","site_admin":false},"body":"[SWIFT-201](https://jira.mongodb.org/browse/SWIFT-201)\r\n\r\nThis PR finds places in the entire codebase where we should probably be using `guard` instead of an `if` statement.\r\n\r\nGenerally speaking, it seems like `guard` should be used to catch or, _guard_ against exceptional violations of (an) assumption(s) or invariant(s) in the rest of the current scope. Usually, this is involved with condition checks at the beginning of functions or protecting oneself from exceptional failures, e.g., calls to `mongoc_*` functions. Therefore, there may be a few cases where a `guard` is added for something that is not an explicit failure.\r\n\r\nI've used the above idea to determine when to use `guard`. Since I essentially looked through the entire codebase, it is possible that I have missed some cases. If you think I've missed anything, just suggest it :). ","created_at":"2018-10-22T19:07:55Z","updated_at":"2018-10-22T21:54:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b598e886ca00aff83baff4c123e512c578b4c40","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/125/commits","review_comments_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/125/comments","review_comment_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/issues/125/comments","statuses_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/statuses/9daf9dfb08987c8a68191e54eb89e59c8a75869d","head":{"label":"Utagai:SWIFT-201","ref":"SWIFT-201","sha":"9daf9dfb08987c8a68191e54eb89e59c8a75869d","user":{"login":"Utagai","id":10730394,"node_id":"MDQ6VXNlcjEwNzMwMzk0","avatar_url":"https://avatars2.githubusercontent.com/u/10730394?v=4","gravatar_id":"","url":"https://api.github.com/users/Utagai","html_url":"https://github.com/Utagai","followers_url":"https://api.github.com/users/Utagai/followers","following_url":"https://api.github.com/users/Utagai/following{/other_user}","gists_url":"https://api.github.com/users/Utagai/gists{/gist_id}","starred_url":"https://api.github.com/users/Utagai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Utagai/subscriptions","organizations_url":"https://api.github.com/users/Utagai/orgs","repos_url":"https://api.github.com/users/Utagai/repos","events_url":"https://api.github.com/users/Utagai/events{/privacy}","received_events_url":"https://api.github.com/users/Utagai/received_events","type":"User","site_admin":false},"repo":{"id":153830140,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM4MzAxNDA=","name":"mongo-swift-driver","full_name":"Utagai/mongo-swift-driver","private":false,"owner":{"login":"Utagai","id":10730394,"node_id":"MDQ6VXNlcjEwNzMwMzk0","avatar_url":"https://avatars2.githubusercontent.com/u/10730394?v=4","gravatar_id":"","url":"https://api.github.com/users/Utagai","html_url":"https://github.com/Utagai","followers_url":"https://api.github.com/users/Utagai/followers","following_url":"https://api.github.com/users/Utagai/following{/other_user}","gists_url":"https://api.github.com/users/Utagai/gists{/gist_id}","starred_url":"https://api.github.com/users/Utagai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Utagai/subscriptions","organizations_url":"https://api.github.com/users/Utagai/orgs","repos_url":"https://api.github.com/users/Utagai/repos","events_url":"https://api.github.com/users/Utagai/events{/privacy}","received_events_url":"https://api.github.com/users/Utagai/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Utagai/mongo-swift-driver","description":"The Swift driver for MongoDB","fork":true,"url":"https://api.github.com/repos/Utagai/mongo-swift-driver","forks_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/forks","keys_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/teams","hooks_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/hooks","issue_events_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/issues/events{/number}","events_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/events","assignees_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/assignees{/user}","branches_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/branches{/branch}","tags_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/tags","blobs_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/languages","stargazers_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/stargazers","contributors_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/contributors","subscribers_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/subscribers","subscription_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/subscription","commits_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/contents/{+path}","compare_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/merges","archive_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/downloads","issues_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/issues{/number}","pulls_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/labels{/name}","releases_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/releases{/id}","deployments_url":"https://api.github.com/repos/Utagai/mongo-swift-driver/deployments","created_at":"2018-10-19T19:12:02Z","updated_at":"2018-10-22T16:50:40Z","pushed_at":"2018-10-22T20:12:01Z","git_url":"git://github.com/Utagai/mongo-swift-driver.git","ssh_url":"git@github.com:Utagai/mongo-swift-driver.git","clone_url":"https://github.com/Utagai/mongo-swift-driver.git","svn_url":"https://github.com/Utagai/mongo-swift-driver","homepage":"","size":6928,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mongodb:master","ref":"master","sha":"e98bdf5806458caf911db56aa5e7aed67d41b5bd","user":{"login":"mongodb","id":45120,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1MTIw","avatar_url":"https://avatars1.githubusercontent.com/u/45120?v=4","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"repo":{"id":118030974,"node_id":"MDEwOlJlcG9zaXRvcnkxMTgwMzA5NzQ=","name":"mongo-swift-driver","full_name":"mongodb/mongo-swift-driver","private":false,"owner":{"login":"mongodb","id":45120,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1MTIw","avatar_url":"https://avatars1.githubusercontent.com/u/45120?v=4","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/mongodb/mongo-swift-driver","description":"The Swift driver for MongoDB","fork":false,"url":"https://api.github.com/repos/mongodb/mongo-swift-driver","forks_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/forks","keys_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/teams","hooks_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/hooks","issue_events_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/events","assignees_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/tags","blobs_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/languages","stargazers_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/stargazers","contributors_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/contributors","subscribers_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/subscribers","subscription_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/subscription","commits_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/merges","archive_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/downloads","issues_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/labels{/name}","releases_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/releases{/id}","deployments_url":"https://api.github.com/repos/mongodb/mongo-swift-driver/deployments","created_at":"2018-01-18T19:55:11Z","updated_at":"2018-10-22T16:49:25Z","pushed_at":"2018-10-22T19:07:56Z","git_url":"git://github.com/mongodb/mongo-swift-driver.git","ssh_url":"git@github.com:mongodb/mongo-swift-driver.git","clone_url":"https://github.com/mongodb/mongo-swift-driver.git","svn_url":"https://github.com/mongodb/mongo-swift-driver","homepage":"","size":6898,"stargazers_count":56,"watchers_count":56,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":9,"open_issues":4,"watchers":56,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/125"},"html":{"href":"https://github.com/mongodb/mongo-swift-driver/pull/125"},"issue":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/issues/125"},"comments":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/issues/125/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/125/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/pulls/125/commits"},"statuses":{"href":"https://api.github.com/repos/mongodb/mongo-swift-driver/statuses/9daf9dfb08987c8a68191e54eb89e59c8a75869d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kmahar"}}