1 package com.google.checkstyle.test.chapter4formatting.rule44columnlimit; //ok 2 import com.google.checkstyle.test.chapter3filestructure.toolongpackagetotestcoveragegooglesjavastylerule.*; //ok 3 final class InputLineLength 4 { 5 // Long line ---------------------------------------------------------------------------------------- //warn 6 // Contains a tab -> <- 7 // Contains trailing whitespace -> 8 9 // Name format tests 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, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, }; //warn 30 31 // 32 // Accessor tests 33 // 34 /** should be private **/ 35 public static int sTest1; 36 /** should be private **/ 37 protected static int sTest3; 38 /** should be private **/ 39 static int sTest2; 40 41 /** should be private **/ 42 int mTest1; 43 /** should be private **/ 44 public int mTest2; 45 46 // 47 // Parameter name format tests 48 // 49 50 /** 51 * @return hack 52 * @param badFormat1 bad format 53 * @param badFormat2 bad format 54 * @param badFormat3 bad format 55 * @throws java.lang.Exception abc 56 **/ 57 int test1(int badFormat1,int badFormat2, 58 final int badFormat3) 59 throws java.lang.Exception 60 { 61 return 0; 62 } 63 64 /** method that is 20 lines long **/ 65 private void longMethod() 66 { 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 // a line 79 // a line 80 // a line 81 // a line 82 // a line 83 // a line 84 // a line 85 } 86 87 /** constructor that is 10 lines long **/ 88 private InputLineLength() 89 { 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 } 99 100 /** test local variables */ 101 private void localVariables() 102 { 103 // normal decl 104 int abc = 0; 105 int ABC = 0; 106 107 // final decls 108 final int cde = 0; 109 final int CDE = 0; 110 111 // decl in for loop init statement 112 for (int k = 0; k < 1; k++) 113 { 114 String innerBlockVariable = ""; 115 } 116 for (int I = 0; I < 1; I++) 117 { 118 String InnerBlockVariable = ""; 119 } 120 } 121 122 /** test method pattern */ 123 void ALL_UPPERCASE_METHOD() 124 { 125 } 126 127 /** test illegal constant **/ 128 private static final int BAD__NAME = 3; 129 130 // A very, very long line that is OK because it matches the regexp "^.*is OK.*regexp.*$" 131 // long line that has a tab -> <- and would be OK if tab counted as 1 char 132 // tabs that count as one char because of their position -> <- -> <-, OK 133 134 /** some lines to test the column after tabs */ 135 void violateColumnAfterTabs() 136 { 137 // with tab-width 8 all statements below start at the same column, 138 // with different combinations of ' ' and '\t' before the statement 139 int tab0 =1; 140 int tab1 =1; 141 int tab2 =1; 142 int tab3 =1; 143 int tab4 =1; 144 int tab5 =1; 145 } 146 147 // MEMME: 148 /* MEMME: a 149 * MEMME: 150 * OOOO 151 */ 152 /* NOTHING */ 153 /* YES */ /* MEMME: x */ /* YES!! */ 154 155 /** test long comments **/ 156 void veryLong() 157 { 158 /* 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 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 enough talk */ 175 } 176 177 /** 178 * @see to lazy to document all args. Testing excessive # args 179 **/ 180 void toManyArgs(int aArg1, int aArg2, int aArg3, int aArg4, int aArg5, 181 int aArg6, int aArg7, int aArg8, int aArg9) 182 { 183 } 184 } 185 186 /** Test class for variable naming in for each clause. */ 187 class InputSimple2 188 { 189 /** Some more Javadoc. */ 190 public void doSomething() 191 { 192 //"O" should be named "o" 193 for (Object O : new java.util.ArrayList()) 194 { 195 196 } 197 } 198 } 199 200 /** Test enum for member naming check */ 201 enum MyEnum1 202 { 203 /** ABC constant */ 204 ABC, 205 206 /** XYZ constant */ 207 XYZ; 208 209 /** Should be mSomeMember */ 210 private int someMember; 211 }