
org.sonar.l10n.java.rules.squid.S00108.html Maven / Gradle / Ivy
Most of the time a block of code is empty when a piece of code is really missing.
So such empty block must be either filled or removed.
When a block contains a comment, this block is not considered to be empty.
The following code snippet illustrates this rule:
void doSomething() {
for (int i = 0; i < 42; i++) // Non-Compliant
{
}
for (int i = 0; i < 42; i++); // Compliant
if (myVar == 4) // Compliant - contains a comment
{
// Do nothing because of X and Y
}
else // Compliant
{
doSomething();
}
try // Non-Compliant
{
}
catch (Exception e) // Compliant
{
// Ignore
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy