mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
C++: Initial .qhelp file
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user