ResponseFactoryImpl.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
EXITSProcedure exits
COMPARISONSNumber of comparison operators
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
CYCLOMATICCyclomatic complexity
LINE_COMMENTNumber of line comments
EXEC_COMMENTSComments in executable code
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
SIZESize of the file in bytes
OPERANDSNumber of operands
PROGRAM_LENGTHHalstead program length
OPERATORSNumber of operators
LOGICAL_LINESNumber of statements
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
ELOCEffective lines of code
INTERFACE_COMPLEXITYInterface complexity
PARAMSNumber of formal parameter declarations
JAVA0008JAVA0008 Empty catch block
LOCLines of code
RETURNSNumber of return points from functions
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0177JAVA0177 Variable declaration missing initializer
UNIQUE_OPERATORSNumber of unique operators
JAVA0076JAVA0076 Use of magic number
LINESNumber of lines in the source file
JAVA0036JAVA0036 Missing braces in while statement
BLOCKSNumber of blocks
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0119JAVA0119 Control variable changed within body of for loop
PROGRAM_VOLUMEHalstead program volume
DECL_COMMENTSComments in declarations
JAVA0138JAVA0138 N parameters defined for method (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0123JAVA0123 Use all three components of for loop
JAVA0117JAVA0117 Missing javadoc: method 'method'
LOOPSNumber of loops
NEST_DEPTHMaximum nesting depth
JAVA0145JAVA0145 Tab character used in source file
package com.limegroup.gnutella; import static com.limegroup.gnutella.Constants.MAX_FILE_SIZE; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import org.limewire.collection.BitNumbers; import org.limewire.collection.IntervalSet; import org.limewire.collection.NameValue; import org.limewire.io.ConnectableImpl; import org.limewire.io.IPPortCombo; import org.limewire.io.InvalidDataException; import org.limewire.io.IpPort; import org.limewire.io.IpPortSet; import org.limewire.io.NetworkInstanceUtils; import org.limewire.io.NetworkUtils; import org.limewire.service.ErrorService; import org.limewire.util.ByteOrder; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; import com.limegroup.gnutella.altlocs.AltLocManager; import com.limegroup.gnutella.altlocs.AlternateLocation; import com.limegroup.gnutella.altlocs.AlternateLocationCollection; import com.limegroup.gnutella.altlocs.DirectAltLoc; import com.limegroup.gnutella.filters.IPFilter; import com.limegroup.gnutella.messages.BadGGEPPropertyException; import com.limegroup.gnutella.messages.GGEP; import com.limegroup.gnutella.messages.HUGEExtension; import com.limegroup.gnutella.messages.IntervalEncoder; import com.limegroup.gnutella.settings.MessageSettings; import com.limegroup.gnutella.uploader.HTTPHeaderUtils; import com.limegroup.gnutella.util.DataUtils; import com.limegroup.gnutella.xml.LimeXMLDocument; import com.limegroup.gnutella.xml.LimeXMLDocumentFactory; import com.limegroup.gnutella.xml.LimeXMLNames; @Singleton public class ResponseFactoryImpl implements ResponseFactory { /** * The maximum number of alternate locations to include in responses in the * GGEP block */ private static final int MAX_LOCATIONS = 10; /** The magic byte to use as extension separators. */ private static final byte EXT_SEPARATOR = 0x1c; /** Constant for the KBPS string to avoid constructing it too many times. */ private static final String KBPS = "kbps"; /** Constant for kHz to string to avoid excessive string construction. */ private static final String KHZ = "kHz"; private final AltLocManager altLocManager; private final Provider<CreationTimeCache> creationTimeCache; private final IPFilter ipFilter; private final NetworkInstanceUtils networkInstanceUtils; private final LimeXMLDocumentFactory limeXMLDocumentFactory; @Inject public ResponseFactoryImpl(AltLocManager altLocManager, Provider<CreationTimeCache> creationTimeCache, IPFilter ipFilter, LimeXMLDocumentFactory limeXMLDocumentFactory, NetworkInstanceUtils networkInstanceUtils) { this.altLocManager = altLocManager; this.creationTimeCache = creationTimeCache; this.ipFilter = ipFilter; this.limeXMLDocumentFactory = limeXMLDocumentFactory; this.networkInstanceUtils = networkInstanceUtils; } /* (non-Javadoc) * @see com.limegroup.gnutella.ResponseFactory#createResponse(long, long, java.lang.String) */ public Response createResponse(long index, long size, String name) { return createResponse(index, size, name, -1, null, null, null, null); } /* (non-Javadoc) * @see com.limegroup.gnutella.ResponseFactory#createResponse(long, long, java.lang.String, com.limegroup.gnutella.xml.LimeXMLDocument) */ public Response createResponse(long index, long size, String name, LimeXMLDocument doc) { return createResponse(index, size, name, -1, null, doc, null, null); } /* (non-Javadoc) * @see com.limegroup.gnutella.ResponseFactory#createResponse(com.limegroup.gnutella.FileDesc) */ public Response createResponse(FileDesc fd) { IntervalSet ranges = null; boolean verified = false; if (fd instanceof IncompleteFileDesc) { IncompleteFileDesc ifd = (IncompleteFileDesc)fd; ranges = new IntervalSet(); verified = ifd.loadResponseRanges(ranges); } GGEPContainer container = new GGEPContainer(getAsIpPorts(altLocManager .getDirect(fd.getSHA1Urn())), creationTimeCache.get() .getCreationTimeAsLong(fd.getSHA1Urn()), fd.getFileSize(), ranges, verified, fd.getTTROOTUrn()); return createResponse(fd.getIndex(), fd.getFileSize(), fd.getFileName(), -1, fd.getUrns(), null, container, null); } /* (non-Javadoc) * @see com.limegroup.gnutella.ResponseFactory#createFromStream(java.io.InputStream) */ public Response createFromStream(InputStream is) throws IOException { // extract file index & size long index = ByteOrder.uint2long(ByteOrder.leb2int(is)); long size = ByteOrder.uint2long(ByteOrder.leb2int(is)); int incomingNameByteArraySize; if ((index & 0xFFFFFFFF00000000L) != 0) throw new IOException("invalid index: " + index); if (size < 0) throw new IOException("invalid size: " + size); // The file name is terminated by a null terminator. // A second null indicates the end of this response. // Gnotella & others insert meta-information between // these null characters. So we have to handle this. // See: // http://gnutelladev.wego.com/go/wego.discussion.message?groupId=139406&view=message&curMsgId=319258&discId=140845&index=-1&action=view // Extract the filename ByteArrayOutputStream baos = new ByteArrayOutputStream(); int c; while ((c = is.read()) != 0) { if (c == -1) throw new IOException("EOF before null termination"); baos.write(c); } incomingNameByteArraySize = baos.size(); String name = new String(baos.toByteArray(), "UTF-8"); checkFilename(name); // throws IOException // Extract extra info, if any baos.reset(); while ((c = is.read()) != 0) { if (c == -1) throw new IOException("EOF before null termination"); baos.write(c); } byte[] rawMeta = baos.toByteArray(); if (rawMeta.length == 0) { if (is.available() < 16) { throw new IOException("not enough room for the GUID"); } //changed to pass an additional parameter (incomingNameByteArraySize) for the new response return createResponse(index, size, name, incomingNameByteArraySize, null, null, null, null); } else { // now handle between-the-nulls // \u001c is the HUGE v0.93 GEM delimiter HUGEExtension huge = new HUGEExtension(rawMeta); Set<URN> urns = huge.getURNS(); LimeXMLDocument doc = null; for (String next : huge.getMiscBlocks()) { doc = createXmlDocument(name, next); if (doc != null) break; } GGEPContainer ggep = getGGEP(huge.getGGEP(), size); if (ggep.size64 > MAX_FILE_SIZE) throw new IOException(" file too large " + ggep.size64); if (ggep.size64 > Integer.MAX_VALUE) size = ggep.size64; //changed to pass an additional parameter (baosByteArraySize) for the new response return createResponse(index, size, name, incomingNameByteArraySize, urns, doc, ggep, rawMeta); } } /** * Overloaded constructor that allows the creation of Responses with * meta-data and a <tt>Set</tt> of <tt>URN</tt> instances. This is the * primary constructor that establishes all of the class's invariants, does * any necessary parameter validation, etc. * * If extensions is non-null, it is used as the extBytes instead of creating * them from the urns and locations. * * @param index the index of the file referenced in the response * @param size the size of the file (in bytes) * @param name the name of the file * @param incomingNameByteArraySize TODO * @param urns the <tt>Set</tt> of <tt>URN</tt> instances associated * with the file * @param doc the <tt>LimeXMLDocument</tt> instance associated with the * file * @param extensions The raw unparsed extension bytes. * @param endpoints a collection of other locations on this network that * will have this file */ // NOTE: not in the interface, but public so tests not in this package can use. public Response createResponse(long index, long size, String name, int incomingNameByteArraySize, Set<? extends URN> urns, LimeXMLDocument doc, GGEPContainer ggepData, byte[] extensions) { // make sure ggepData is correct. if (ggepData == null) { if (size <= Integer.MAX_VALUE) ggepData = GGEPContainer.EMPTY; else // large filesizes require GGEP now ggepData = new GGEPContainer(null, -1L, size, null, false, null); } // build up extensions if it wasn't already! if (extensions == null) extensions = createExtBytes(urns, ggepData, size); return new Response(index, size, name, incomingNameByteArraySize, urns, doc, ggepData.locations, ggepData.createTime, extensions, ggepData.ranges, ggepData.verified); } private void checkFilename(String name) throws IOException { if (name.length() == 0) { throw new IOException("empty name in response"); } // sanity checks for filename if (name.indexOf('/') != -1 || name.indexOf('\n') != -1 || name.indexOf('\r') != -1) { throw new IOException("Illegal filename " + name + "contains one of [/\\n\\r]"); } } /** * Constructs an xml string from the given extension sting. * * @param name the name of the file to construct the string for * @param ext an individual between-the-nulls string (note that there can be * multiple between-the-nulls extension strings with HUGE) * @return the xml formatted string, or the empty string if the xml could * not be parsed */ private LimeXMLDocument createXmlDocument(String name, String ext) { StringTokenizer tok = new StringTokenizer(ext); // if there aren't the expected number of tokens, simply // return the empty string if (tok.countTokens() < 2) return null; String first = tok.nextToken(); String second = tok.nextToken(); assert first != null; assert second != null; first = first.toLowerCase(); second = second.toLowerCase(); String length = ""; String bitrate = ""; boolean bearShare1 = false; boolean bearShare2 = false; boolean gnotella = false; if (second.startsWith(KBPS)) bearShare1 = true; else if (first.endsWith(KBPS)) bearShare2 = true; if (bearShare1) { bitrate = first; } else if (bearShare2) { int j = first.indexOf(KBPS); bitrate = first.substring(0, j); } if (bearShare1 || bearShare2) { while (tok.hasMoreTokens()) length = tok.nextToken(); // OK we have the bitrate and the length } else if (ext.endsWith(KHZ)) {// Gnotella gnotella = true; length = first; // extract the bitrate from second int i = second.indexOf(KBPS); if (i > -1)// see if we can find the bitrate bitrate = second.substring(0, i); else // not gnotella, after all...some other format we do not know gnotella = false; } // make sure these are valid numbers. try { Integer.parseInt(bitrate); Integer.parseInt(length); } catch (NumberFormatException nfe) { return null; } if (bearShare1 || bearShare2 || gnotella) {// some metadata we understand List<NameValue<String>> values = new ArrayList<NameValue<String>>(3); values.add(new NameValue<String>(LimeXMLNames.AUDIO_TITLE, name)); values.add(new NameValue<String>(LimeXMLNames.AUDIO_BITRATE, bitrate)); values.add(new NameValue<String>(LimeXMLNames.AUDIO_SECONDS, length)); return limeXMLDocumentFactory.createLimeXMLDocument(values, LimeXMLNames.AUDIO_SCHEMA); } return null; } /** * Helper method that creates an array of bytes for the specified * <tt>Set</tt> of <tt>URN</tt> instances. The bytes are written as * specified in HUGE v 0.94. * * @param urns the <tt>Set</tt> of <tt>URN</tt> instances to use in * constructing the byte array */ private byte[] createExtBytes(Set<? extends URN> urns, GGEPContainer ggep, long size) { try { if (isEmpty(urns) && ggep.isEmpty()) return DataUtils.EMPTY_BYTE_ARRAY; ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (!isEmpty(urns)) { // Add the extension for URNs, if any. for (Iterator<? extends URN> iter = urns.iterator(); iter .hasNext();) { URN urn = iter.next(); assert urn != null : "Null URN"; if (!urn.isSHA1() && MessageSettings.TTROOT_IN_GGEP.getValue()) continue; baos.write(urn.toString().getBytes()); // If there's another URN, add the separator. if (iter.hasNext()) { baos.write(EXT_SEPARATOR); } } assert !(ggep.isEmpty() && urns.size() > 1); // If there's ggep data, write the separator. if (!ggep.isEmpty()) baos.write(EXT_SEPARATOR); } // It is imperitive that GGEP is added LAST. // That is because GGEP can contain 0x1c (EXT_SEPARATOR) // within it, which would cause parsing problems // otherwise. if (!ggep.isEmpty()) addGGEP(baos, ggep, size); return baos.toByteArray(); } catch (IOException impossible) { ErrorService.error(impossible); return DataUtils.EMPTY_BYTE_ARRAY; } } /** * Utility method to know if a set is empty or null. */ private boolean isEmpty(Set<?> set) { return set == null || set.isEmpty(); } /** * Utility method for converting the non-firewalled elements of an * AlternateLocationCollection to a smaller set of endpoints. */ private Set<? extends IpPort> getAsIpPorts( AlternateLocationCollection<DirectAltLoc> col) { if (col == null || !col.hasAlternateLocations()) return Collections.emptySet(); long now = System.currentTimeMillis(); synchronized (col) { Set<IpPort> endpoints = null; int i = 0; for (Iterator<DirectAltLoc> iter = col.iterator(); iter.hasNext() && i < MAX_LOCATIONS;) { DirectAltLoc al = iter.next(); if (al.canBeSent(AlternateLocation.MESH_RESPONSE)) { IpPort host = al.getHost(); if (!networkInstanceUtils.isMe(host)) { if (endpoints == null) endpoints = new IpPortSet(); endpoints.add(host); i++; al.send(now, AlternateLocation.MESH_RESPONSE); } } else if (!al.canBeSentAny()) iter.remove(); } if (endpoints == null) return Collections.emptySet(); else return endpoints; } } /** * Adds a GGEP block with the specified alternate locations to the output * stream. */ private void addGGEP(OutputStream out, GGEPContainer ggep, long size) throws IOException { if (ggep == null || (ggep.locations.size() == 0 && ggep.createTime <= 0 && ggep.size64 <= Integer.MAX_VALUE && ggep.ranges == null && ggep.ttroot == null)) throw new IllegalArgumentException( "null or empty locations and small size"); GGEP info = new GGEP(true); if (ggep.locations.size() > 0) { byte[] output = NetworkUtils.packIpPorts(ggep.locations); info.put(GGEP.GGEP_HEADER_ALTS, output); BitNumbers bn = HTTPHeaderUtils.getTLSIndices(ggep.locations); if (!bn.isEmpty()) info.put(GGEP.GGEP_HEADER_ALTS_TLS, bn.toByteArray()); } if (ggep.createTime > 0) info.put(GGEP.GGEP_HEADER_CREATE_TIME, ggep.createTime / 1000); if (ggep.size64 > Integer.MAX_VALUE && ggep.size64 <= MAX_FILE_SIZE) info.put(GGEP.GGEP_HEADER_LARGE_FILE, ggep.size64); if (ggep.ranges != null) { IntervalEncoder.encode(size, info, ggep.ranges); if (!ggep.verified) info.put(GGEP.GGEP_HEADER_PARTIAL_RESULT_UNVERIFIED); } if (ggep.ttroot != null && MessageSettings.TTROOT_IN_GGEP.getValue()) info.put(GGEP.GGEP_HEADER_TTROOT,ggep.ttroot.getBytes()); info.write(out); } /** * Returns a <tt>Set</tt> of other endpoints described in one of the GGEP * arrays. * * Default access for testing. */ GGEPContainer getGGEP(GGEP ggep, long size) { if (ggep == null) return GGEPContainer.EMPTY; Set<? extends IpPort> locations = null; long createTime = -1; long size64 = size; URN ttroot = null; // if the block has a ALTS value, get it, parse it, // and move to the next. if (ggep.hasKey(GGEP.GGEP_HEADER_ALTS)) { byte[] tlsData = null; if (ggep.hasKey(GGEP.GGEP_HEADER_ALTS_TLS)) { try { tlsData = ggep.getBytes(GGEP.GGEP_HEADER_ALTS_TLS); } catch (BadGGEPPropertyException ignored) { } } BitNumbers bn = tlsData == null ? null : new BitNumbers(tlsData); try { locations = parseLocations(bn, ggep .getBytes(GGEP.GGEP_HEADER_ALTS)); } catch (BadGGEPPropertyException bad) { } } if (ggep.hasKey(GGEP.GGEP_HEADER_CREATE_TIME)) { try { createTime = ggep.getLong(GGEP.GGEP_HEADER_CREATE_TIME) * 1000; } catch (BadGGEPPropertyException bad) { } } if (ggep.hasKey(GGEP.GGEP_HEADER_LARGE_FILE)) { try { size64 = ggep.getLong(GGEP.GGEP_HEADER_LARGE_FILE); } catch (BadGGEPPropertyException bad) { } } if (ggep.hasKey(GGEP.GGEP_HEADER_TTROOT)) { try { byte []tt = ggep.get(GGEP.GGEP_HEADER_TTROOT); if (tt != null) ttroot = URN.createTTRootFromBytes(tt); } catch (IOException bad){} } boolean verified = false; IntervalSet ranges = null; try { ranges = IntervalEncoder.decode(size64,ggep); verified = !ggep.hasKey(GGEP.GGEP_HEADER_PARTIAL_RESULT_UNVERIFIED); } catch (BadGGEPPropertyException ignore){} if (locations == null && createTime == -1 && size64 <= Integer.MAX_VALUE && ranges == null & ttroot == null) return GGEPContainer.EMPTY; return new GGEPContainer(locations, createTime, size64, ranges, verified, ttroot); } /** * Returns a set of IpPorts corresponding to the IpPorts in data. If * BitNumbers is non-null, the addresses in the index corresponding to any * 'on' indexes in BitNumbers are considered tlsCapable. Whenever an invalid * address is encountered, all further hosts are prevented from being TLS * capable. */ private Set<? extends IpPort> parseLocations(BitNumbers tlsHosts, byte[] data) { Set<IpPort> locations = null; if (data.length % 6 != 0) return null; int size = data.length / 6; byte[] current = new byte[6]; for (int i = 0; i < size; i++) { System.arraycopy(data, i * 6, current, 0, 6); IpPort ipp; try { ipp = IPPortCombo.getCombo(current); } catch (InvalidDataException ide) { tlsHosts = null; // turn off TLS continue; } // if we're me or banned, ignore. if (!ipFilter.allow(ipp.getAddress()) || networkInstanceUtils.isMe(ipp)) continue; if (locations == null) locations = new IpPortSet(); // if this addr was TLS-capable, mark it as such. if (tlsHosts != null && tlsHosts.isSet(i)) ipp = new ConnectableImpl(ipp, true); locations.add(ipp); } return locations; } /** * A container for information we're putting in/out of GGEP blocks. */ static final class GGEPContainer { final Set<? extends IpPort> locations; final long createTime; final long size64; static final GGEPContainer EMPTY = new GGEPContainer(); final IntervalSet ranges; final boolean verified; final URN ttroot; private GGEPContainer() { this(null, -1, 0, null, false, null); } GGEPContainer(Set<? extends IpPort> locs, long create, long size64, IntervalSet ranges, boolean verified, URN ttroot) { if (locs == null) locations = Collections.emptySet(); else locations = Collections.unmodifiableSet(locs); createTime = create; this.size64 = size64; this.ranges = ranges; this.verified = verified; this.ttroot = ttroot; assert ttroot == null || ttroot.isTTRoot(); } boolean isEmpty() { return locations.isEmpty() && createTime <= 0 && size64 <= Integer.MAX_VALUE && ranges == null && ttroot == null; } } }

The table below shows all metrics for ResponseFactoryImpl.java.

MetricValueDescription
BLOCKS65.00Number of blocks
BLOCK_COMMENT12.00Number of block comment lines
COMMENTS118.00Comment lines
COMMENT_DENSITY 0.33Comment density
COMPARISONS92.00Number of comparison operators
CYCLOMATIC117.00Cyclomatic complexity
DECL_COMMENTS18.00Comments in declarations
DOC_COMMENT72.00Number of javadoc comment lines
ELOC355.00Effective lines of code
EXEC_COMMENTS22.00Comments in executable code
EXITS97.00Procedure exits
FUNCTIONS17.00Number of function declarations
HALSTEAD_DIFFICULTY98.09Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY93.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 5.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 0.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
JAVA003439.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 1.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 7.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 0.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
JAVA010812.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 1.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 6.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 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 1.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 1.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 1.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 1.00JAVA0119 Control variable changed within body of for loop
JAVA0123 1.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 3.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 2.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 0.00JAVA0143 Synchronized method
JAVA0144 2.00JAVA0144 Line exceeds maximum M characters
JAVA0145 4.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 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.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 3.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.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 0.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
LINES605.00Number of lines in the source file
LINE_COMMENT34.00Number of line comments
LOC407.00Lines of code
LOGICAL_LINES226.00Number of statements
LOOPS 6.00Number of loops
NEST_DEPTH 5.00Maximum nesting depth
OPERANDS1117.00Number of operands
OPERATORS2044.00Number of operators
PARAMS43.00Number of formal parameter declarations
PROGRAM_LENGTH3161.00Halstead program length
PROGRAM_VOCAB415.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS50.00Number of return points from functions
SIZE23272.00Size of the file in bytes
UNIQUE_OPERANDS353.00Number of unique operands
UNIQUE_OPERATORS62.00Number of unique operators
WHITESPACE80.00Number of whitespace lines