C & C++

C & C++

Made by DeepSource

Audit required: suspicious placement of semicolon hinting difference in code behaviour and programmer's intent CXX-A1003

Bug risk
Minor
Autofix

Using a semicolon right after the conditional statement (for example an if, for, while, etc.) indicates that nothing happens if the predicate is true. Though this is sometimes intentional, but at other times this might also indicate a possible miss by the programmer, specially when the following lines of code have specific traits (like indentation matching that of the conditional block).

If the semicolon after the conditional statements is intentional, consider moving the semicolon to the next line or indent the following code block/line with that of the conditional.

Bad practice

while ((l = readLine(fileHandle)) != NULL); // unintended semicolon
    comsumeLine(l);
while ((skipSpaces(line));
    readLine(line);         // intentional semicolon but indentation suggest otherwise

Recommended

while ((l = readLine(fileHandle)) != NULL)
    comsumeLine(l);

while ((skipSpaces(line));
readLine(line);

// OR

while ((skipSpaces(line))
    ;
readLine(line);