Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
// Nice simple comment

int i; // counter

Noncompliant Code Example

There are other misuses of comments that should be avoided.

Noncompliant Code Example

Do not use the The following noncompliant example uses the character sequence /*within a comment:. Consequently, the call to the security-critical method is not executed. A reviewer examining this page could incorrectly assume that the code is executed.

Code Block
bgColor#FFcccc
/* comment with end comment marker unintentionally omitted
security_critical_method();
/* some other comment */

In this example, the call to the security-critical method is not executed. A reviewer examining this page could incorrectly assume that the code is executed.

Using an editor that provides syntax highlighting or that formats the code to identify issues like missing end comment delimitors can help detect accidental omissions.

Because missing end delimitors are error prone error8prone and often viewed as a mistake, this approach is not recommended for commenting out code.

...