001: ////////////////////////////////////////////////////////////////////////////////
002: // Test case file for checkstyle.
003: // Created: Feb-2001
004: // Ignore error
005: ////////////////////////////////////////////////////////////////////////////////
006: package com.puppycrawl.tools.checkstyle;
007:
008: import java.io.*;
009:
010: /**
011: * Contains simple mistakes:
012: * - Long lines
013: * - Tabs
014: * - Format of variables and parameters
015: * - Order of modifiers
016: * @author Oliver Burn
017: **/
018: final class InputSimple {
019: // Long line ----------------------------------------------------------------
020: // Contains a tab -> <-
021: // Contains trailing whitespace ->
022:
023: // Name format tests
024: //
025: /** Invalid format **/
026: public static final int badConstant = 2;
027: /** Valid format **/
028: public static final int MAX_ROWS = 2;
029:
030: /** Invalid format **/
031: private static int badStatic = 2;
032: /** Valid format **/
033: private static int sNumCreated = 0;
034:
035: /** Invalid format **/
036: private int badMember = 2;
037: /** Valid format **/
038: private int mNumCreated1 = 0;
039: /** Valid format **/
040: protected int mNumCreated2 = 0;
041:
042: /** commas are wrong **/
043: private int[] mInts = new int[] { 1, 2, 3, 4 };
044:
045: //
046: // Accessor tests
047: //
048: /** should be private **/
049: public static int sTest1;
050: /** should be private **/
051: protected static int sTest3;
052: /** should be private **/
053: static int sTest2;
054:
055: /** should be private **/
056: int mTest1;
057: /** should be private **/
058: public int mTest2;
059:
060: //
061: // Parameter name format tests
062: //
063:
064: /**
065: * @return hack
066: * @param badFormat1 bad format
067: * @param badFormat2 bad format
068: * @param badFormat3 bad format
069: * @throws java.lang.Exception abc
070: **/
071: int test1(int badFormat1, int badFormat2, final int badFormat3)
072: throws java.lang.Exception {
073: return 0;
074: }
075:
076: /** method that is 20 lines long **/
077: private void longMethod() {
078: // a line
079: // a line
080: // a line
081: // a line
082: // a line
083: // a line
084: // a line
085: // a line
086: // a line
087: // a line
088: // a line
089: // a line
090: // a line
091: // a line
092: // a line
093: // a line
094: // a line
095: // a line
096: }
097:
098: /** constructor that is 10 lines long **/
099: private InputSimple() {
100: // a line
101: // a line
102: // a line
103: // a line
104: // a line
105: // a line
106: // a line
107: // a line
108: }
109:
110: /** test local variables */
111: private void localVariables() {
112: // normal decl
113: int abc = 0;
114: int ABC = 0;
115:
116: // final decls
117: final int cde = 0;
118: final int CDE = 0;
119:
120: // decl in for loop init statement
121: for (int k = 0; k < 1; k++) {
122: String innerBlockVariable = "";
123: }
124: for (int I = 0; I < 1; I++) {
125: String InnerBlockVariable = "";
126: }
127: }
128:
129: /** test method pattern */
130: void ALL_UPPERCASE_METHOD() {
131: }
132:
133: /** test illegal constant **/
134: private static final int BAD__NAME = 3;
135:
136: // A very, very long line that is OK because it matches the regexp "^.*is OK.*regexp.*$"
137: // long line that has a tab -> <- and would be OK if tab counted as 1 char
138: // tabs that count as one char because of their position -> <- -> <-, OK
139:
140: /** some lines to test the error column after tabs */
141: void errorColumnAfterTabs() {
142: // with tab-width 8 all statements below start at the same column,
143: // with different combinations of ' ' and '\t' before the statement
144: int tab0 = 1;
145: int tab1 = 1;
146: int tab2 = 1;
147: int tab3 = 1;
148: int tab4 = 1;
149: int tab5 = 1;
150: }
151:
152: // FIXME:
153: /* FIXME: a
154: * FIXME:
155: * TODO
156: */
157: /* NOTHING */
158: /* YES *//* FIXME: x *//* YES!! */
159:
160: /** test long comments **/
161: void veryLong() {
162: /*
163: blah blah blah blah
164: blah blah blah blah
165: blah blah blah blah
166: blah blah blah blah
167: blah blah blah blah
168: blah blah blah blah
169: blah blah blah blah
170: blah blah blah blah
171: blah blah blah blah
172: blah blah blah blah
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: enough talk */
179: }
180:
181: /**
182: * @see to lazy to document all args. Testing excessive # args
183: **/
184: void toManyArgs(int aArg1, int aArg2, int aArg3, int aArg4,
185: int aArg5, int aArg6, int aArg7, int aArg8, int aArg9) {
186: }
187: }
188:
189: /** Test class for variable naming in for each clauses. */
190: class InputSimple2 {
191: /** Some more Javadoc. */
192: public void doSomething() {
193: //"O" should be named "o"
194: for (Object O : new java.util.ArrayList()) {
195:
196: }
197: }
198: }
199:
200: /** Test enum for member naming check */
201: enum MyEnum1 {
202: /** ABC constant */
203: ABC,
204:
205: /** XYZ constant */
206: XYZ;
207:
208: /** Should be mSomeMemeber */
209: private int someMember;
210: }
|