зеркало из https://github.com/github/codeql.git
C++: Initial .qhelp file
This commit is contained in:
Родитель
dca13f5c89
Коммит
0e9b77e7c3
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Here, the comma should have been a semicolon:
|
||||
*/
|
||||
|
||||
enum privileges entitlements = NONE;
|
||||
|
||||
if (is_admin)
|
||||
entitlements = FULL, // BAD
|
||||
|
||||
restrict_privileges(entitlements);
|
||||
|
||||
/*
|
||||
* This is misleading, because the code is unexpectedly equivalent to:
|
||||
*/
|
||||
|
||||
enum privileges entitlements = NONE;
|
||||
|
||||
if (is_admin) {
|
||||
entitlements = FULL;
|
||||
restrict_privileges(entitlements);
|
||||
}
|
||||
|
||||
/*
|
||||
* Whereas the following code was probably intended:
|
||||
*/
|
||||
|
||||
enum privileges entitlements = NONE;
|
||||
|
||||
if (is_admin)
|
||||
entitlements = FULL; // GOOD
|
||||
|
||||
restrict_privileges(entitlements);
|
|
@ -4,11 +4,17 @@
|
|||
<qhelp>
|
||||
|
||||
<overview>
|
||||
<p>...</p>
|
||||
<p>
|
||||
If the expression to the right of a comma operator starts at an earlier column than the expression to the left, then
|
||||
this suspicious indentation likely indicates a logic error caused by a typo that may escape visual inspection.
|
||||
</p>
|
||||
</overview>
|
||||
|
||||
<recommendation>
|
||||
<p>...</p>
|
||||
<p>
|
||||
Use standard indentation around the comma operator: begin the right-hand-side operand at the same level of
|
||||
indentation as the left-hand-side operand.
|
||||
</p>
|
||||
</recommendation>
|
||||
|
||||
<example>
|
||||
|
|
Загрузка…
Ссылка в новой задаче