View Javadoc
1   /*
2   EmptyBlock
3   option = (default)STATEMENT
4   tokens = LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_DO, LITERAL_IF, LITERAL_ELSE, \
5            INSTANCE_INIT, STATIC_INIT, LITERAL_SWITCH
6   
7   
8   */
9   
10  package com.puppycrawl.tools.checkstyle.checks.blocks.emptyblock;
11  
12  import java.io.*; // star import for instantiation tests
13  import java.awt.Dimension; // explicit import for instantiation tests
14  import java.awt.Color;
15  
16  class InputEmptyBlockSemantic2Statement
17  {
18      public void fooMethod()
19      {
20          int a = 1;
21          if (a == 1) {}  // violation 'Must have at least one statement'
22          char[] s = {'1', '2'};
23          int index = 2;
24          if (doSideEffect() == 1) {} // violation 'Must have at least one statement'
25          while ((a = index - 1) != 0) {}
26          for (; index < s.length && s[index] != 'x'; index++) {}
27          if (a == 1) {} else {a++;}// violation 'Must have at least one statement'
28          switch (a) {}   // violation 'Must have at least one statement'
29          switch (a) {
30              case 1:
31                  a = 2;
32              case 2:
33                  a = 3;
34              default:
35                  a = 0;
36          }
37      }
38  
39      public int doSideEffect()
40      {
41          return 1;
42      }
43  }