View Javadoc
1   /*
2   FinalLocalVariable
3   validateEnhancedForLoopVariable = (default)false
4   tokens = (default)VARIABLE_DEF
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.finallocalvariable;
10  
11  
12  public class InputFinalLocalVariableBreak {
13  
14      void foo1() throws Exception {
15          Exception e; // violation
16          final int a = (int) Math.random();
17          final int b = (int) Math.random();
18  
19          switch (a) {
20          case 0:
21              e = new Exception();
22              break;
23          case 1:
24              if (b == 0) {
25                  e = new Exception();
26                  break;
27              }
28  
29              if (b == 1) {
30                  e = new Exception();
31              }
32              else {
33                  e = new Exception();
34              }
35              break;
36          case 2:
37              if (b == 0) {
38                  return;
39              }
40  
41              e = new Exception();
42              break;
43          default:
44              e = new Exception();
45              break;
46          }
47  
48          throw e;
49      }
50  
51      int foo2() {
52          int a;
53          if (true) {
54              a = 1;
55          } else {
56              a = 2;
57              if (a == 3) {
58                  return a;
59              }
60              a = 4;
61          }
62          return a;
63      }
64  }