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