View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.indentation.indentation; //indent:0 exp:0
2   
3   import java.util.Arrays; //indent:0 exp:0
4   
5   /**                                                                           //indent:0 exp:0
6    * This test-input is intended to be checked using following configuration:   //indent:1 exp:1
7    *                                                                            //indent:1 exp:1
8    * arrayInitIndent = 4                                                        //indent:1 exp:1
9    * basicOffset = 4                                                            //indent:1 exp:1
10   * braceAdjustment = 0                                                        //indent:1 exp:1
11   * caseIndent = 4                                                             //indent:1 exp:1
12   * forceStrictCondition = false                                               //indent:1 exp:1
13   * lineWrappingIndentation = 4                                                //indent:1 exp:1
14   * tabWidth = 4                                                               //indent:1 exp:1
15   * throwsIndent = 4                                                           //indent:1 exp:1
16   *                                                                            //indent:1 exp:1
17   * @author  jrichard                                                         //indent:1 exp:1
18   */                                                                           //indent:1 exp:1
19  public class InputIndentationInvalidMethodIndent { //indent:0 exp:0
20  
21      /** Creates a new instance of InputInalidMethodIndent */ //indent:4 exp:4
22      public InputIndentationInvalidMethodIndent() { //indent:4 exp:4
23        } //indent:6 exp:4 warn
24  
25      // ctor with rcurly on next line //indent:4 exp:4
26        public InputIndentationInvalidMethodIndent(int dummy) //indent:6 exp:4 warn
27    { //indent:2 exp:4 warn
28        } //indent:6 exp:4 warn
29  
30      // method with rcurly on same line //indent:4 exp:4
31    public void method() { //indent:2 exp:4 warn
32        } //indent:6 exp:4 warn
33  
34      // method with rcurly on next line //indent:4 exp:4
35      public void method2() //indent:4 exp:4
36      { //indent:4 exp:4
37      } //indent:4 exp:4
38  
39      // method with a bunch of params //indent:4 exp:4
40      public int method2(int x, int y, int w, int h) { //indent:4 exp:4
41          return 1; //indent:8 exp:8
42      } //indent:4 exp:4
43  
44      // params on multiple lines //indent:4 exp:4
45      public void method2(int x, int y, int w, int h, //indent:4 exp:4
46          int x1, int y1, int w1, int h1) //indent:8 exp:8
47      { //indent:4 exp:4
48      } //indent:4 exp:4
49  
50      // params on multiple lines //indent:4 exp:4
51      public void method3(int x, int y, int w, int h, //indent:4 exp:4
52          int x1, int y1, int w1, int h1) //indent:8 exp:8
53      { //indent:4 exp:4
54          System.getProperty("foo"); //indent:8 exp:8
55      } //indent:4 exp:4
56  
57  
58  
59      // params on multiple lines //indent:4 exp:4
60      public void method4(int x, int y, int w, int h, //indent:4 exp:4
61          int x1, int y1, int w1, int h1) //indent:8 exp:8
62      { //indent:4 exp:4
63          boolean test = true; //indent:8 exp:8
64          if (test) { //indent:8 exp:8
65              System.getProperty("foo"); //indent:12 exp:12
66          } //indent:8 exp:8
67      } //indent:4 exp:4
68  
69       public //indent:5 exp:4 warn
70       final //indent:5 exp:9 warn
71       void //indent:5 exp:9 warn
72      method5() //indent:4 exp:9 warn
73      { //indent:4 exp:4
74          boolean test = true; //indent:8 exp:8
75          if (test) { //indent:8 exp:8
76              System.getProperty("foo"); //indent:12 exp:12
77          } //indent:8 exp:8
78      } //indent:4 exp:4
79  
80     public //indent:3 exp:4 warn
81     final //indent:3 exp:7 warn
82     void //indent:3 exp:7 warn
83       method6() //indent:5 exp:7 warn
84      { //indent:4 exp:4
85          boolean test = true; //indent:8 exp:8
86          if (test) { //indent:8 exp:8
87              System.getProperty("foo"); //indent:12 exp:12
88          } //indent:8 exp:8
89      } //indent:4 exp:4
90  
91      public InputIndentationInvalidMethodIndent(int dummy, int dummy2) //indent:4 exp:4
92      { //indent:4 exp:4
93      System.getProperty("foo"); //indent:4 exp:8 warn
94      } //indent:4 exp:4
95  
96      void method6a() //indent:4 exp:4
97      { //indent:4 exp:4
98        boolean test = true; //indent:6 exp:8 warn
99        if (test) { //indent:6 exp:8 warn
100           System.getProperty("foo"); //indent:10 exp:12 warn
101       } //indent:6 exp:8 warn
102 
103         System.identityHashCode("methods are: " + //indent:8 exp:8
104           Arrays.asList( //indent:10 exp:12 warn
105                 new String[] {"method"}).toString()); //indent:16 exp:>=14
106 
107 
108         System.identityHashCode("methods are: " + //indent:8 exp:8
109             Arrays.asList( //indent:12 exp:>=12
110               new String[] {"method"}).toString()); //indent:14 exp:>=14
111 
112         System.identityHashCode("methods are: " //indent:8 exp:8
113           + Arrays.asList( //indent:10 exp:12 warn
114                 new String[] {"method"}).toString()); //indent:16 exp:>=14
115 
116         System.identityHashCode("methods are: " //indent:8 exp:8
117             + Arrays.asList( //indent:12 exp:>=12
118               new String[] {"method"}).toString()); //indent:14 exp:>=12
119 
120 
121         String blah = (String) System.getProperty( //indent:8 exp:8
122           new String("type")); //indent:10 exp:12 warn
123 
124 
125         String blah1 = (String) System.getProperty( //indent:8 exp:8
126           new String("type") //indent:10 exp:12 warn
127       ); //indent:6 exp:8 warn
128 
129         System.identityHashCode("methods are: " + Arrays.asList( //indent:8 exp:8
130             new String[] {"method"}).toString() //indent:12 exp:>=12
131       ); //indent:6 exp:8 warn
132     } //indent:4 exp:4
133 
134 
135     private void myfunc2(int a, int b, int c, int d, int e, int f, int g) { //indent:4 exp:4
136     } //indent:4 exp:4
137 
138     private int myfunc3(int a, int b, int c, int d) { //indent:4 exp:4
139         return 1; //indent:8 exp:8
140     } //indent:4 exp:4
141 
142     private void myMethod() //indent:4 exp:4
143     { //indent:4 exp:4
144         myfunc2(3, 4, 5, //indent:8 exp:8
145           6, 7, 8, 9); //indent:10 exp:12 warn
146 
147         myfunc2(3, 4, method2(3, 4, 5, 6) + 5, //indent:8 exp:8
148           6, 7, 8, 9); //indent:10 exp:12 warn
149 
150 
151 //     : this is not illegal, but probably should be //indent:0 exp:0
152 //        myfunc3(11, 11, Integer. //indent:0 exp:0
153 //            getInteger("mytest").intValue(), //indent:0 exp:0
154 //            11); //indent:0 exp:0
155 
156 
157         String.CASE_INSENSITIVE_ORDER.toString() //indent:8 exp:8
158       .equals("blah"); //indent:6 exp:12 warn
159 
160 
161     } //indent:4 exp:4
162 
163     private void myFunc() //indent:4 exp:4
164         throws Exception //indent:8 exp:8
165     { //indent:4 exp:4
166     } //indent:4 exp:4
167 
168     void method7() { //indent:4 exp:4
169         // return incorrectly indented //indent:8 exp:8
170     return; //indent:4 exp:8 warn
171     } //indent:4 exp:4
172 
173     void method8() { //indent:4 exp:4
174         // thow invorrectly indented //indent:8 exp:8
175     throw new RuntimeException(""); //indent:4 exp:8 warn
176     } //indent:4 exp:4
177 
178     public //indent:4 exp:4
179 int[] //indent:0 exp:8 warn
180     method9() //indent:4 exp:8 warn
181     { //indent:4 exp:4
182         return null; //indent:8 exp:8
183     } //indent:4 exp:4
184 
185     private int[] getArray() { //indent:4 exp:4
186         return new int[] {1}; //indent:8 exp:8
187     } //indent:4 exp:4
188 
189     private void indexTest() { //indent:4 exp:4
190             getArray()[0] = 2; //indent:12 exp:8 warn
191     } //indent:4 exp:4
192 
193     /* package scope */ void methodWithCommentBefore() {} //indent:4 exp:4
194 } //indent:0 exp:0