C++: Initial .qhelp file

This commit is contained in:
Nora Dimitrijević
2022-09-23 11:46:31 +02:00
parent dca13f5c89
commit 0e9b77e7c3
2 changed files with 40 additions and 2 deletions

View File

@@ -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);

View File

@@ -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>