42 lines
727 B
Plaintext
42 lines
727 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
void DoSomething()
|
||
|
{
|
||
|
; // Noncompliant - was used as a kind of TODO marker
|
||
|
}
|
||
|
|
||
|
void DoSomethingElse()
|
||
|
{
|
||
|
Console.WriteLine("Hello, world!");; // Noncompliant - double ;
|
||
|
// ...
|
||
|
// Rarely, they are used on purpose as the body of a loop. It is a bad practice to
|
||
|
// have side-effects outside of the loop:
|
||
|
for (int i = 0; i < 3; Console.WriteLine(i), i++); // Noncompliant
|
||
|
// ...
|
||
|
}
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
void DoSomething()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void DoSomethingElse()
|
||
|
{
|
||
|
Console.WriteLine("Hello, world!");
|
||
|
// ...
|
||
|
for (int i = 0; i < 3; i++)
|
||
|
{
|
||
|
Console.WriteLine(i);
|
||
|
}
|
||
|
// ...
|
||
|
}
|
||
|
----
|
||
|
|
||
|
include::../see.adoc[]
|