ä¸ã®ä¸ã®ã³ã¼ãã£ã³ã°è¦ç´çã«ã¯ã©ããªã®ããªã¨æã£ãã®ã§ã¡ãã£ã¨èª¿ã¹ããä¸æ¬å¼§ä»ããæ¹ãå¤ãæ°ãããã
C or C++
In general, curly braces are not required for single-line statements, but they are allowed if you like them; conditional or loop statements with complex conditions or statements may be more readable with curly braces. Some projects require that an if must always always have an accompanying brace.
Google C++ Style Guide
æ¬å¼§ãªãOK
High Integrity C++ Coding Standard
Follow each control flow primitive (if, else, while, for, do and switch) by a block enclosed by braces, even if the block is empty or contains only one line. Use of null statements or statement expressions in these contexts reduces code readability and making it harder to maintain.
6.1.1 Enclose the body of a selection or an iteration statement in a compound statement | High Integrity C++ Coding Standard
æ¬å¼§å¿ é
CERT C++ Secure Coding Standard
Opening and closing braces for if, for, and while statements should always be used even if the statement's body contains only a single statement.
EXP19-C. Use braces for the body of an if, for, or while statement - Secure Coding - CERT Secure Coding Standards
æ¬å¼§å¿ é
Applied Informatics
The placement of braces seems to have been the subject of the greatest
www.appinf.com/download/CppCodingStyleGuide.pdf
debate concerning the appearance of both C and C++ code. We recommend
a style that, in our opinion, gives the most readable code. Other styles may
well provide more compact code.
表ç¾ãå¾®å¦ãå¤åãæ¬å¼§æ¨å¥¨
Possibility
All if, while and do statements must either have braces or be on a single line.
C++ Coding Standard
æ¬å¼§å¿ é
JOINT STRIKE FIGHTER AIR VEHICLE
AV Rule 59 (MISRA Rule 59, Revised)
www.stroustrup.com/JSF-AV-rules.pdf
The statements forming the body of an if, else if, else, while, doâ¦while or for statement shall
always be enclosed in braces, even if the braces form an empty block.
æ¬å¼§å¿ é
Uwyn
Always Uses Braces Form, even if there is only a single statement within the braces.
Uwyn - C++ coding standard - Braces Usage
æ¬å¼§å¿ é
Java
Oracle
Note: if statements always use braces, {}. Avoid the following error-prone form:
Code Conventions for the Java Programming Language: 7. Statements
æ¬å¼§å¿ é
4.1.1 Braces are used where optional
Braces are used with if, else, for, do and while statements, even when the body is empty or contains only a single statement.
Google Java Style
æ¬å¼§å¿ é
Douglas Crockford
Braces are used around all statements, even single statements, when they are part of a
javascript.crockford.com/javacodeconventions.pdf
control structure, such as a if-else or for statement. This makes it easier to add
statements without accidentally introducing bugs due to forgetting to add braces.
æ¬å¼§å¿ é
PHP
PSR-2
The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body.
PSR-2 — Coding Style Guide
æ¬å¼§å¿ é
PEAR
You are strongly encouraged to always use curly braces even in situations where they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added.
Manual :: Control Structures
æ¬å¼§æ¨å¥¨
Symphony
Use braces to indicate control structure body regardless of the number of statements it contains;
Coding Standards (Contributing to Symfony)
æ¬å¼§å¿ é
Zend Framework
PHP allows statements to be written without braces in some circumstances. This coding standard makes no differentiation- all "if", "elseif" or "else" statements must use braces.
Coding Style - Zend Framework Coding Standard for PHP - Zend Framework
æ¬å¼§å¿ é
WordPress
Braces should always be used, even when they are not required:
WordPress › PHP Coding Standards « Make WordPress Core
æ¬å¼§å¿ é