View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.indentation.indentation; //indent:0 exp:0
2   
3   /**                                                                           //indent:0 exp:0
4    * This test-input is intended to be checked using following configuration:   //indent:1 exp:1
5    *                                                                            //indent:1 exp:1
6    * arrayInitIndent = 4                                                        //indent:1 exp:1
7    * basicOffset = 4                                                            //indent:1 exp:1
8    * braceAdjustment = 0                                                        //indent:1 exp:1
9    * caseIndent = 4                                                             //indent:1 exp:1
10   * forceStrictCondition = false                                               //indent:1 exp:1
11   * lineWrappingIndentation = 4                                                //indent:1 exp:1
12   * tabWidth = 4                                                               //indent:1 exp:1
13   * throwsIndent = 4                                                           //indent:1 exp:1
14   *                                                                            //indent:1 exp:1
15   * @author  jrichard                                                         //indent:1 exp:1
16   */                                                                           //indent:1 exp:1
17  public class InputIndentationInvalidSwitchIndent { //indent:0 exp:0
18  
19      private static final int CONST = 5; //indent:4 exp:4
20      private static final int CONST2 = 2; //indent:4 exp:4
21      private static final int CONST3 = 3; //indent:4 exp:4
22  
23      /** Creates a new instance of InputIndentationInvalidSwitchIndent */ //indent:4 exp:4
24      public InputIndentationInvalidSwitchIndent() { //indent:4 exp:4
25      } //indent:4 exp:4
26  
27      private void method1() { //indent:4 exp:4
28          int s = 3; //indent:8 exp:8
29  
30        switch (s) { //indent:6 exp:8 warn
31  
32            case 4: //indent:10 exp:12 warn
33                System.identityHashCode(""); //indent:14 exp:16 warn
34                  break; //indent:16 exp:16
35  
36              case CONST: //indent:12 exp:12
37                break; //indent:14 exp:16 warn
38  
39                case CONST2: //indent:14 exp:12 warn
40            case CONST3: //indent:10 exp:12 warn
41                  break; //indent:16 exp:16
42  
43            default: //indent:10 exp:12 warn
44                System.identityHashCode(""); //indent:14 exp:16 warn
45                break; //indent:14 exp:16 warn
46          } //indent:8 exp:8
47  
48  
49          // some people like to add curlies to their cases: //indent:8 exp:8
50          switch (s) { //indent:8 exp:8
51  
52              case 4: { //indent:12 exp:12
53                System.identityHashCode(""); //indent:14 exp:16 warn
54                    break; //indent:18 exp:16 warn
55            } //indent:10 exp:12 warn
56  
57              case CONST2: //indent:12 exp:12
58              case CONST3: //indent:12 exp:12
59            { //indent:10 exp:12 warn
60                  System.identityHashCode(""); //indent:16 exp:16
61                  break; //indent:16 exp:16
62                } //indent:14 exp:12 warn
63  
64  
65              case 22: //indent:12 exp:12
66                { //indent:14 exp:12 warn
67                  System.identityHashCode(""); //indent:16 exp:16
68                  break; //indent:16 exp:16
69            } //indent:10 exp:12 warn
70          } //indent:8 exp:8
71  
72          // check broken 'case' lines //indent:8 exp:8
73          switch (s) { //indent:8 exp:8
74  
75              case //indent:12 exp:12
76                CONST: //indent:14 exp:16 warn
77                  break; //indent:16 exp:16
78  
79              case CONST2: //indent:12 exp:12
80              case //indent:12 exp:12
81                CONST3: //indent:14 exp:16 warn
82              { //indent:12 exp:12
83                  System.identityHashCode(""); //indent:16 exp:16
84                  break; //indent:16 exp:16
85              } //indent:12 exp:12
86          } //indent:8 exp:8
87  
88          switch (s) { //indent:8 exp:8
89        } //indent:6 exp:8 warn
90  
91          switch (s) //indent:8 exp:8
92        { //indent:6 exp:8 warn
93            } //indent:10 exp:8 warn
94          switch (s) //indent:8 exp:8
95            { //indent:10 exp:8 warn
96        } //indent:6 exp:8 warn
97  
98      } //indent:4 exp:4
99  
100 } //indent:0 exp:0