Class EmptyStatementCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class EmptyStatementCheck
    extends AbstractCheck

    Detects empty statements (standalone ";" semicolon). Empty statements often introduce bugs that are hard to spot

    To configure the check:

     <module name="EmptyStatement"/>
     

    Example:

     public void foo() {
       int i = 5;
       if (i > 3); // violation, ";" right after if statement
         i++;
       for (i = 0; i < 5; i++); // violation
         i++;
       while (i > 10) // OK
         i++;
     }
     

    Parent is com.puppycrawl.tools.checkstyle.TreeWalker

    Violation Message Keys:

    • empty.statement
    Since:
    3.1