WebKit Bugzilla
Attachment 362479 Details for
Bug 194848
: [Code Style] Functions returning void
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194848-20190219205012.patch (text/plain), 2.61 KB, created by
Daniel Bates
on 2019-02-19 20:50:13 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2019-02-19 20:50:13 PST
Size:
2.61 KB
patch
obsolete
>Subversion Revision: 241559 >diff --git a/Websites/webkit.org/ChangeLog b/Websites/webkit.org/ChangeLog >index 47e3d220d054772d09e56c678612901a43b852fc..aedcda3999fc16e011844198cb7311d13537eb93 100644 >--- a/Websites/webkit.org/ChangeLog >+++ b/Websites/webkit.org/ChangeLog >@@ -1,3 +1,19 @@ >+2019-02-19 Daniel Bates <dabates@apple.com> >+ >+ [Code Style] Functions returning void >+ https://bugs.webkit.org/show_bug.cgi?id=194848 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Codify policy on how to write return statements in functions returning void. In such functions, >+ the return statement should be expression-less and written on its own line. If after writing the >+ return statement on its own line its effect is equivalent to falling off the end of the function >+ then it should be omitted. >+ >+ This policy was discussed on webkit-dev in the thread that starts at <https://lists.webkit.org/pipermail/webkit-dev/2019-February/030439.html>. >+ >+ * code-style.md: >+ > 2019-02-07 Jon Davis <jond@apple.com> > > Fixed animation positioning when homepage animation completes >diff --git a/Websites/webkit.org/code-style.md b/Websites/webkit.org/code-style.md >index 0b71e8d6666d4cea08ac951983b6c01a8543e5b0..37ef088c4039a176fecbede0f6da761c7c5459e8 100644 >--- a/Websites/webkit.org/code-style.md >+++ b/Websites/webkit.org/code-style.md >@@ -362,6 +362,62 @@ if (condition) { > } > ``` > >+[](#linebreaking-return-void) In functions that return void, the `return` statement should not have an expression and should be written on its own line. A `return` statement on its own line should be omitted entirely if it has the same effect as falling off the end of the function. >+ >+###### Right: >+ >+```cpp >+void PolicyChecker::checkNewWindowPolicy() >+{ >+ if (condition) { >+ f(ShouldContinue::No); >+ return; >+ } >+ f(ShouldContinue::Yes); >+} >+``` >+ >+###### Wrong: >+ >+```cpp >+void PolicyChecker::checkNewWindowPolicy() >+{ >+ if (condition) >+ return f(ShouldContinue::No); >+ return f(ShouldContinue::Yes); >+} >+``` >+ >+###### Right: >+ >+```cpp >+void PolicyChecker::checkNavigationPolicy() >+{ >+ switch (condition) { >+ case fooCondition: >+ case barCondition: >+ f(ShouldContinue::Yes) >+ return; >+ } >+ f(ShouldContinue::No); >+} >+``` >+ >+###### Wrong: >+ >+```cpp >+void PolicyChecker::checkNavigationPolicy() >+{ >+ switch (condition) { >+ case fooCondition: >+ case barCondition: >+ return f(ShouldContinue::Yes) >+ } >+ f(ShouldContinue::No); >+ return; >+} >+``` >+ > ### Braces > > [](#braces-function) Function definitions: place each brace on its own line.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
rniwa
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194848
: 362479