MISC.ELSEBLK
"else" statements should have a block
Description
This rule flags any "else" statement that does not have a block.
"else" statements are less error-prone when they have blocks.
Example
package MISC;
public class ELSEBLK {
public void method (boolean b) {
if (b) {
System.out.println ("inside of if");
} else
System.out.println ("inside of if"); //violation.
}
}
Repair
Provide a block for each "else" statement.
|