UrnCache.java

Index Score
com.limegroup.gnutella
FrostWire

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
JAVA0034JAVA0034 Missing braces in if statement
JAVA0143JAVA0143 Synchronized method
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
DECL_COMMENTSComments in declarations
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
EXITSProcedure exits
JAVA0233JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0020JAVA0020 Field name does not have required form
JAVA0279JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
DOC_COMMENTNumber of javadoc comment lines
PROGRAM_VOCABHalstead program vocabulary
UNIQUE_OPERATORSNumber of unique operators
UNIQUE_OPERANDSNumber of unique operands
SIZESize of the file in bytes
LINE_COMMENTNumber of line comments
LOGICAL_LINESNumber of statements
JAVA0117JAVA0117 Missing javadoc: method 'method'
RETURNSNumber of return points from functions
CYCLOMATICCyclomatic complexity
COMMENTSComment lines
OPERATORSNumber of operators
PROGRAM_VOLUMEHalstead program volume
PROGRAM_LENGTHHalstead program length
JAVA0035JAVA0035 Missing braces in for statement
JAVA0126JAVA0126 Method declares unchecked exception in throws
LINESNumber of lines in the source file
OPERANDSNumber of operands
ELOCEffective lines of code
EXEC_COMMENTSComments in executable code
LOOPSNumber of loops
LOCLines of code
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
package com.limegroup.gnutella; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.limewire.concurrent.ExecutorsHelper; import org.limewire.io.IOUtils; import org.limewire.util.CommonUtils; import org.limewire.util.ConverterObjectInputStream; import org.limewire.util.GenericsUtils; import com.google.inject.Singleton; /** * This class contains a systemwide URN cache that persists file URNs (hashes) * across sessions. * * Modified by Gordon Mohr (2002/02/19): Added URN storage, calculation, caching * Repackaged by Greg Bildson (2002/02/19): Moved to dedicated class. * * @see URN */ @Singleton public final class UrnCache { private static final Log LOG = LogFactory.getLog(UrnCache.class); /** * File where urns (currently SHA1 urns) for files are stored. */ private static final File URN_CACHE_FILE = new File(CommonUtils.getUserSettingsDir(), "fileurns.cache"); /** * Last good version of above. */ private static final File URN_CACHE_BACKUP_FILE = new File(CommonUtils.getUserSettingsDir(), "fileurns.bak"); /** * The ProcessingQueue that Files are hashed in. */ private final ExecutorService QUEUE = ExecutorsHelper.newProcessingQueue("Hasher"); /** * The set of files that are pending hashing to the callbacks that are listening to them. */ private Map<File, List<UrnCallback>> pendingHashing = new HashMap<File, List<UrnCallback>>(); /** * Whether or not data is dirty since the last time we saved. */ private volatile boolean dirty = false; /** The future that will contain the URN_MAP when it is done. */ private final Future<Map<UrnSetKey, Set<URN>>> deserializer; /** * Create and initialize urn cache. */ public UrnCache() { deserializer = QUEUE.submit(new Callable<Map<UrnSetKey, Set<URN>>>() { @SuppressWarnings("unchecked") public Map<UrnSetKey, Set<URN>> call() { // This cannot be inside a synchronized block, otherwise other methods // can block its construction. Map map = createMap(); dirty = scanAndRemoveOldEntries(map); return map; } }); } /** * Calculates the given File's URN and caches it. The callback will * be notified of the URNs. If they're already calculated, the callback * will be notified immediately. Otherwise, it will be notified when hashing * completes, fails, or is interrupted. */ public void calculateAndCacheUrns(File file, UrnCallback callback) { Set<URN> urns; synchronized (this) { urns = getUrns(file); // TODO: If we ever create more URN types (other than SHA1) // we cannot just check for size == 0, we must check for // size == NUM_URNS_WE_WANT, and calculateUrns should only // calculate the URN for the specific hash we still need. if (urns.isEmpty()) { if(LOG.isDebugEnabled()) LOG.debug("Adding: " + file + " to be hashed."); List<UrnCallback> list = pendingHashing.get(file); if(list == null) { list = new ArrayList<UrnCallback>(1); pendingHashing.put(file, list); } list.add(callback); QUEUE.execute(new Processor(file)); } } if (!urns.isEmpty()) callback.urnsCalculated(file, urns); } /** * Clears all callbacks that are owned by the given owner. */ public synchronized void clearPendingHashes(Object owner) { if(LOG.isDebugEnabled()) LOG.debug("Clearing all pending hashes owned by: " + owner); for(Iterator<List<UrnCallback>> i = pendingHashing.values().iterator(); i.hasNext(); ) { List<UrnCallback> callbacks = i.next(); for(int j = callbacks.size() - 1; j >= 0; j--) { UrnCallback c = callbacks.get(j); if(c.isOwner(owner)) callbacks.remove(j); } // if there's no more callbacks for this file, remove it. if(callbacks.isEmpty()) i.remove(); } } /** * Clears all callbacks for the given file that are owned by the given owner. */ public synchronized void clearPendingHashesFor(File file, Object owner) { if(LOG.isDebugEnabled()) LOG.debug("Clearing all pending hashes for: " + file + ", owned by: " + owner); List<UrnCallback> callbacks = pendingHashing.get(file); if(callbacks != null) { for(int j = callbacks.size() - 1; j >= 0; j--) { UrnCallback c = callbacks.get(j); if(c.isOwner(owner)) callbacks.remove(j); } if(callbacks.isEmpty()) pendingHashing.remove(file); } } /** * Adds any URNs that can be locally calculated; may take a while to * complete on large files. After calculation, the items are added * for future remembering. * * @param file the <tt>File</tt> instance to calculate URNs for * @return the new <tt>Set</tt> of calculated <tt>URN</tt> instances. If * the calling thread is interrupted while executing this, returns an empty * set. */ public Set<URN> calculateUrns(File file) throws IOException, InterruptedException { return URN.createSHA1AndTTRootUrns(file); } /** * Find any URNs remembered from a previous session for the specified * <tt>File</tt> instance. The returned <tt>Set</tt> is * guaranteed to be non-null, but it may be empty. * * @param file the <tt>File</tt> instance to look up URNs for * @return a new <tt>Set</tt> containing any cached URNs for the * speficied <tt>File</tt> instance, guaranteed to be non-null and * unmodifiable, but possibly empty */ public synchronized Set<URN> getUrns(File file) { // don't trust failed mod times if (file.lastModified() == 0L) return Collections.emptySet(); UrnSetKey key = new UrnSetKey(file); // one or more "urn:" names for this file Set<URN> cachedUrns = getUrnMap().get(key); if(cachedUrns == null) return Collections.emptySet(); return cachedUrns; } /** * Removes any URNs that associated with a specified file. */ public synchronized void removeUrns(File f) { UrnSetKey k = new UrnSetKey(f); getUrnMap().remove(k); dirty = true; } /** * Add URNs for the specified <tt>FileDesc</tt> instance to URN_MAP. * * @param file the <tt>File</tt> instance containing URNs to store */ public synchronized void addUrns(File file, Set<? extends URN> urns) { UrnSetKey key = new UrnSetKey(file); getUrnMap().put(key, Collections.unmodifiableSet(urns)); dirty = true; } /** * Loads values from cache file, if available. If the cache file is * not readable, tries the backup. */ private static Map createMap() { Map result; result = readMap(URN_CACHE_FILE); if(result == null) result = readMap(URN_CACHE_BACKUP_FILE); if(result == null) result = new HashMap<Object, Object>(); return result; } /** * Loads values from cache file, if available. * * @return null if the file does not exist or there was an error * reading the map from the file. */ private static Map readMap(File file) { if (!file.exists()) { return null; } ObjectInputStream ois = null; try { ois = new ConverterObjectInputStream( new BufferedInputStream( new FileInputStream(file))); return (Map)ois.readObject(); } catch(Throwable t) { LOG.error("Unable to read UrnCache", t); return null; } finally { IOUtils.close(ois); } } /** * Removes any stale entries from the map so that they will automatically * be replaced. * * @param map the <tt>Map</tt> to check */ private static boolean scanAndRemoveOldEntries(Map<Object, Object> map) { // discard outdated info boolean dirty = false; for(Iterator<Map.Entry<Object, Object>> i = map.entrySet().iterator(); i.hasNext(); ) { Map.Entry<Object, Object> entry = i.next(); if(!(entry.getKey() instanceof UrnSetKey)) { i.remove(); dirty = true; continue; } UrnSetKey key = (UrnSetKey)entry.getKey(); File f = new File(key._path); if (!f.exists() || f.lastModified() != key._modTime) { dirty = true; i.remove(); continue; } if(!(entry.getValue() instanceof Set)) { i.remove(); dirty = true; continue; } Set<URN> set = GenericsUtils.scanForSet(entry.getValue(), URN.class, GenericsUtils.ScanMode.NEW_COPY_REMOVED, UrnSet.class); if(set.isEmpty()) { i.remove(); dirty = true; continue; } if(set != entry.getValue()) { // if it changed, replace the value w/ unmodifiable dirty = true; entry.setValue(Collections.unmodifiableSet(set)); } } return dirty; } /** * Write cache so that we only have to calculate them once. */ public synchronized void persistCache() { getUrnMap(); // make sure it's finished constructing. if(!dirty) return; //It's not ideal to hold a lock while writing to disk, but I doubt think //it's a problem in practice. URN_CACHE_FILE.renameTo(URN_CACHE_BACKUP_FILE); ObjectOutputStream oos = null; try { oos = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream(URN_CACHE_FILE))); oos.writeObject(getUrnMap()); oos.flush(); } catch (IOException e) { LOG.error("Unable to persist cache", e); } finally { IOUtils.close(oos); } dirty = false; } private Map<UrnSetKey, Set<URN>> getUrnMap() { boolean interrupted = Thread.interrupted(); try { while(true) { try { return deserializer.get(); }catch (InterruptedException tryAgain) { interrupted = true; } } } catch (ExecutionException e) { throw new RuntimeException(e); } finally { if (interrupted) Thread.currentThread().interrupt(); } } private class Processor implements Runnable { private final File file; Processor(File f) { file = f; } public void run() { Set<URN> urns; List<UrnCallback> callbacks; synchronized(UrnCache.this) { callbacks = pendingHashing.remove(file); urns = getUrns(file); // already calculated? } // If there was atleast one callback listening, try and send it out // (which may involve calculating it). if(callbacks != null && !callbacks.isEmpty()) { // If not calculated, calculate OUTSIDE OF LOCK. if(urns.isEmpty()) { if(LOG.isDebugEnabled()) LOG.debug("Hashing file: " + file); try { urns = calculateUrns(file); addUrns(file, urns); } catch(IOException ignored) { LOG.warn("Unable to calculate URNs", ignored); } catch(InterruptedException ignored) { LOG.warn("Unable to calculate URNs", ignored); } } // Note that because we already removed this list from the Map, // we don't need to synchronize while iterating over it, because // nothing else can modify it now. for(int i = 0; i < callbacks.size(); i++) callbacks.get(i).urnsCalculated(file, urns); } } } /** * Private class for the key for the set of URNs for files. */ private static class UrnSetKey implements Serializable { static final long serialVersionUID = -7183232365833531645L; /** * Constant for the file modification time. * @serial */ transient long _modTime; /** * Constant for the file path. * @serial */ transient String _path; /** * Constant cached hash code, since this class is used exclusively * as a hash key. * @serial */ transient int _hashCode; /** * Constructs a new <tt>UrnSetKey</tt> instance from the specified * <tt>File</tt> instance. * * @param file the <tt>File</tt> instance to use in constructing the * key */ UrnSetKey(File file) { _modTime = file.lastModified(); _path = file.getAbsolutePath(); _hashCode = calculateHashCode(); } /** * Helper method to calculate the hash code. * * @return the hash code for this instance */ int calculateHashCode() { int result = 17; result = result*37 + (int)(_modTime ^(_modTime >>> 32)); result = result*37 + _path.hashCode(); return result; } /** * Overrides Object.equals so that keys with equal paths and modification * times will be considered equal. * * @param o the <tt>Object</tt> instance to compare for equality * @return <tt>true</tt> if the specified object is the same instance * as this object, or if it has the same modification time and the same * path, otherwise returns <tt>false</tt> */ public boolean equals(Object o) { if(this == o) return true; if(!(o instanceof UrnSetKey)) return false; UrnSetKey key = (UrnSetKey)o; // note that the path is guaranteed to be non-null return ((_modTime == key._modTime) && (_path.equals(key._path))); } /** * Overrides Object.hashCode to meet the specification of Object.equals * and to make this class functions properly as a hash key. * * @return the hash code for this instance */ public int hashCode() { return _hashCode; } /** * Serializes this instance. * * @serialData the modification time followed by the file path */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); s.writeLong(_modTime); s.writeObject(_path); } /** * Deserializes this instance, restoring all invariants. */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); _modTime = s.readLong(); _path = (String)s.readObject(); _hashCode = calculateHashCode(); } } }

The table below shows all metrics for UrnCache.java.

MetricValueDescription
BLOCKS54.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS157.00Comment lines
COMMENT_DENSITY 0.65Comment density
COMPARISONS35.00Number of comparison operators
CYCLOMATIC65.00Cyclomatic complexity
DECL_COMMENTS29.00Comments in declarations
DOC_COMMENT138.00Number of javadoc comment lines
ELOC240.00Effective lines of code
EXEC_COMMENTS11.00Comments in executable code
EXITS67.00Procedure exits
FUNCTIONS22.00Number of function declarations
HALSTEAD_DIFFICULTY81.27Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY58.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 3.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003417.00JAVA0034 Missing braces in if statement
JAVA0035 1.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 2.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 1.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA010810.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 2.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 5.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 6.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145251.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 1.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 1.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 4.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 1.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 1.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES504.00Number of lines in the source file
LINE_COMMENT19.00Number of line comments
LOC288.00Lines of code
LOGICAL_LINES163.00Number of statements
LOOPS 6.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS681.00Number of operands
OPERATORS1305.00Number of operators
PARAMS17.00Number of formal parameter declarations
PROGRAM_LENGTH1986.00Halstead program length
PROGRAM_VOCAB301.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS41.00Number of return points from functions
SIZE16294.00Size of the file in bytes
UNIQUE_OPERANDS243.00Number of unique operands
UNIQUE_OPERATORS58.00Number of unique operators
WHITESPACE59.00Number of whitespace lines