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