{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/143723215","pull_request_review_id":68274988,"id":143723215,"diff_hunk":"@@ -0,0 +1,120 @@\n+# C++ style guide\n+\n+Unfortunately, the C++ linter (based on\n+[Google’s `cpplint`](https://github.com/google/styleguide)), which can be run\n+explicitly via `make cpplint`, does not currently catch a lot of rules that are\n+specific to the Node.js C++ code base. This document explains the most common of\n+these rules:\n+\n+## Left-leaning (C++ style) asterisks for pointer declarations\n+\n+`char* buffer;` instead of `char *buffer;`\n+\n+## 2 spaces of indentation for blocks or bodies of conditionals\n+\n+```c++\n+if (foo)\n+  bar();\n+```\n+\n+or\n+\n+```c++\n+if (foo) {\n+  bar();\n+  baz();\n+}\n+```\n+\n+(Braces are optional if the statement body only has one line.)\n+\n+## 4 spaces of indentation for statement continuations\n+\n+```c++\n+VeryLongTypeName very_long_result = SomeValueWithAVeryLongName +\n+    SomeOtherValueWithAVeryLongName;\n+```\n+\n+## Align function arguments vertically\n+\n+```c++\n+void FunctionWithAVeryLongName(int parameter_with_a_very_long_name,\n+                               double other_parameter_with_a_very_long_name,\n+                               ...);\n+```\n+\n+If that doesn’t work, break after the `(` and use 4 spaces of indentation:\n+\n+```c++\n+void FunctionWithAReallyReallyReallyLongNameSeriouslyStopIt(\n+    int okay_there_is_no_space_left_in_the_previous_line,\n+    ...);\n+```\n+\n+## CamelCase for methods, functions and classes\n+\n+Exceptions are simple getters/setters, which are named `property_name()` and\n+`set_property_name()`, respectively.\n+\n+```c++\n+class FooBar {\n+ public:\n+  void DoSomething();\n+  static void DoSomethingButItsStaticInstead();\n+\n+  void set_foo_flag(int flag_value);\n+  int foo_flag() const;  // Use const-correctness whenever possible.\n+};\n+```\n+\n+## snake\\_case for local variables and parameters\n+\n+```c++\n+int FunctionThatDoesSomething(const char* important_string) {\n+  const char* pointer_into_string = important_string;\n+}\n+```\n+\n+## snake\\_case\\_ for private class fields\n+\n+```c++\n+class Foo {\n+ private:\n+  int counter_ = 0;\n+};\n+```\n+\n+## Space after `template`\n+\n+```c++\n+template <typename T>\n+class FancyContainer {\n+ ...\n+}\n+```\n+\n+## Type casting\n+\n+- Always avoid C-style casts (`(type)value`)\n+- `dynamic_cast` does not work because RTTI is not enabled\n+- Use `static_cast` for casting whenever it works\n+- `reinterpret_cast` is okay if `static_cast` is not appropriate\n+\n+## Memory allocation","path":"CPP_STYLE_GUIDE.md","position":103,"original_position":103,"commit_id":"78d870e5482b6e299ccd104714ed983d63598afe","original_commit_id":"78d870e5482b6e299ccd104714ed983d63598afe","user":{"login":"addaleax","id":899444,"avatar_url":"https://avatars2.githubusercontent.com/u/899444?v=4","gravatar_id":"","url":"https://api.github.com/users/addaleax","html_url":"https://github.com/addaleax","followers_url":"https://api.github.com/users/addaleax/followers","following_url":"https://api.github.com/users/addaleax/following{/other_user}","gists_url":"https://api.github.com/users/addaleax/gists{/gist_id}","starred_url":"https://api.github.com/users/addaleax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addaleax/subscriptions","organizations_url":"https://api.github.com/users/addaleax/orgs","repos_url":"https://api.github.com/users/addaleax/repos","events_url":"https://api.github.com/users/addaleax/events{/privacy}","received_events_url":"https://api.github.com/users/addaleax/received_events","type":"User","site_admin":false},"body":"Do you have any specific question? I realize this isn’t helpful when it comes to which-do-I-use, but then again we don’t really follow any specific rules for this right now. (I assume @bnoordhuis is a fan of just aborting in OOM situations, me not so much. :smile:)","created_at":"2017-10-10T13:16:12Z","updated_at":"2017-10-10T13:16:12Z","html_url":"https://github.com/nodejs/node/pull/16090#discussion_r143723215","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/16090","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/143723215"},"html":{"href":"https://github.com/nodejs/node/pull/16090#discussion_r143723215"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/16090"}},"in_reply_to_id":143537036},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/16090","id":145349466,"html_url":"https://github.com/nodejs/node/pull/16090","diff_url":"https://github.com/nodejs/node/pull/16090.diff","patch_url":"https://github.com/nodejs/node/pull/16090.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/16090","number":16090,"state":"open","locked":false,"title":"doc: add basic C++ style guide","user":{"login":"addaleax","id":899444,"avatar_url":"https://avatars2.githubusercontent.com/u/899444?v=4","gravatar_id":"","url":"https://api.github.com/users/addaleax","html_url":"https://github.com/addaleax","followers_url":"https://api.github.com/users/addaleax/followers","following_url":"https://api.github.com/users/addaleax/following{/other_user}","gists_url":"https://api.github.com/users/addaleax/gists{/gist_id}","starred_url":"https://api.github.com/users/addaleax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addaleax/subscriptions","organizations_url":"https://api.github.com/users/addaleax/orgs","repos_url":"https://api.github.com/users/addaleax/repos","events_url":"https://api.github.com/users/addaleax/events{/privacy}","received_events_url":"https://api.github.com/users/addaleax/received_events","type":"User","site_admin":false},"body":"Ideally, most of these things would be enforced via linter rules. This is a first step into having a style guide that goes beyond what the linter currently enforces.\r\n\r\nThis is probably relevant to most of: @bnoordhuis @jasnell @TimothyGu @trevnorris @danbev @eugeneo @nodejs/n-api ","created_at":"2017-10-08T19:31:15Z","updated_at":"2017-10-10T13:16:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ee0f52e02b5c098562e8d158ebf02edda6d27ce","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/16090/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/16090/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/16090/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/78d870e5482b6e299ccd104714ed983d63598afe","head":{"label":"addaleax:cpp-style-guide","ref":"cpp-style-guide","sha":"78d870e5482b6e299ccd104714ed983d63598afe","user":{"login":"addaleax","id":899444,"avatar_url":"https://avatars2.githubusercontent.com/u/899444?v=4","gravatar_id":"","url":"https://api.github.com/users/addaleax","html_url":"https://github.com/addaleax","followers_url":"https://api.github.com/users/addaleax/followers","following_url":"https://api.github.com/users/addaleax/following{/other_user}","gists_url":"https://api.github.com/users/addaleax/gists{/gist_id}","starred_url":"https://api.github.com/users/addaleax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addaleax/subscriptions","organizations_url":"https://api.github.com/users/addaleax/orgs","repos_url":"https://api.github.com/users/addaleax/repos","events_url":"https://api.github.com/users/addaleax/events{/privacy}","received_events_url":"https://api.github.com/users/addaleax/received_events","type":"User","site_admin":false},"repo":{"id":47707342,"name":"node","full_name":"addaleax/node","owner":{"login":"addaleax","id":899444,"avatar_url":"https://avatars2.githubusercontent.com/u/899444?v=4","gravatar_id":"","url":"https://api.github.com/users/addaleax","html_url":"https://github.com/addaleax","followers_url":"https://api.github.com/users/addaleax/followers","following_url":"https://api.github.com/users/addaleax/following{/other_user}","gists_url":"https://api.github.com/users/addaleax/gists{/gist_id}","starred_url":"https://api.github.com/users/addaleax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addaleax/subscriptions","organizations_url":"https://api.github.com/users/addaleax/orgs","repos_url":"https://api.github.com/users/addaleax/repos","events_url":"https://api.github.com/users/addaleax/events{/privacy}","received_events_url":"https://api.github.com/users/addaleax/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/addaleax/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":true,"url":"https://api.github.com/repos/addaleax/node","forks_url":"https://api.github.com/repos/addaleax/node/forks","keys_url":"https://api.github.com/repos/addaleax/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/addaleax/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/addaleax/node/teams","hooks_url":"https://api.github.com/repos/addaleax/node/hooks","issue_events_url":"https://api.github.com/repos/addaleax/node/issues/events{/number}","events_url":"https://api.github.com/repos/addaleax/node/events","assignees_url":"https://api.github.com/repos/addaleax/node/assignees{/user}","branches_url":"https://api.github.com/repos/addaleax/node/branches{/branch}","tags_url":"https://api.github.com/repos/addaleax/node/tags","blobs_url":"https://api.github.com/repos/addaleax/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/addaleax/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/addaleax/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/addaleax/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/addaleax/node/statuses/{sha}","languages_url":"https://api.github.com/repos/addaleax/node/languages","stargazers_url":"https://api.github.com/repos/addaleax/node/stargazers","contributors_url":"https://api.github.com/repos/addaleax/node/contributors","subscribers_url":"https://api.github.com/repos/addaleax/node/subscribers","subscription_url":"https://api.github.com/repos/addaleax/node/subscription","commits_url":"https://api.github.com/repos/addaleax/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/addaleax/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/addaleax/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/addaleax/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/addaleax/node/contents/{+path}","compare_url":"https://api.github.com/repos/addaleax/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/addaleax/node/merges","archive_url":"https://api.github.com/repos/addaleax/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/addaleax/node/downloads","issues_url":"https://api.github.com/repos/addaleax/node/issues{/number}","pulls_url":"https://api.github.com/repos/addaleax/node/pulls{/number}","milestones_url":"https://api.github.com/repos/addaleax/node/milestones{/number}","notifications_url":"https://api.github.com/repos/addaleax/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/addaleax/node/labels{/name}","releases_url":"https://api.github.com/repos/addaleax/node/releases{/id}","deployments_url":"https://api.github.com/repos/addaleax/node/deployments","created_at":"2015-12-09T17:26:30Z","updated_at":"2016-03-24T02:52:12Z","pushed_at":"2017-10-08T21:41:58Z","git_url":"git://github.com/addaleax/node.git","ssh_url":"git@github.com:addaleax/node.git","clone_url":"https://github.com/addaleax/node.git","svn_url":"https://github.com/addaleax/node","homepage":"https://nodejs.org","size":307454,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"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":"nodejs:master","ref":"master","sha":"037d9085f1d1ed996dc8f4958b4e7f5e53a6fa39","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars3.githubusercontent.com/u/9950313?v=4","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"node","full_name":"nodejs/node","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars3.githubusercontent.com/u/9950313?v=4","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":false,"url":"https://api.github.com/repos/nodejs/node","forks_url":"https://api.github.com/repos/nodejs/node/forks","keys_url":"https://api.github.com/repos/nodejs/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node/teams","hooks_url":"https://api.github.com/repos/nodejs/node/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node/events","assignees_url":"https://api.github.com/repos/nodejs/node/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node/tags","blobs_url":"https://api.github.com/repos/nodejs/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node/languages","stargazers_url":"https://api.github.com/repos/nodejs/node/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node/subscription","commits_url":"https://api.github.com/repos/nodejs/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node/merges","archive_url":"https://api.github.com/repos/nodejs/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node/downloads","issues_url":"https://api.github.com/repos/nodejs/node/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node/releases{/id}","deployments_url":"https://api.github.com/repos/nodejs/node/deployments","created_at":"2014-11-26T19:57:11Z","updated_at":"2017-10-10T13:09:26Z","pushed_at":"2017-10-10T13:14:38Z","git_url":"git://github.com/nodejs/node.git","ssh_url":"git@github.com:nodejs/node.git","clone_url":"https://github.com/nodejs/node.git","svn_url":"https://github.com/nodejs/node","homepage":"https://nodejs.org","size":320424,"stargazers_count":40337,"watchers_count":40337,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8372,"mirror_url":null,"open_issues_count":888,"forks":8372,"open_issues":888,"watchers":40337,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/16090"},"html":{"href":"https://github.com/nodejs/node/pull/16090"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/16090"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/16090/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/16090/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/16090/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/78d870e5482b6e299ccd104714ed983d63598afe"}},"author_association":"OWNER"}}
{"actor":{"display_login":"addaleax"}}