View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // Test case file for checkstyle.
3   // Created: Feb-2001
4   // Ignore error
5   ////////////////////////////////////////////////////////////////////////////////
6   package com.puppycrawl.tools.checkstyle.checks.design.visibilitymodifier;
7   import java.io.*;
8   /**
9    * Contains simple mistakes:
10   * - Long lines
11   * - Tabs
12   * - Format of variables and parameters
13   * - Order of modifiers
14   * @author Oliver Burn
15   **/
16  final class InputVisibilityModifierSimple
17  {
18      /** Invalid format **/
19      public static final int badConstant = 2;
20      /** Valid format **/
21      public static final int MAX_ROWS = 2;
22  
23      /** Invalid format **/
24      private static int badStatic = 2;
25      /** Valid format **/
26      private static int sNumCreated = 0;
27  
28      /** Invalid format **/
29      private int badMember = 2;
30      /** Valid format **/
31      private int mNumCreated1 = 0;
32      /** Valid format **/
33      protected int mNumCreated2 = 0;
34  
35      /** commas are wrong **/
36      private int[] mInts = new int[] {1,2, 3,
37                                       4};
38  
39      //
40      // Accessor tests
41      //
42      /** should be private **/
43      public static int sTest1;
44      /** should be private **/
45      protected static int sTest3;
46      /** should be private **/
47      static int sTest2;
48  
49      /** should be private **/
50      int mTest1;
51      /** should be private **/
52      public int mTest2;
53  
54      /**
55       * @return hack
56       * @param badFormat1 bad format
57       * @param badFormat2 bad format
58       * @param badFormat3 bad format
59       * @throws java.lang.Exception abc
60       **/
61      int test1(int badFormat1,int badFormat2,
62                final int badFormat3)
63          throws java.lang.Exception
64      {
65          return 0;
66      }
67  
68      /** test local variables */
69      private void localVariables()
70      {
71          // normal decl
72          int abc = 0;
73          int ABC = 0;
74  
75          // final decls
76          final int cde = 0;
77          final int CDE = 0;
78  
79          // decl in for loop init statement
80          for (int k = 0; k < 1; k++)
81          {
82              String innerBlockVariable = "";
83          }
84          for (int I = 0; I < 1; I++)
85          {
86              String InnerBlockVariable = "";
87          }
88      }
89  
90      /** test illegal constant **/
91      private static final int BAD__NAME = 3;
92  }
93  
94  /** Test class for variable naming in for each clauses. */
95  class InputVisibilityModifierSimple2
96  {
97      /** Some more Javadoc. */
98      public void doSomething()
99      {
100         //"O" should be named "o"
101         for (Object O : new java.util.ArrayList())
102         {
103 
104         }
105     }
106 }
107 
108 /** Test enum for member naming check */
109 enum MyEnum1
110 {
111     /** ABC constant */
112     ABC,
113 
114     /** XYZ constant */
115     XYZ;
116 
117     /** Should be mSomeMemeber */
118     private int someMember;
119 }