This commit is contained in:
Nora Dimitrijević 2022-09-23 11:46:31 +02:00
Родитель dca13f5c89
Коммит 0e9b77e7c3
2 изменённых файлов: 40 добавлений и 2 удалений

Просмотреть файл

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