Host.java

Index Score
phex.host
Phex

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
JAVA0117JAVA0117 Missing javadoc: method 'method'
FUNCTIONSNumber of function declarations
DECL_COMMENTSComments in declarations
RETURNSNumber of return points from functions
INTERFACE_COMPLEXITYInterface complexity
CYCLOMATICCyclomatic complexity
BLOCKSNumber of blocks
LINESNumber of lines in the source file
SIZESize of the file in bytes
LOCLines of code
DOC_COMMENTNumber of javadoc comment lines
EXEC_COMMENTSComments in executable code
COMMENTSComment lines
LINE_COMMENTNumber of line comments
ELOCEffective lines of code
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
UNIQUE_OPERANDSNumber of unique operands
LOGICAL_LINESNumber of statements
PROGRAM_VOCABHalstead program vocabulary
COMPARISONSNumber of comparison operators
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
EXITSProcedure exits
WHITESPACENumber of whitespace lines
PARAMSNumber of formal parameter declarations
JAVA0076JAVA0076 Use of magic number
UNIQUE_OPERATORSNumber of unique operators
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
OPERANDSNumber of operands
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0034JAVA0034 Missing braces in if statement
JAVA0264JAVA0264 Integer math in long context - check for overflow
JAVA0030JAVA0030 Private field not used
JAVA0173JAVA0173 Unused method parameter
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
LOOPSNumber of loops
JAVA0145JAVA0145 Tab character used in source file
/* * PHEX - The pure-java Gnutella-servent. * Copyright (C) 2001 - 2007 Phex Development Group * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * --- SVN Information --- * $Id: Host.java 4231 2008-07-15 16:01:10Z gregork $ */ package phex.host; import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; import phex.common.Environment; import phex.common.QueryRoutingTable; import phex.common.address.DestAddress; import phex.common.log.NLogger; import phex.connection.ConnectionClosedException; import phex.connection.MessageQueue; import phex.io.buffer.ByteBuffer; import phex.msg.GUID; import phex.msg.Message; import phex.msg.QueryMsg; import phex.msg.QueryResponseMsg; import phex.msg.vendor.CapabilitiesVMsg; import phex.msg.vendor.MessagesSupportedVMsg; import phex.net.connection.Connection; import phex.prefs.core.SecurityPrefs; import phex.query.DynamicQueryConstants; import phex.servent.Servent; import phex.utils.GnutellaInputStream; import phex.utils.GnutellaOutputStream; /** * <p>A Gnutella host, or servent together with operating statistics and IO.</p> * * <p>This class seems to be overloaded. Hosts are used in several different * distinct modes: * <ul> * <li>Incoming sTypeIncoming - client half of a Gnutella networm node pair. * This is the default state of a Host. A phex.ReadWorker will be assigned to * handle the connection.</li> * <li>Outgoing sTypeOutgoing - server half of a Gnutella network node pair. A * phex.Listener will be assigned to handle the connection, and this will * delegate on to a phex.ReadWorker.</li> * <li>Download sTypeDownload - attempting to HTTP get data. A * phex.download.DownloadWorker will be assigned to handle the connection.</li> * <li>Push sTypePush - a Host to send data that has been routed via a Push * request. A phex.PushWorker will be assigned to handle the connection.</li> * </ul> * </p> */ public class Host { public enum Type { OUTGOING, INCOMING, LOCAL } private static final int MAX_SEND_QUEUE = 400; private static final int DROP_PACKAGE_RATIO = 70; private static final Long ZERO_LONG = Long.valueOf(0); /** * The time after which a query routing table can be updated in milliseconds. */ private long QUERY_ROUTING_UPDATE_TIME = 5 * 60 * 1000; // 5 minutes /** * The time after which a connection is stable. */ private static final int STABLE_CONNECTION_TIME = 60 * 1000; // 60 seconds /** * Normal connection type. */ public static final byte CONNECTION_NORMAL = 0; /** * Connection type as me as a leaf and the host as a ultrapeer. */ public static final byte CONNECTION_LEAF_UP = 1; /** * Connection type from ultrapeer to ultrapeer. */ public static final byte CONNECTION_UP_UP = 2; /** * Connection type representing me as a ultrapeer and the host as a leaf. */ public static final byte CONNECTION_UP_LEAF = 3; private DestAddress hostAddress; private Connection connection; private HostStatus status; private String lastStatusMsg = ""; private long statusTime = 0; private Type type; /** * Number of messages received from this host. */ private int receivedMsgCount; /** * Number of messages send to this host. */ private int sentMsgCount; private int droppedMsgCount; private long fileCount = -1; private long shareSize = -1; private String vendor; private boolean vendorChecked = false; /** * The servent id we found from {@link QueryResponseMsg}. */ private GUID serventId; /** * The maxTTL this connection accepts for dynamic queries. * It is provide through the handshake header X-Max-TTL and used * for the dynamic query proposal. * This header indicates that we should not send fresh queries to * this connection with TTLs higher than the X-Max-TTL. If we are * routing traffic from other Ultrapeers, the X-Max-TTL is irrelevant. * The X-Max-TTL MUST NOT exceed 4, as any TTL above 4 indicates a client * is allowing too much query traffic on the network. This header is * particularly useful for compatibility with future clients that may * choose to have higher degrees but that would prefer lower TTL traffic * from their neighbors. For example, if future clients connect to * 200 Ultrapeers, they could use the X-Max-TTL header to indicate to * today's clients that they will not accept TTLs above 2. A typical * initial value for X-Max-TTL is 3. */ private byte maxTTL; /** * The max hops value to use for queries coming from a hops flow vendor * message. */ private byte hopsFlowLimit; /** * The intra ultrapeer connection this connection holds. * It is provide through the handshake header X-Degree and used * for the dynamic query proposal. * The X-Degree header simply indicates the number of Ultrapeer * connections this nodes attempts to maintain. Clients supporting * the dynamic query proposal must have X-Degrees of at least 15, * and higher values are preferable. */ private int ultrapeerDegree; /** * Marks if a connection is stable. A connection is stable when a * host connection last over STABLE_CONNECTION_TIME seconds. */ private boolean isConnectionStable; /** * Defines if the host supports QRP. This is only important for Ultrapeer * connections. */ private boolean isQueryRoutingSupported; /** * Defines if the host supports Ultrapeer QRP. This is only important for * Ultrapeer connections. */ private boolean isUPQueryRoutingSupported; /** * Defines if the host supports dynamic query. */ private boolean isDynamicQuerySupported; /** * Marks the last time the local query routing table was sent to this * host. Only for leaf-ultrapeers connection a query routing table is send. * @see #isQRTableUpdateRequired() */ private long lastQRTableSentTime; /** * The QR table that was last sent to this host on lastQRTableSentTime. This * table is needed to send patch updates to the host. */ private QueryRoutingTable lastSentQRTable; /** * The QR table that was last received from this host. This * table is needed to determine which querys to send to this host. */ private QueryRoutingTable lastReceivedQRTable; /** * Defines the connection type we have with this host. Possible values are * CONNECTION_NORMAL * CONNECTION_LEAF_ULTRAPEER * PEER_LEAF */ private byte connectionType; /** * A SACHRIFC message queue implementation. */ private MessageQueue messageQueue; private SendEngine sendEngine; private boolean isVendorMessageSupported; private MessagesSupportedVMsg supportedVMsgs; private CapabilitiesVMsg capabilitiesVMsgs; /** * The PushProxy host address of this host. It is received from a * PushProxyAcknowledgement vendor message. */ private DestAddress pushProxyAddress; /** * Create a new Host with type OUTGOING. */ private Host() { connection = null; status = HostStatus.NOT_CONNECTED; type = Type.OUTGOING; isConnectionStable = false; connectionType = CONNECTION_NORMAL; isQueryRoutingSupported = false; isUPQueryRoutingSupported = false; isDynamicQuerySupported = false; isVendorMessageSupported = false; receivedMsgCount = 0; sentMsgCount = 0; droppedMsgCount = 0; maxTTL = DynamicQueryConstants.DEFAULT_MAX_TTL; hopsFlowLimit = -1; } /** * <p>Create a new Host for a HostAddress that will default type * OUTGOING.</p> * * @param address the HostAddress this Host will communicate with */ public Host(DestAddress address) { this(); hostAddress = address; } public Host(DestAddress address, Connection connection) { this(); hostAddress = address; this.connection = connection; } public DestAddress getHostAddress() { return hostAddress; } public void setConnection(Connection connection) { this.connection = connection; receivedMsgCount = 0; sentMsgCount = 0; droppedMsgCount = 0; } /** * @return Returns the connection. */ public Connection getConnection() { return connection; } /** * @deprecated */ @Deprecated public GnutellaInputStream getInputStream() throws IOException { if ( connection == null ) { throw new ConnectionClosedException( "Connection already closed"); } return connection.getInputStream(); } /** * @deprecated */ @Deprecated public GnutellaOutputStream getOutputStream() throws IOException { if ( connection == null ) { throw new ConnectionClosedException( "Connection already closed"); } return connection.getOutputStream(); } public void activateInputInflation() throws IOException { getInputStream().activateInputInflation(); } public void activateOutputDeflation() throws IOException { getOutputStream().activateOutputDeflation(); } public void setVendor(String aVendor) { vendor = aVendor; } public String getVendor() { return vendor; } /** * @return the serventId */ public GUID getServentId() { return serventId; } /** * @param serventId the serventId to set */ public void setServentId(GUID serventId) { this.serventId = serventId; } public HostStatus getStatus() { return status; } public String getLastStatusMsg() { return lastStatusMsg; } public void setStatus( HostStatus status) { setStatus(status, null, System.currentTimeMillis()); } public void setStatus( HostStatus status, long statusTime) { setStatus(status, null, statusTime); } public void setStatus( HostStatus status, String msg) { setStatus(status, msg, System.currentTimeMillis()); } public void setStatus( HostStatus status, String msg, long statusTime) { if ( this.status == status && lastStatusMsg != null && lastStatusMsg.equals(msg) ) { return; } this.status = status; lastStatusMsg = msg; this.statusTime = statusTime; } /** * Checks if a connection status is stable. A stable connection * is a connection to host that last over STABLE_CONNECTION_TIME seconds. * The current time is given out of performance reasons when * looping over all hosts. */ public void checkForStableConnection(long currentTime) { if ( isConnectionStable ) { return; } // if we have connected status for at least STABLE_CONNECTION_TIME. if ( status == HostStatus.CONNECTED && getConnectionUpTime(currentTime) > STABLE_CONNECTION_TIME ) { isConnectionStable = true; } } public boolean isConnectionStable() { return isConnectionStable; } /** * Returns the number of millis the connection is up. */ public long getConnectionUpTime(long currentTime) { if ( status == HostStatus.CONNECTED ) { return currentTime - statusTime; } else { return 0; } } public boolean isErrorStatusExpired( long currentTime, long expiryDelay ) { if ( status == HostStatus.ERROR || status == HostStatus.DISCONNECTED ) { if ( currentTime - statusTime > expiryDelay ) { return true; } } return false; } public Type getType() { return type; } public void setType( Type aType ) { this.type = aType; } public boolean isIncomming() { return type.equals( Type.INCOMING ); } public void setVendorMessageSupported( boolean state ) { this.isVendorMessageSupported = state; } public boolean isVendorMessageSupported() { return isVendorMessageSupported; } public void setCapabilitiesVMsgs( CapabilitiesVMsg capabilitiesVMsgs ) { this.capabilitiesVMsgs = capabilitiesVMsgs; } public boolean isFeatureSearchSupported() { return capabilitiesVMsgs != null && capabilitiesVMsgs.isFeatureSearchSupported(); } public void setSupportedVMsgs( MessagesSupportedVMsg supportedVMsgs ) { this.supportedVMsgs = supportedVMsgs; } public boolean isTCPConnectBackSupported() { return supportedVMsgs != null && supportedVMsgs.isTCPConnectBackSupported(); } public boolean isTCPConnectBackRedirectSupported() { return supportedVMsgs != null && supportedVMsgs.isTCPConnectBackRedirectSupported(); } public boolean isPushProxySupported() { return supportedVMsgs != null && supportedVMsgs.isPushProxySupported(); } public boolean isHopsFlowSupported() { return supportedVMsgs != null && supportedVMsgs.isHopsFlowSupported(); } /** * Returns the PushProxy host address of this host if received * from a PushProxyAcknowledgement vendor message. Null otherwise. */ public DestAddress getPushProxyAddress() { return pushProxyAddress; } /** * Sets the PushProxy host address of this host. It must be received * from a PushProxyAcknowledgement vendor message. */ public void setPushProxyAddress( DestAddress address ) { pushProxyAddress = address; } public void incReceivedCount() { receivedMsgCount++; } public int getReceivedCount() { return receivedMsgCount; } public void incSentCount() { sentMsgCount++; } public int getSentCount() { return sentMsgCount; } public void incDropCount() { droppedMsgCount++; } public int getDropCount() { return droppedMsgCount; } public long getFileCount() { return fileCount; } public void setFileCount(long fileCount) { this.fileCount = fileCount; } /** * Returns total size in kBytes. */ public long getTotalSize() { return shareSize; } public void setTotalFileSize(long shareSize) { this.shareSize = shareSize; } /** * Returns the maxTTL this connection accepts. * @return the maxTTL this connection accepts. * @see #maxTTL */ public byte getMaxTTL() { return maxTTL; } /** * Sets the maxTTL this connection accepts. * @param maxTTL the new maxTTL. * @see #maxTTL */ public void setMaxTTL(byte maxTTL) { this.maxTTL = maxTTL; } /** * Returns the max hops value to use for queries comming from a hops flow vendor * message, or -1 if not set. **/ public byte getHopsFlowLimit() { return hopsFlowLimit; } /** * Sets the max hops value to use for queries coming from a hops flow vendor * message, or -1 to reset. * @param hopsFlowLimit */ public void setHopsFlowLimit(byte hopsFlowLimit) { this.hopsFlowLimit = hopsFlowLimit; } /** * Returns the ultrapeer connection degree. * @return the ultrapeer connection degree. * @see #ultrapeerDegree */ public int getUltrapeerDegree() { return ultrapeerDegree; } /** * Sets the ultrapeer connection degree of this connection. * @param degree the new ultrapeer connection degree. * @see #ultrapeerDegree */ public void setUltrapeerDegree(int degree) { ultrapeerDegree = degree; } public boolean tooManyDropPackets() { // don't drop if this is a young connection if ( receivedMsgCount < 50 && getConnectionUpTime(System.currentTimeMillis()) < 1000 * 60 ) { return false; } return (droppedMsgCount * 100 / (receivedMsgCount + 1) > DROP_PACKAGE_RATIO); } public boolean dropPacketsInRed() { return (droppedMsgCount * 100 / (receivedMsgCount + 1)) > (DROP_PACKAGE_RATIO * 3 / 4); } public boolean isConnected() { return connection != null; } public void disconnect() { if ( connection != null ) { if ( status != HostStatus.ERROR ) { setStatus( HostStatus.DISCONNECTED ); } connection.disconnect(); connection = null; } if ( messageQueue != null ) { // notify messageQueue to cause SendEngine to stop waiting and running.. synchronized (messageQueue) { messageQueue.notify(); } } Servent.getInstance().getHostService().getNetworkHostsContainer().disconnectHost( this ); } public int getSendQueueLength() { if ( messageQueue == null ) { return 0; } else { return messageQueue.getQueuedMessageCount(); } } public int getSendDropCount() { if ( messageQueue == null ) { return 0; } else { return messageQueue.getDropCount(); } } public boolean isSendQueueTooLong() { if ( messageQueue == null ) { return false; } return (messageQueue.getQueuedMessageCount() >= MAX_SEND_QUEUE - 1); } public boolean isSendQueueInRed() { if ( messageQueue == null ) { return false; } return (messageQueue.getQueuedMessageCount() >= MAX_SEND_QUEUE * 3 / 4); } public boolean isNoVendorDisconnectApplying() { if ( !SecurityPrefs.DisconnectNoVendorHosts.get().booleanValue() ) { return false; } // Already checked? Short-circuit out (no need to recalculate len & delta-time) // Possible issue if user toggles the config setting while connected to // an unwanted host--it will not disconnect because it already passed the test if ( vendorChecked ) { return false; } // The vendor string might not be there immediately because of // handshaking, but will certainly be there when the status is HOST_CONNECTED. if ( status != HostStatus.CONNECTED ) { return false; } String normalizedVendorString = this.vendor; if ( normalizedVendorString == null ) { normalizedVendorString = ""; } else { normalizedVendorString = normalizedVendorString.trim(); } if ( normalizedVendorString.length() == 0 ) { return true; } else { vendorChecked = true; return false; } } public boolean isFreeloader(long currentTime) { // freeloaders are no real problem... // // never count a ultrapeer as freeloader... // if ( isUltrapeer() ) { return false; } // long timeDelta = getConnectionUpTime(currentTime); // // We can only really tell after initial handshaing is complete, 10 // // seconds should be a good delay. // if ( timeDelta >= DISCONNECT_POLICY_THRESHOLD ) // { // if ( ServiceManager.sCfg.freeloaderFiles > 0 // && fileCount < ServiceManager.sCfg.freeloaderFiles ) { return true; } // if ( ServiceManager.sCfg.freeloaderShareSize > 0 // && (shareSize / 1024) < ServiceManager.sCfg.freeloaderShareSize ) { return true; } // } return false; } /** * Indicates that this is a ultrapeer and I am a leaf. The * connection type in this case is CONNECTION_LEAF_UP. * @return true if this is a ultrapeer and I am a leaf, false otherwise. */ public boolean isLeafUltrapeerConnection() { return connectionType == CONNECTION_LEAF_UP; } /** * Indicates that this is a ultrapeer in general without paying attention to * my relationship to this ultrapeer. The connection type in this case can * be CONNECTION_LEAF_UP or CONNECTION_UP_UP. * @return true if this is a ultrapeer, false otherwise. */ public boolean isUltrapeer() { return connectionType == CONNECTION_LEAF_UP || connectionType == CONNECTION_UP_UP; } /** * Indicates that this is a leaf and I am its ultrapeer. The * connection type in this case is CONNECTION_UP_LEAF. * @return true if this is a leaf and I am its ultrapeer, false otherwise. */ public boolean isUltrapeerLeafConnection() { return connectionType == CONNECTION_UP_LEAF; } /** * Sets the connection type of the host. The connection can be of type: * CONNECTION_NORMAL * CONNECTION_LEAF_UP * CONNECTION_UP_UP * CONNECTION_UP_LEAF * @param connectionType the connection type of the host. */ public void setConnectionType(byte connectionType) { this.connectionType = connectionType; } @Override public String toString() { return "Host" + "[" + hostAddress.getHostName() + ":" + hostAddress.getPort() + "," + vendor + ",State=" + status + "]"; } ////////////////////////START MessageQueue implementation/////////////////// /** * Sends a message over the output stream but is not flushing the output * stream. This needs to be done by the caller. * @param message the message to send * @throws IOException when a send error occurs */ public void sendMessage( Message message ) throws IOException { if (NLogger.isDebugEnabled( Host.class ) ) NLogger.debug( Host.class, "Sending message: " + message + " - " + message.getHeader().toString()); ByteBuffer headerBuf = message.createHeaderBuffer(); ByteBuffer messageBuf = message.createMessageBuffer(); if ( !isConnected() ) { throw new ConnectionClosedException( "Connection is already closed"); } connection.write( headerBuf ); if ( !isConnected() ) { throw new ConnectionClosedException( "Connection is already closed"); } connection.write( messageBuf ); if (NLogger.isDebugEnabled( Host.class ) ) NLogger.debug( Host.class, "Message send: " + message + " - " + message.getHeader().toString()); } public void flushOutputStream() throws IOException { if ( isConnected() ) { connection.flush(); //Logger.logMessage( Logger.FINEST, Logger.NETWORK, // "Messages flushed" ); } } public void queueMessageToSend(Message message) { // before queuing a query check hops flow limit... if ( hopsFlowLimit > -1 && message instanceof QueryMsg && message.getHeader().getHopsTaken() >= hopsFlowLimit ) {// don't send query! return; } NLogger.debug( Host.class, "Queuing message: " + message ); initMessageQueue(); incSentCount(); synchronized (messageQueue) { messageQueue.addMessage(message); sendEngine.dispatch(); } } private class SendEngine implements Runnable { private AtomicBoolean isRunning = new AtomicBoolean(false); public void dispatch( ) { boolean result = isRunning.compareAndSet( false, true ); if ( result ) { String jobName = "SendEngine-" + Integer.toHexString(sendEngine.hashCode()); Environment.getInstance().executeOnThreadPool( sendEngine, jobName); } } public void run() { do { try { messageQueue.sendQueuedMessages(); } catch (IOException exp) { setStatus( HostStatus.ERROR, exp.getMessage() ); disconnect(); } } while( checkForRepeat() ); } private boolean checkForRepeat() { synchronized (messageQueue) { if ( isConnected() && messageQueue.getQueuedMessageCount() > 0 ) { return true; } else { boolean result = isRunning.compareAndSet( true, false ); if ( !result ) { throw new RuntimeException( "Invalid state." ); } return false; } } } } /** * This method is here to make sure the message queue is only generated * when it is actually necessary. Generating it in the constructor * uses up a big amount of memory for every known Host. Together with the * message queue its SendEngine is initialized. */ private void initMessageQueue() { if ( messageQueue != null ) { return; } // Create a queue with max-size, dropping the oldest msg when max reached. messageQueue = new MessageQueue(this); sendEngine = new SendEngine(); } ////////////////////////END MessageQueue implementation///////////////////// ////////////////////////START QRP implementation//////////////////////////// public boolean isQRTableUpdateRequired() { return System.currentTimeMillis() > lastQRTableSentTime + QUERY_ROUTING_UPDATE_TIME; } public QueryRoutingTable getLastSentRoutingTable() { return lastSentQRTable; } public void setLastSentRoutingTable(QueryRoutingTable routingTable) { lastSentQRTable = routingTable; lastQRTableSentTime = System.currentTimeMillis(); } public QueryRoutingTable getLastReceivedRoutingTable() { return lastReceivedQRTable; } public void setLastReceivedRoutingTable(QueryRoutingTable routingTable) { lastReceivedQRTable = routingTable; } public boolean isQueryRoutingSupported() { return isQueryRoutingSupported; } public void setQueryRoutingSupported(boolean state) { isQueryRoutingSupported = state; } public boolean isUPQueryRoutingSupported() { return isUPQueryRoutingSupported; } public void setUPQueryRoutingSupported(boolean state) { isUPQueryRoutingSupported = state; } /** * Returns if the host supports dynamic query. * @return true if dynamic query is supported, false otherwise. */ public boolean isDynamicQuerySupported() { return isDynamicQuerySupported; } /** * Sets if the hosts supports dynamic query. * @param state true if dynamic query is supported, false otherwise. */ public void setDynamicQuerySupported(boolean state) { isDynamicQuerySupported = state; } //////////////////////////END QRP implementation//////////////////////////// public static final LocalHost LOCAL_HOST; static { LOCAL_HOST = new LocalHost(); } public static class LocalHost extends Host { LocalHost() { // TODO the local address might change... super(Servent.getInstance().getLocalAddress()); } @Override public boolean isConnected() { // return true to suite routing table.. return true; } @Override public Type getType() { return Type.LOCAL; } } }

The table below shows all metrics for Host.java.

MetricValueDescription
BLOCKS132.00Number of blocks
BLOCK_COMMENT21.00Number of block comment lines
COMMENTS285.00Comment lines
COMMENT_DENSITY 0.76Comment density
COMPARISONS60.00Number of comparison operators
CYCLOMATIC136.00Cyclomatic complexity
DECL_COMMENTS54.00Comments in declarations
DOC_COMMENT233.00Number of javadoc comment lines
ELOC374.00Effective lines of code
EXEC_COMMENTS23.00Comments in executable code
EXITS57.00Procedure exits
FUNCTIONS90.00Number of function declarations
HALSTEAD_DIFFICULTY63.66Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY156.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 1.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 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 1.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
JAVA0034 2.00JAVA0034 Missing braces in if statement
JAVA0035 0.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 1.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 6.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 1.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
JAVA0108 3.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.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 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 2.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 1.00JAVA0116 Missing javadoc: field 'field'
JAVA011758.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 1.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 1.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 0.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145 7.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 1.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 0.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 1.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
LINES1056.00Number of lines in the source file
LINE_COMMENT31.00Number of line comments
LOC622.00Lines of code
LOGICAL_LINES222.00Number of statements
LOOPS 1.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS738.00Number of operands
OPERATORS1794.00Number of operators
PARAMS37.00Number of formal parameter declarations
PROGRAM_LENGTH2532.00Halstead program length
PROGRAM_VOCAB367.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS119.00Number of return points from functions
SIZE29259.00Size of the file in bytes
UNIQUE_OPERANDS313.00Number of unique operands
UNIQUE_OPERATORS54.00Number of unique operators
WHITESPACE149.00Number of whitespace lines