mirror of
https://github.com/tiennm99/styleguide.git
synced 2026-08-02 12:21:22 +00:00
Update C++ style guide to 3.274:
- Change formatting rules of braced initializers. - Permit use of constexpr and allow constexpr global variables. - Allow all C++11 features except for those that are specifically banned. - Fix/add C99 format specifiers for ptrdiff_t and ssize_t. - Add lambda expressions to the list of explicitly banned C++11 features. - Relax "return type is always on the same line as the function name" rule. - Allow unique_ptr, discourage ownership transfer. Allow noncopyable std::move. - Allow system-specific includes after other includes. - Add boost/math/distributions to the set of permitted Boost libraries. Update Objective-C style guide to 2.59: - Use instancetype as return type for example init methods. - Remove invalid +stringWithInt: call. - Remove reference to pre-Objective-C 2.0 declaration requirements. - Remove reference to Objective-C exception macros. - Remove reference to informal protocols as an alternative to optional methods. - Class headers should include comments documenting non-trivial interfaces. - Don't specify that blocks are preferable to methods as callbacks. - Specify "strong" and "weak" as comments for non-Objective-C pointers. - Replace improper reference to ownership of a retained object. - Clarify some aspects of method ordering rules. - Prefixes are required for shared code and optional for applications. - Clarify that nil pointers are safe as receivers, not necessarily parameters. - Clarify that delegate pointers should typically be zeroing weak pointers. - Allow a 100-column limit, except for projects that choose to use 80. Update Python style guide to 2.59: - Add more examples of bad code to the default arguments section. - Allow ''' when ' is used as the single quote within a file. - Remove references to pychecker. Recommend pylint. - Add more examples to the indentation section. Update JavaScript style guide to 2.93: - Add @nocompile. - Fix a few typos. - When wrapping lines, indent more deeply for child expressions. - Document that @const can be used on a constructor. - Update eval section to discourage using eval for RPC. - Update an example to avoid encouraging using numbers as booleans. - Allow for no indentation of @desc jsdoc tags. - Add @public discussion. Update shell style guide to 1.26: - Add a section on style for case statements. Update Common Lisp style guide to 1.23: - fare-matcher was superseded by optima. - Clarify wording regarding DYNAMIC-EXTENT.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
<p align="right">
|
||||
|
||||
Revision 1.25
|
||||
Revision 1.26
|
||||
</p>
|
||||
|
||||
|
||||
@@ -393,6 +393,73 @@ Revision 1.25
|
||||
</BODY>
|
||||
</STYLEPOINT>
|
||||
|
||||
<STYLEPOINT title="Case statement">
|
||||
<SUMMARY>
|
||||
<ul>
|
||||
<li>
|
||||
Indent alternatives by 2 spaces.
|
||||
</li>
|
||||
<li>
|
||||
A one-line alternative needs a space after the close parenthesis of
|
||||
the pattern and before the <code>;;</code>.
|
||||
</li>
|
||||
<li>
|
||||
Long or multi-command alternatives should be split over multiple
|
||||
lines with the pattern, actions, and <code>;;</code> on separate
|
||||
lines.
|
||||
</li>
|
||||
</ul>
|
||||
</SUMMARY>
|
||||
<BODY>
|
||||
<p>
|
||||
The matching expressions are indented one level from the 'case' and
|
||||
'esac'. Multiline actions are indented another level. In general,
|
||||
there is no need to quote match expressions. Pattern expressions
|
||||
should not be preceded by an open parenthesis. Avoid the
|
||||
<code>;&</code> and <code>;;&</code> notations.
|
||||
</p>
|
||||
<CODE_SNIPPET>
|
||||
case "${expression}" in
|
||||
a)
|
||||
variable="..."
|
||||
some_command "${variable}" "${other_expr}" ...
|
||||
;;
|
||||
absolute)
|
||||
actions="relative"
|
||||
another_command "${actions}" "${other_expr}" ...
|
||||
;;
|
||||
*)
|
||||
error "Unexpected expression '${expression}'"
|
||||
;;
|
||||
esac
|
||||
</CODE_SNIPPET>
|
||||
<p>
|
||||
Simple commands may be put on the same line as the pattern <i>and</i>
|
||||
<code>;;</code> as long as the expression remains readable. This is
|
||||
often appropriate for single-letter option processing. When the
|
||||
actions don't fit on a single line, put the pattern on a line on its
|
||||
own, then the actions, then <code>;;</code> also on a line of its own.
|
||||
When on the same line as the actions, use a space after the close
|
||||
parenthesis of the pattern and another before the <code>;;</code>.
|
||||
</p>
|
||||
<CODE_SNIPPET>
|
||||
verbose='false'
|
||||
aflag=''
|
||||
bflag=''
|
||||
files=''
|
||||
while getopts 'abf:v' flag; do
|
||||
case "${flag}" in
|
||||
a) aflag='true' ;;
|
||||
b) bflag='true' ;;
|
||||
f) files="${OPTARG}" ;;
|
||||
v) verbose='true' ;;
|
||||
*) error "Unexpected option ${flag}" ;;
|
||||
esac
|
||||
done
|
||||
</CODE_SNIPPET>
|
||||
</BODY>
|
||||
</STYLEPOINT>
|
||||
|
||||
<STYLEPOINT title="Variable expansion">
|
||||
<SUMMARY>
|
||||
In order of precedence: Stay consistent with what you find;
|
||||
@@ -856,9 +923,7 @@ Revision 1.25
|
||||
VERBOSE='false'
|
||||
while getopts 'v' flag; do
|
||||
case "${flag}" in
|
||||
'v')
|
||||
VERBOSE='true'
|
||||
;;
|
||||
v) VERBOSE='true' ;;
|
||||
esac
|
||||
done
|
||||
readonly VERBOSE
|
||||
@@ -1081,7 +1146,7 @@ Revision 1.25
|
||||
</CATEGORY>
|
||||
|
||||
<p align="right">
|
||||
Revision 1.25
|
||||
Revision 1.26
|
||||
</p>
|
||||
|
||||
</GUIDE>
|
||||
|
||||
Reference in New Issue
Block a user