SampleResult.java

Index Score
org.apache.jmeter.samplers
JMeter

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
DECL_COMMENTSComments in declarations
FUNCTIONSNumber of function declarations
RETURNSNumber of return points from functions
DOC_COMMENTNumber of javadoc comment lines
COMMENTSComment lines
JAVA0117JAVA0117 Missing javadoc: method 'method'
INTERFACE_COMPLEXITYInterface complexity
BLOCKSNumber of blocks
CYCLOMATICCyclomatic complexity
LINESNumber of lines in the source file
SIZESize of the file in bytes
EXITSProcedure exits
PARAMSNumber of formal parameter declarations
LINE_COMMENTNumber of line comments
LOCLines of code
ELOCEffective lines of code
LOGICAL_LINESNumber of statements
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
JAVA0034JAVA0034 Missing braces in if statement
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
WHITESPACENumber of whitespace lines
OPERANDSNumber of operands
JAVA0068JAVA0068 Modifiers not declared in recommended order
JAVA0259JAVA0259 Return of collection/array field
UNIQUE_OPERATORSNumber of unique operators
COMPARISONSNumber of comparison operators
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0173JAVA0173 Unused method parameter
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
LOOPSNumber of loops
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0145JAVA0145 Tab character used in source file
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.jmeter.samplers; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; import org.apache.avalon.framework.configuration.Configuration; import org.apache.jmeter.assertions.AssertionResult; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.logging.LoggingManager; import org.apache.jorphan.util.JOrphanUtils; import org.apache.log.Logger; // For unit tests, @see TestSampleResult /** * This is a nice packaging for the various information returned from taking a * sample of an entry. * */ public class SampleResult implements Serializable { public static final String DEFAULT_HTTP_ENCODING = "ISO-8859-1"; // $NON-NLS-1$ // Needs to be accessible from Test code static final Logger log = LoggingManager.getLoggerForClass(); // Bug 33196 - encoding ISO-8859-1 is only suitable for Western countries // However the suggested System.getProperty("file.encoding") is Cp1252 on // Windows // So use a new property with the original value as default // needs to be accessible from test code static final String DEFAULT_ENCODING = JMeterUtils.getPropDefault("sampleresult.default.encoding", // $NON-NLS-1$ DEFAULT_HTTP_ENCODING); /** * Data type value indicating that the response data is text. * * @see #getDataType * @see #setDataType(java.lang.String) */ public final static String TEXT = "text"; // $NON-NLS-1$ /** * Data type value indicating that the response data is binary. * * @see #getDataType * @see #setDataType(java.lang.String) */ public final static String BINARY = "bin"; // $NON-NLS-1$ /* empty arrays which can be returned instead of null */ private static final byte[] EMPTY_BA = new byte[0]; private static final SampleResult[] EMPTY_SR = new SampleResult[0]; private static final AssertionResult[] EMPTY_AR = new AssertionResult[0]; private SampleSaveConfiguration saveConfig; private SampleResult parent = null; /** * @param propertiesToSave * The propertiesToSave to set. */ public void setSaveConfig(SampleSaveConfiguration propertiesToSave) { this.saveConfig = propertiesToSave; } public SampleSaveConfiguration getSaveConfig() { return saveConfig; } private byte[] responseData = EMPTY_BA; private String responseCode = "";// Never return null private String label = "";// Never return null private String resultFileName = ""; // Filename used by ResultSaver private String samplerData; private String threadName = ""; // Never return null private String responseMessage = ""; private String responseHeaders = ""; // Never return null private String contentType = ""; // e.g. text/html; charset=utf-8 private String requestHeaders = ""; // TODO timeStamp == 0 means either not yet initialised or no stamp available (e.g. when loading a results file) private long timeStamp = 0;// the time stamp - can be start or end private long startTime = 0; private long endTime = 0; private long idleTime = 0;// Allow for non-sample time private long pauseTime = 0;// Start of pause (if any) private List assertionResults; private List subResults; private String dataType=""; // Don't return null if not set private boolean success; private Set files; // files that this sample has been saved in private String dataEncoding;// (is this really the character set?) e.g. // ISO-8895-1, UTF-8 private static Method initNanoTimeMethod() { try { return System.class.getMethod("nanoTime", null); } catch (NoSuchMethodException e) { return null; } } private static boolean haveNanoTime() { return nanoTimeMethod != null; } private static long nanoTime() { Long result = null; try { result = (Long) nanoTimeMethod.invoke(null, null); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } return result.longValue(); } private static final Method nanoTimeMethod = initNanoTimeMethod(); // a reference time from the nanosecond clock private static final long referenceTimeNsClock = haveNanoTime() ? sampleNsClockInMs() : Long.MIN_VALUE; // a reference time from the millisecond clock private static final long referenceTimeMsClock = System.currentTimeMillis(); private long time = 0; // elapsed time private long latency = 0; // time to first response private boolean stopThread = false; // Should thread terminate? private boolean stopTest = false; // Should test terminate? private boolean isMonitor = false; private int sampleCount = 1; private int bytes = 0; // Allows override of sample size in case sampler does not want to store all the data private volatile int groupThreads = 0; // Active threads in this thread group private volatile int allThreads = 0; // Active threads in all thread groups // TODO do contentType and/or dataEncoding belong in HTTPSampleResult instead? private final static String TOTAL_TIME = "totalTime"; // $NON-NLS-1$ private static final boolean startTimeStamp = JMeterUtils.getPropDefault("sampleresult.timestamp.start", false); // $NON-NLS-1$ static { if (startTimeStamp) { log.info("Note: Sample TimeStamps are START times"); } else { log.info("Note: Sample TimeStamps are END times"); } log.info("sampleresult.default.encoding is set to " + DEFAULT_ENCODING); } public SampleResult() { time = 0; } /** * Construct a 'parent' result for an already-existing result, essentially * cloning it * * @param res * existing sample result */ public SampleResult(SampleResult res) { //TODO - why not just copy all the fields? Do we need the calculations that some of the set() methods perform? //TODO - why are the following not copied: // assertionResults, bytes, idleTime, latency, parent,pauseTime,resultFileName,sampleCount,samplerData,saveConfig // stopTest, stopThread, subResults,threadName setStartTime(res.getStartTime()); setEndTime(res.getStartTime()); // was setElapsed(0) which is the same as setStartTime=setEndTime=now setSampleLabel(res.getSampleLabel()); setRequestHeaders(res.getRequestHeaders()); setResponseData(res.getResponseData()); setResponseCode(res.getResponseCode()); setSuccessful(res.isSuccessful()); setResponseMessage(res.getResponseMessage()); setDataType(res.getDataType()); setResponseHeaders(res.getResponseHeaders()); setContentType(res.getContentType()); setDataEncoding(res.getDataEncodingNoDefault()); setURL(res.getURL()); setGroupThreads(res.getGroupThreads()); setAllThreads(res.getAllThreads()); addSubResult(res); // this will add res.getTime() to getTime(). } public boolean isStampedAtStart() { return startTimeStamp; } /** * Create a sample with a specific elapsed time but don't allow the times to * be changed later * * (only used by HTTPSampleResult) * * @param elapsed * time * @param atend * create the sample finishing now, else starting now */ protected SampleResult(long elapsed, boolean atend) { long now = currentTimeInMs(); if (atend) { setTimes(now - elapsed, now); } else { setTimes(now, now + elapsed); } } /** * Create a sample with specific start and end times for test purposes, but * don't allow the times to be changed later * * (used by StatVisualizerModel.Test) * * @param start * start time * @param end * end time */ public static SampleResult createTestSample(long start, long end) { SampleResult res = new SampleResult(); res.setStartTime(start); res.setEndTime(end); return res; } /** * Create a sample with a specific elapsed time for test purposes, but don't * allow the times to be changed later * * @param elapsed - * desired elapsed time */ public static SampleResult createTestSample(long elapsed) { long now = currentTimeInMs(); return createTestSample(now, now + elapsed); } /** * Allow users to create a sample with specific timestamp and elapsed times * for cloning purposes, but don't allow the times to be changed later * * Currently used by OldSaveService, CSVSaveService and StatisticalSampleResult * * @param stamp - * this may be a start time or an end time * @param elapsed */ public SampleResult(long stamp, long elapsed) { stampAndTime(stamp, elapsed); } private static long sampleNsClockInMs() { return nanoTime() / 1000000; } // Helper method to get 1 ms resolution timing. public static long currentTimeInMs() { if (haveNanoTime()) { long elapsedInMs = sampleNsClockInMs() - referenceTimeNsClock; return referenceTimeMsClock + elapsedInMs; } else { return System.currentTimeMillis(); } } // Helper method to maintain timestamp relationships private void stampAndTime(long stamp, long elapsed) { if (startTimeStamp) { startTime = stamp; endTime = stamp + elapsed; } else { startTime = stamp - elapsed; endTime = stamp; } timeStamp = stamp; time = elapsed; } /* * For use by SaveService only. * * @param stamp - * this may be a start time or an end time * @param elapsed */ public void setStampAndTime(long stamp, long elapsed) { if (startTime != 0 || endTime != 0){ throw new RuntimeException("Calling setStampAndTime() after start/end times have been set"); } stampAndTime(stamp, elapsed); } /** * Method to set the elapsed time for a sample. Retained for backward * compatibility with 3rd party add-ons. * It is assumed that the method is only called at the end of a sample * and that timeStamps are end-times * * Also used by SampleResultConverter when creating results from files. * * Must not be used in conjunction with sampleStart()/End() * * @deprecated use sampleStart() and sampleEnd() instead * @param elapsed * time in milliseconds */ public void setTime(long elapsed) { if (startTime != 0 || endTime != 0){ throw new RuntimeException("Calling setTime() after start/end times have been set"); } long now = currentTimeInMs(); setTimes(now - elapsed, now); } public void setMarked(String filename) { if (files == null) { files = new HashSet(); } files.add(filename); } public boolean isMarked(String filename) { return files != null && files.contains(filename); } public String getResponseCode() { return responseCode; } private static final String OK = Integer.toString(HttpURLConnection.HTTP_OK); /** * Set response code to OK, i.e. "200" * */ public void setResponseCodeOK(){ responseCode=OK; } public void setResponseCode(String code) { responseCode = code; } public boolean isResponseCodeOK(){ return responseCode.equals(OK); } public String getResponseMessage() { return responseMessage; } public void setResponseMessage(String msg) { responseMessage = msg; } public void setResponseMessageOK() { responseMessage = "OK"; // $NON-NLS-1$ } public String getThreadName() { return threadName; } public void setThreadName(String threadName) { this.threadName = threadName; } /** * Get the sample timestamp, which may be either the start time or the end time. * * @see #getStartTime() * @see #getEndTime() * * @return timeStamp in milliseconds */ public long getTimeStamp() { return timeStamp; } public String getSampleLabel() { return label; } /** * Get the sample label for use in summary reports etc. * * @param includeGroup whether to include the thread group name * @return the label */ public String getSampleLabel(boolean includeGroup) { if (includeGroup) { StringBuffer sb = new StringBuffer(threadName.substring(0,threadName.lastIndexOf(" "))); //$NON-NLS-1$ return sb.append(":").append(label).toString(); //$NON-NLS-1$ } return label; } public void setSampleLabel(String label) { this.label = label; } public void addAssertionResult(AssertionResult assertResult) { if (assertionResults == null) { assertionResults = new ArrayList(); } assertionResults.add(assertResult); } /** * Gets the assertion results associated with this sample. * * @return an array containing the assertion results for this sample. * Returns empty array if there are no assertion results. */ public AssertionResult[] getAssertionResults() { if (assertionResults == null) { return EMPTY_AR; } return (AssertionResult[]) assertionResults.toArray(new AssertionResult[0]); } public void addSubResult(SampleResult subResult) { String tn = getThreadName(); if (tn.length()==0) { tn=Thread.currentThread().getName();//TODO do this more efficiently this.setThreadName(tn); } subResult.setThreadName(tn); if (subResults == null) { subResults = new ArrayList(); } subResults.add(subResult); // Extend the time to the end of the added sample setEndTime(Math.max(getEndTime(), subResult.getEndTime())); // Include the byte count for the added sample setBytes(getBytes() + subResult.getBytes()); subResult.setParent(this); } /** * Add a subresult read from a results file. * * As for addSubResult(), except that the fields don't need to be accumulated * * @param subResult */ public void storeSubResult(SampleResult subResult) { if (subResults == null) { subResults = new ArrayList(); } subResults.add(subResult); subResult.setParent(this); } /** * Gets the subresults associated with this sample. * * @return an array containing the subresults for this sample. Returns an * empty array if there are no subresults. */ public SampleResult[] getSubResults() { if (subResults == null) { return EMPTY_SR; } return (SampleResult[]) subResults.toArray(new SampleResult[0]); } public void configure(Configuration info) { time = info.getAttributeAsLong(TOTAL_TIME, 0L); } /** * Sets the responseData attribute of the SampleResult object. * * If the parameter is null, then the responseData is set to an empty byte array. * This ensures that getResponseData() can never be null. * * @param response * the new responseData value */ public void setResponseData(byte[] response) { responseData = response == null ? EMPTY_BA : response; } /** * Sets the responseData attribute of the SampleResult object. * * @param response * the new responseData value (String) * * @deprecated - only intended for use from BeanShell code */ public void setResponseData(String response) { responseData = response.getBytes(); } /** * Gets the responseData attribute of the SampleResult object. * <p> * Note that some samplers may not store all the data, in which case * getResponseData().length will be incorrect. * * Instead, always use {@link #getBytes()} to obtain the sample result byte count. * </p> * @return the responseData value (cannot be null) */ public byte[] getResponseData() { return responseData; } /** * Gets the responseData of the SampleResult object as a String * * @return the responseData value as a String, converted according to the encoding */ public String getResponseDataAsString() { try { return new String(responseData,getDataEncodingWithDefault()); } catch (UnsupportedEncodingException e) { log.warn("Using platform default as "+getDataEncodingWithDefault()+" caused "+e); return new String(responseData); } } public void setSamplerData(String s) { samplerData = s; } public String getSamplerData() { return samplerData; } /** * Get the time it took this sample to occur. * * @return elapsed time in milliseonds * */ public long getTime() { return time; } public boolean isSuccessful() { return success; } public void setDataType(String dataType) { this.dataType = dataType; } public String getDataType() { return dataType; } /** * Set Encoding and DataType from ContentType * @param ct - content type (may be null) */ public void setEncodingAndType(String ct){ if (ct != null) { // Extract charset and store as DataEncoding // N.B. The meta tag: // <META http-equiv="content-type" content="text/html; charset=foobar"> // is now processed by HTTPSampleResult#getDataEncodingWithDefault final String CS_PFX = "charset="; // $NON-NLS-1$ int cset = ct.toLowerCase(java.util.Locale.ENGLISH).indexOf(CS_PFX); if (cset >= 0) { // TODO - assumes charset is not followed by anything else String charSet = ct.substring(cset + CS_PFX.length()); // Check for quoted string if (charSet.startsWith("\"")){ // $NON-NLS-1$ setDataEncoding(charSet.substring(1, charSet.length()-1)); // remove quotes } else { setDataEncoding(charSet); } } if (isBinaryType(ct)) { setDataType(BINARY); } else { setDataType(TEXT); } } } // List of types that are known to be binary private static final String[] BINARY_TYPES = { "image/", //$NON-NLS-1$ "audio/", //$NON-NLS-1$ "video/", //$NON-NLS-1$ }; /* * Determine if content-type is known to be binary, i.e. not displayable as text. * * @param ct content type * @return true if content-type is of type binary. */ private static boolean isBinaryType(String ct){ for (int i = 0; i < BINARY_TYPES.length; i++){ if (ct.startsWith(BINARY_TYPES[i])){ return true; } } return false; } /** * Sets the successful attribute of the SampleResult object. * * @param success * the new successful value */ public void setSuccessful(boolean success) { this.success = success; } /** * Returns the display name. * * @return display name of this sample result */ public String toString() { return getSampleLabel(); } /** * Returns the dataEncoding or the default if no dataEncoding was provided * * @deprecated use getDataEncodingWithDefault() or getDataEncodingNoDefault() as needed. */ public String getDataEncoding() { if (dataEncoding != null) { return dataEncoding; } return DEFAULT_ENCODING; } /** * Returns the dataEncoding or the default if no dataEncoding was provided */ public String getDataEncodingWithDefault() { if (dataEncoding != null && dataEncoding.length() > 0) { return dataEncoding; } return DEFAULT_ENCODING; } /** * Returns the dataEncoding or the default if no dataEncoding was provided */ public String getDataEncodingNoDefault() { return dataEncoding; } /** * Sets the dataEncoding. * * @param dataEncoding * the dataEncoding to set, e.g. ISO-8895-1, UTF-8 */ public void setDataEncoding(String dataEncoding) { this.dataEncoding = dataEncoding; } /** * @return whether to stop the test */ public boolean isStopTest() { return stopTest; } /** * @return whether to stop this thread */ public boolean isStopThread() { return stopThread; } /** * @param b */ public void setStopTest(boolean b) { stopTest = b; } /** * @param b */ public void setStopThread(boolean b) { stopThread = b; } /** * @return the request headers */ public String getRequestHeaders() { return requestHeaders; } /** * @return the response headers */ public String getResponseHeaders() { return responseHeaders; } /** * @param string - * request headers */ public void setRequestHeaders(String string) { requestHeaders = string; } /** * @param string - * response headers */ public void setResponseHeaders(String string) { responseHeaders = string; } /** * @return the full content type - e.g. text/html [;charset=utf-8 ] */ public String getContentType() { return contentType; } /** * Get the media type from the Content Type * @return the media type - e.g. text/html (without charset, if any) */ public String getMediaType() { return JOrphanUtils.trim(contentType," ;").toLowerCase(java.util.Locale.ENGLISH); } /** * @param string */ public void setContentType(String string) { contentType = string; } /** * @return idleTime */ public long getIdleTime() { return idleTime; } /** * @return the end time */ public long getEndTime() { return endTime; } /** * @return the start time */ public long getStartTime() { return startTime; } /* * Helper methods N.B. setStartTime must be called before setEndTime * * setStartTime is used by HTTPSampleResult to clone the parent sampler and * allow the original start time to be kept */ protected final void setStartTime(long start) { startTime = start; if (startTimeStamp) { timeStamp = startTime; } } protected void setEndTime(long end) { endTime = end; if (!startTimeStamp) { timeStamp = endTime; } if (startTime == 0) { log.error("setEndTime must be called after setStartTime", new Throwable("Invalid call sequence")); // TODO should this throw an error? } else { time = endTime - startTime - idleTime; } } private void setTimes(long start, long end) { setStartTime(start); setEndTime(end); } /** * Record the start time of a sample * */ public void sampleStart() { if (startTime == 0) { setStartTime(currentTimeInMs()); } else { log.error("sampleStart called twice", new Throwable("Invalid call sequence")); } } /** * Record the end time of a sample and calculate the elapsed time * */ public void sampleEnd() { if (endTime == 0) { setEndTime(currentTimeInMs()); } else { log.error("sampleEnd called twice", new Throwable("Invalid call sequence")); } } /** * Pause a sample * */ public void samplePause() { if (pauseTime != 0) { log.error("samplePause called twice", new Throwable("Invalid call sequence")); } pauseTime = currentTimeInMs(); } /** * Resume a sample * */ public void sampleResume() { if (pauseTime == 0) { log.error("sampleResume without samplePause", new Throwable("Invalid call sequence")); } idleTime += currentTimeInMs() - pauseTime; pauseTime = 0; } /** * When a Sampler is working as a monitor * * @param monitor */ public void setMonitor(boolean monitor) { isMonitor = monitor; } /** * If the sampler is a monitor, method will return true. * * @return true if the sampler is a monitor */ public boolean isMonitor() { return isMonitor; } /** * For the JMS sampler, it can perform multiple samples for greater degree * of accuracy. * * @param count */ public void setSampleCount(int count) { sampleCount = count; } /** * return the sample count. by default, the value is 1. * * @return the sample count */ public int getSampleCount() { return sampleCount; } /** * Returns the count of errors. * * @return 0 - or 1 if the sample failed */ public int getErrorCount(){ return success ? 0 : 1; } public void setErrorCount(int i){// for reading from CSV files // ignored currently } /* * TODO: error counting needs to be sorted out after 2.3 final. * At present the Statistical Sampler tracks errors separately * It would make sense to move the error count here, but this would * mean lots of changes. * It's also tricky maintaining the count - it can't just be incremented/decremented * when the success flag is set as this may be done multiple times. * The work-round for now is to do the work in the StatisticalSampleResult, * which overrides this method. * Note that some JMS samplers also create samples with > 1 sample count * Also the Transaction Controller probably needs to be changed to do * proper sample and error accounting. * The purpose of this work-round is to allow at least minimal support for * errors in remote statistical batch mode. * */ /** * In the event the sampler does want to pass back the actual contents, we * still want to calculate the throughput. The bytes is the bytes of the * response data. * * @param length */ public void setBytes(int length) { bytes = length; } /** * return the bytes returned by the response. * * @return byte count */ public int getBytes() { return bytes == 0 ? responseData.length : bytes; } /** * @return Returns the latency. */ public long getLatency() { return latency; } /** * Set the time to the first response * */ public void latencyEnd() { latency = currentTimeInMs() - startTime - idleTime; } /** * This is only intended for use by SampleResultConverter! * * @param latency * The latency to set. */ public void setLatency(long latency) { this.latency = latency; } /** * This is only intended for use by SampleResultConverter! * * @param timeStamp * The timeStamp to set. */ public void setTimeStamp(long timeStamp) { this.timeStamp = timeStamp; } private URL location; public void setURL(URL location) { this.location = location; } public URL getURL() { return location; } /** * Get a String representation of the URL (if defined). * * @return ExternalForm of URL, or empty string if url is null */ public String getUrlAsString() { return location == null ? "" : location.toExternalForm(); } /** * @return Returns the parent. */ public SampleResult getParent() { return parent; } /** * @param parent * The parent to set. */ public void setParent(SampleResult parent) { this.parent = parent; } public String getResultFileName() { return resultFileName; } public void setResultFileName(String resultFileName) { this.resultFileName = resultFileName; } public int getGroupThreads() { return groupThreads; } public void setGroupThreads(int n) { this.groupThreads = n; } public int getAllThreads() { return allThreads; } public void setAllThreads(int n) { this.allThreads = n; } }

The table below shows all metrics for SampleResult.java.

MetricValueDescription
BLOCKS146.00Number of blocks
BLOCK_COMMENT53.00Number of block comment lines
COMMENTS401.00Comment lines
COMMENT_DENSITY 1.02Comment density
COMPARISONS44.00Number of comparison operators
CYCLOMATIC142.00Cyclomatic complexity
DECL_COMMENTS77.00Comments in declarations
DOC_COMMENT318.00Number of javadoc comment lines
ELOC394.00Effective lines of code
EXEC_COMMENTS 9.00Comments in executable code
EXITS78.00Procedure exits
FUNCTIONS100.00Number of function declarations
HALSTEAD_DIFFICULTY69.13Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY168.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 1.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 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
JAVA0034 0.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 3.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 0.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 0.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 5.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 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 1.00JAVA0116 Missing javadoc: field 'field'
JAVA011736.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 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 0.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 1.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 3.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 1.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
LINES1084.00Number of lines in the source file
LINE_COMMENT30.00Number of line comments
LOC528.00Lines of code
LOGICAL_LINES242.00Number of statements
LOOPS 1.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS904.00Number of operands
OPERATORS1977.00Number of operators
PARAMS53.00Number of formal parameter declarations
PROGRAM_LENGTH2881.00Halstead program length
PROGRAM_VOCAB392.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS115.00Number of return points from functions
SIZE30675.00Size of the file in bytes
UNIQUE_OPERANDS340.00Number of unique operands
UNIQUE_OPERATORS52.00Number of unique operators
WHITESPACE155.00Number of whitespace lines