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