Project Report: fawkez

Packagesummary org.jcoderz.guidelines.snippets

org.jcoderz.guidelines.snippets.JCoderZJavaExample

LineHitsNoteSource
1  /*
2   * $Id: JCoderZJavaExample.java 1011 2008-06-16 17:57:36Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5   *
6   * Redistribution and use in source and binary forms, with or without
7   * modification, are permitted provided that the following conditions are
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   */
33  package org.jcoderz.guidelines.snippets;
34  
35  
36  import java.util.logging.Level;
37  import java.util.logging.Logger;
38  
39  
40  /**
41   * Class description goes here.
42   * @author Firstname Lastname
43   */
44  public class JCoderZJavaExample
45  {
46      /* A class implementation comment can go here. */
47  
48      /** MIN_WIDTH documentation comment. */
49      public static final int MIN_WIDTH = 4;
50  
51      /** MAX_WIDTH documentation comment. */
52      public static final int MAX_WIDTH = 999;
53  
54      /** BAD_PARAM documentation comment. */
55      public static final int BAD_PARAM = -1;
56  
57      /** INTERNAL_ERROR documentation comment. */
58      public static final int INTERNAL_ERROR = -2;
59  
60      /** classVar1 documentation comment. */
61 (1)    protected static int sClassVar1;
62  
63      /**
64       * The logger.
65       */
660     private static final Logger logger =
67              Logger.getLogger(JCoderZJavaExample.class.getName());
68  
69      private static final String CLASS_NAME = "JCoderZJavaExample";
70  
71      /**
72       * classVar2 documentation comment that happens to be more than one
73       * line long.
74       */
75      private static Object sClassVar2;
76  
77      /** instanceVar2 documentation comment. */
78 (2)    protected int mInstanceVar2;
79  
80      /** instanceVar3 documentation comment. */
81      private Object[] mInstanceVar3;
82  
83      /**
84       * ... Constructor blah documentation comment...
85       */
86      public JCoderZJavaExample ()
870     {
88          // ...implementation goes here...
890         if (logger.isLoggable(Level.FINER))
90          {
910             logger.finer("Sample constructor " + this);
92          }
930     }
94  
95      /**
96       * ... method doSomething documentation comment...
97       */
98      public final void setupConfiguration ()
99      {
100          // write message to log
1010         logger.info("Message");
1020     }
103  
104      /**
105       * ... method doSomething documentation comment...
106       */
107      public void doSomething ()
108      {
109          // ...implementation goes here...
1100     }
111  
112      /**
113       * ...method doSomethingElse documentation comment...
114       * @param someParam this is the input parameter
115       * @return result The method returns an int.
116       */
117      public int doSomethingElse (Object someParam)
118      {
1190         int result = BAD_PARAM;
120  
1210         if (logger.isLoggable(Level.FINER))
122          {
1230             logger.entering(CLASS_NAME, "doSomethingElse",
124                      new Object[] {someParam});
125          }
126  
127          // ...implementation goes here...
1280         if (BAD_PARAM == result)
129          {
1300             final RuntimeException ex
131                      = new RuntimeException("Bad parameter");
1320             if (logger.isLoggable(Level.FINER))
133              {
1340                 logger.throwing(CLASS_NAME, "doSomethingElse", ex);
135              }
1360             throw ex;
137          }
138          try
139          {
1400             result = doSometingFine();
141          }
1420(3)        catch (Throwable th)
143          {
1440             result = INTERNAL_ERROR;
1450         }
146  
147 (4)        // FIXME: finally must log exiting() function
1480         if (logger.isLoggable(Level.FINER))
149          {
1500             logger.exiting(CLASS_NAME, "doSomethingElse",
151                      new Integer(result));
152          }
1530         return result;
154      }
155  
156      /**
157       * Method doSomethingElse documentation comment.
158       * @return result The method returns an int.
159       */
160      private int doSometingFine ()
161      {
162          // ...implementation goes here...
1630(5)        return 0;
164      }
165  
166  }

Findings in this File

w (6) class org.jcoderz.guidelines.snippets.JCoderZJavaExample defines fields that are used only as locals
i (7) org.jcoderz.guidelines.snippets.JCoderZJavaExample.sClassVar1 isn't final but should be
w (8) Unused field: org.jcoderz.guidelines.snippets.JCoderZJavaExample.mInstanceVar3
w (9) Unused field: org.jcoderz.guidelines.snippets.JCoderZJavaExample.sClassVar2
c (1) 61 : 26 Variable 'sClassVar1' must be private and have accessor methods.
c (2) 78 : 19 Variable 'mInstanceVar2' must be private and have accessor methods.
c (3) 142 : 9 Catching 'Throwable' is not allowed.
i (4) 147 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
w (5) 163 : 0 private method org.jcoderz.guidelines.snippets.JCoderZJavaExample.doSometingFine() only returns one constant value