View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // Test case file for checkstyle.
3   // Created: Feb-2001
4   // Ignore error
5   ////////////////////////////////////////////////////////////////////////////////
6   package com.puppycrawl.tools.checkstyle.checks.whitespace.whitespaceafter;
7   import java.io.*;
8   /**
9    * Contains simple mistakes:
10   * - Long lines
11   * - Tabs
12   * - Format of variables and parameters
13   * - Order of modifiers
14   * @author Oliver Burn
15   **/
16  final class InputWhitespaceAfterDefaultConfig
17  {
18      // Long line ----------------------------------------------------------------
19      // Contains a tab ->	<-
20      // Contains trailing whitespace ->
21  
22      // Name format tests
23      //
24      /** Invalid format **/
25      public static final int badConstant = 2;
26      /** Valid format **/
27      public static final int MAX_ROWS = 2;
28  
29      /** Invalid format **/
30      private static int badStatic = 2;
31      /** Valid format **/
32      private static int sNumCreated = 0;
33  
34      /** Invalid format **/
35      private int badMember = 2;
36      /** Valid format **/
37      private int mNumCreated1 = 0;
38      /** Valid format **/
39      protected int mNumCreated2 = 0;
40  
41      /** commas are wrong **/
42      private int[] mInts = new int[] {1,2, 3,
43                                       4};
44  
45      //
46      // Accessor tests
47      //
48      /** should be private **/
49      public static int sTest1;
50      /** should be private **/
51      protected static int sTest3;
52      /** should be private **/
53      static int sTest2;
54  
55      /** should be private **/
56      int mTest1;
57      /** should be private **/
58      public int mTest2;
59  
60      //
61      // Parameter name format tests
62      //
63  
64      /**
65       * @return hack
66       * @param badFormat1 bad format
67       * @param badFormat2 bad format
68       * @param badFormat3 bad format
69       * @throws java.lang.Exception abc
70       **/
71      int test1(int badFormat1,int badFormat2,
72                final int badFormat3)
73          throws java.lang.Exception
74      {
75          return 0;
76      }
77  
78      /** method that is 20 lines long **/
79      private void longMethod()
80      {
81          // a line
82          // a line
83          // a line
84          // a line
85          // a line
86          // a line
87          // a line
88          // a line
89          // a line
90          // a line
91          // a line
92          // a line
93          // a line
94          // a line
95          // a line
96          // a line
97          // a line
98          // a line
99      }
100 
101     /** constructor that is 10 lines long **/
102     private InputWhitespaceAfterDefaultConfig()
103     {
104         // a line
105         // a line
106         // a line
107         // a line
108         // a line
109         // a line
110         // a line
111         // a line
112     }
113 
114     /** test local variables */
115     private void localVariables()
116     {
117         // normal decl
118         int abc = 0;
119         int ABC = 0;
120 
121         // final decls
122         final int cde = 0;
123         final int CDE = 0;
124 
125         // decl in for loop init statement
126         for (int k = 0; k < 1; k++)
127         {
128             String innerBlockVariable = "";
129         }
130         for (int I = 0; I < 1; I++)
131         {
132             String InnerBlockVariable = "";
133         }
134     }
135 
136     /** test method pattern */
137     void ALL_UPPERCASE_METHOD()
138     {
139     }
140 
141     /** test illegal constant **/
142     private static final int BAD__NAME = 3;
143 
144     // A very, very long line that is OK because it matches the regexp "^.*is OK.*regexp.*$"
145     // long line that has a tab ->	<- and would be OK if tab counted as 1 char
146     // tabs that count as one char because of their position ->	<-   ->	<-, OK
147  
148     /** some lines to test the error column after tabs */
149     void errorColumnAfterTabs()
150     {
151         // with tab-width 8 all statements below start at the same column,
152         // with different combinations of ' ' and '\t' before the statement
153                 int tab0 =1;
154         	int tab1 =1;
155          	int tab2 =1;
156 		int tab3 =1;
157   	  	int tab4 =1;
158   	        int tab5 =1;
159     }
160 
161     // FIXME:
162     /* FIXME: a
163      * FIXME:
164      * TODO
165      */
166     /* NOTHING */
167     /* YES */ /* FIXME: x */ /* YES!! */
168 
169     /** test long comments **/
170     void veryLong()
171     {
172         /*
173           blah blah blah blah
174           blah blah blah blah
175           blah blah blah blah
176           blah blah blah blah
177           blah blah blah blah
178           blah blah blah blah
179           blah blah blah blah
180           blah blah blah blah
181           blah blah blah blah
182           blah blah blah blah
183           blah blah blah blah
184           blah blah blah blah
185           blah blah blah blah
186           blah blah blah blah
187           blah blah blah blah
188           enough talk */
189     }
190 
191     /**
192      * @see to lazy to document all args. Testing excessive # args
193      **/
194     void toManyArgs(int aArg1, int aArg2, int aArg3, int aArg4, int aArg5,
195                     int aArg6, int aArg7, int aArg8, int aArg9)
196     {
197     }
198 }
199 
200 /** Test class for variable naming in for each clauses. */
201 class InputSimple2
202 {
203     /** Some more Javadoc. */
204     public void doSomething()
205     {
206         //"O" should be named "o"
207         for (Object O : new java.util.ArrayList())
208         {
209 
210         }
211     }
212 }
213 
214 /** Test enum for member naming check */
215 enum MyEnum1
216 {
217     /** ABC constant */
218     ABC,
219 
220     /** XYZ constant */
221     XYZ;
222 
223     /** Should be mSomeMember */
224     private int someMember;
225 }