JMeter.java

Index Score
org.apache.jmeter
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
EXITSProcedure exits
SIZESize of the file in bytes
UNIQUE_OPERANDSNumber of unique operands
OPERANDSNumber of operands
PROGRAM_LENGTHHalstead program length
LOGICAL_LINESNumber of statements
PROGRAM_VOCABHalstead program vocabulary
OPERATORSNumber of operators
ELOCEffective lines of code
LOCLines of code
BLOCKSNumber of blocks
COMPARISONSNumber of comparison operators
CYCLOMATICCyclomatic complexity
JAVA0144JAVA0144 Line exceeds maximum M characters
LINESNumber of lines in the source file
JAVA0266JAVA0266 Use of System.out
LINE_COMMENTNumber of line comments
JAVA0130JAVA0130 Non-static method does not use instance fields
EXEC_COMMENTSComments in executable code
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0166JAVA0166 Generic exception caught
JAVA0034JAVA0034 Missing braces in if statement
LOOPSNumber of loops
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
JAVA0143JAVA0143 Synchronized method
JAVA0267JAVA0267 Use of System.err
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0285JAVA0285 Dereference of potentially null variable
UNIQUE_OPERATORSNumber of unique operators
JAVA0067JAVA0067 Array descriptor on identifier name
NEST_DEPTHMaximum nesting depth
DECL_COMMENTSComments in declarations
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0128JAVA0128 Public constructor in non-public class
PROGRAM_VOLUMEHalstead program volume
JAVA0032JAVA0032 Switch statement missing default
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0087JAVA0087 Use of Thread.sleep()
JAVA0265JAVA0265 Use of Throwable.printStackTrace()
INTERFACE_COMPLEXITYInterface complexity
JAVA0173JAVA0173 Unused method parameter
PARAMSNumber of formal parameter declarations
FUNCTIONSNumber of function declarations
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
DOC_COMMENTNumber of javadoc comment lines
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; import java.awt.event.ActionEvent; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.Authenticator; import java.net.MalformedURLException; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; import java.util.Enumeration; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Properties; import java.util.StringTokenizer; import org.apache.commons.cli.avalon.CLArgsParser; import org.apache.commons.cli.avalon.CLOption; import org.apache.commons.cli.avalon.CLOptionDescriptor; import org.apache.commons.cli.avalon.CLUtil; import org.apache.jmeter.control.ReplaceableController; import org.apache.jmeter.engine.ClientJMeterEngine; import org.apache.jmeter.engine.JMeterEngine; import org.apache.jmeter.engine.RemoteJMeterEngineImpl; import org.apache.jmeter.engine.StandardJMeterEngine; import org.apache.jmeter.engine.event.LoopIterationEvent; import org.apache.jmeter.exceptions.IllegalUserActionException; import org.apache.jmeter.gui.GuiPackage; import org.apache.jmeter.gui.MainFrame; import org.apache.jmeter.gui.action.ActionNames; import org.apache.jmeter.gui.action.ActionRouter; import org.apache.jmeter.gui.action.Load; import org.apache.jmeter.gui.action.LoadRecentProject; import org.apache.jmeter.gui.tree.JMeterTreeListener; import org.apache.jmeter.gui.tree.JMeterTreeModel; import org.apache.jmeter.gui.tree.JMeterTreeNode; import org.apache.jmeter.plugin.JMeterPlugin; import org.apache.jmeter.plugin.PluginManager; import org.apache.jmeter.reporters.ResultCollector; import org.apache.jmeter.reporters.Summariser; import org.apache.jmeter.samplers.Remoteable; import org.apache.jmeter.save.SaveService; import org.apache.jmeter.services.FileServer; import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.TestListener; import org.apache.jmeter.util.BeanShellInterpreter; import org.apache.jmeter.util.BeanShellServer; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.SearchByClass; import org.apache.jorphan.gui.ComponentUtil; import org.apache.jorphan.logging.LoggingManager; import org.apache.jorphan.reflect.ClassTools; import org.apache.jorphan.util.JMeterException; import org.apache.jorphan.util.JOrphanUtils; import org.apache.log.Logger; import com.thoughtworks.xstream.converters.ConversionException; /** * Main JMeter class; processes options and starts the GUI, non-GUI or server as appropriate. */ public class JMeter implements JMeterPlugin { private static final Logger log = LoggingManager.getLoggerForClass(); public static final String HTTP_PROXY_PASS = "http.proxyPass"; // $NON-NLS-1$ public static final String HTTP_PROXY_USER = "http.proxyUser"; // $NON-NLS-1$ // If the -t flag is to "LAST", then the last loaded file (if any) is used private static final String USE_LAST_JMX = "LAST"; // If the -j or -l flag is set to LAST or LAST.log|LAST.jtl, then the last loaded file name is used to // generate the log file name by removing .JMX and replacing it with .log|.jtl private static final int PROXY_PASSWORD = 'a';// $NON-NLS-1$ private static final int JMETER_HOME_OPT = 'd';// $NON-NLS-1$ private static final int HELP_OPT = 'h';// $NON-NLS-1$ // jmeter.log private static final int JMLOGFILE_OPT = 'j';// $NON-NLS-1$ // sample result log file private static final int LOGFILE_OPT = 'l';// $NON-NLS-1$ private static final int NONGUI_OPT = 'n';// $NON-NLS-1$ private static final int PROPFILE_OPT = 'p';// $NON-NLS-1$ private static final int PROPFILE2_OPT = 'q';// $NON-NLS-1$ private static final int REMOTE_OPT = 'r';// $NON-NLS-1$ private static final int SERVER_OPT = 's';// $NON-NLS-1$ private static final int TESTFILE_OPT = 't';// $NON-NLS-1$ private static final int PROXY_USERNAME = 'u';// $NON-NLS-1$ private static final int VERSION_OPT = 'v';// $NON-NLS-1$ private static final int SYSTEM_PROPERTY = 'D';// $NON-NLS-1$ private static final int JMETER_GLOBAL_PROP = 'G';// $NON-NLS-1$ private static final int PROXY_HOST = 'H';// $NON-NLS-1$ private static final int JMETER_PROPERTY = 'J';// $NON-NLS-1$ private static final int LOGLEVEL = 'L';// $NON-NLS-1$ private static final int NONPROXY_HOSTS = 'N';// $NON-NLS-1$ private static final int PROXY_PORT = 'P';// $NON-NLS-1$ private static final int REMOTE_OPT_PARAM = 'R';// $NON-NLS-1$ private static final int SYSTEM_PROPFILE = 'S';// $NON-NLS-1$ private static final int REMOTE_STOP = 'X';// $NON-NLS-1$ /** * Define the understood options. Each CLOptionDescriptor contains: * <ul> * <li>The "long" version of the option. Eg, "help" means that "--help" * will be recognised.</li> * <li>The option flags, governing the option's argument(s).</li> * <li>The "short" version of the option. Eg, 'h' means that "-h" will be * recognised.</li> * <li>A description of the option.</li> * </ul> */ private static final CLOptionDescriptor[] options = new CLOptionDescriptor[] { new CLOptionDescriptor("help", CLOptionDescriptor.ARGUMENT_DISALLOWED, HELP_OPT, "print usage information and exit"), new CLOptionDescriptor("version", CLOptionDescriptor.ARGUMENT_DISALLOWED, VERSION_OPT, "print the version information and exit"), new CLOptionDescriptor("propfile", CLOptionDescriptor.ARGUMENT_REQUIRED, PROPFILE_OPT, "the jmeter property file to use"), new CLOptionDescriptor("addprop", CLOptionDescriptor.ARGUMENT_REQUIRED | CLOptionDescriptor.DUPLICATES_ALLOWED, PROPFILE2_OPT, "additional JMeter property file(s)"), new CLOptionDescriptor("testfile", CLOptionDescriptor.ARGUMENT_REQUIRED, TESTFILE_OPT, "the jmeter test(.jmx) file to run"), new CLOptionDescriptor("logfile", CLOptionDescriptor.ARGUMENT_REQUIRED, LOGFILE_OPT, "the file to log samples to"), new CLOptionDescriptor("jmeterlogfile", CLOptionDescriptor.ARGUMENT_REQUIRED, JMLOGFILE_OPT, "jmeter run log file (jmeter.log)"), new CLOptionDescriptor("nongui", CLOptionDescriptor.ARGUMENT_DISALLOWED, NONGUI_OPT, "run JMeter in nongui mode"), new CLOptionDescriptor("server", CLOptionDescriptor.ARGUMENT_DISALLOWED, SERVER_OPT, "run the JMeter server"), new CLOptionDescriptor("proxyHost", CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_HOST, "Set a proxy server for JMeter to use"), new CLOptionDescriptor("proxyPort", CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_PORT, "Set proxy server port for JMeter to use"), new CLOptionDescriptor("nonProxyHosts", CLOptionDescriptor.ARGUMENT_REQUIRED, NONPROXY_HOSTS, "Set nonproxy host list (e.g. *.apache.org|localhost)"), new CLOptionDescriptor("username", CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_USERNAME, "Set username for proxy server that JMeter is to use"), new CLOptionDescriptor("password", CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_PASSWORD, "Set password for proxy server that JMeter is to use"), new CLOptionDescriptor("jmeterproperty", CLOptionDescriptor.DUPLICATES_ALLOWED | CLOptionDescriptor.ARGUMENTS_REQUIRED_2, JMETER_PROPERTY, "Define additional JMeter properties"), new CLOptionDescriptor("globalproperty", CLOptionDescriptor.DUPLICATES_ALLOWED | CLOptionDescriptor.ARGUMENTS_REQUIRED_2, JMETER_GLOBAL_PROP, "Define Global properties (sent to servers)\n\t\te.g. -Gport=123 or -Gglobal.properties"), new CLOptionDescriptor("systemproperty", CLOptionDescriptor.DUPLICATES_ALLOWED | CLOptionDescriptor.ARGUMENTS_REQUIRED_2, SYSTEM_PROPERTY, "Define additional system properties"), new CLOptionDescriptor("systemPropertyFile", CLOptionDescriptor.DUPLICATES_ALLOWED | CLOptionDescriptor.ARGUMENT_REQUIRED, SYSTEM_PROPFILE, "additional system property file(s)"), new CLOptionDescriptor("loglevel", CLOptionDescriptor.DUPLICATES_ALLOWED | CLOptionDescriptor.ARGUMENTS_REQUIRED_2, LOGLEVEL, "[category=]level e.g. jorphan=INFO or jmeter.util=DEBUG"), new CLOptionDescriptor("runremote", CLOptionDescriptor.ARGUMENT_DISALLOWED, REMOTE_OPT, "Start remote servers (as defined in remote_hosts)"), new CLOptionDescriptor("remotestart", CLOptionDescriptor.ARGUMENT_REQUIRED, REMOTE_OPT_PARAM, "Start these remote servers (overrides remote_hosts)"), new CLOptionDescriptor("homedir", CLOptionDescriptor.ARGUMENT_REQUIRED, JMETER_HOME_OPT, "the jmeter home directory to use"), new CLOptionDescriptor("remoteexit", CLOptionDescriptor.ARGUMENT_DISALLOWED, REMOTE_STOP, "Exit the remote servers at end of test (non-GUI)"), }; public JMeter() { } // Hack to allow automated tests to find when test has ended //transient boolean testEnded = false; private JMeter parent; private Properties remoteProps; // Properties to be sent to remote servers private boolean remoteStop; // should remote engines be stopped at end of GUI test? /** * Starts up JMeter in GUI mode */ private void startGui(String testFile) { PluginManager.install(this, true); JMeterTreeModel treeModel = new JMeterTreeModel(); JMeterTreeListener treeLis = new JMeterTreeListener(treeModel); treeLis.setActionHandler(ActionRouter.getInstance()); // NOTUSED: GuiPackage guiPack = GuiPackage.getInstance(treeLis, treeModel); MainFrame main = new MainFrame(ActionRouter.getInstance(), treeModel, treeLis); ComponentUtil.centerComponentInWindow(main, 80); main.show(); ActionRouter.getInstance().actionPerformed(new ActionEvent(main, 1, ActionNames.ADD_ALL)); if (testFile != null) { FileInputStream reader = null; try { File f = new File(testFile); log.info("Loading file: " + f); reader = new FileInputStream(f); HashTree tree = SaveService.loadTree(reader); GuiPackage.getInstance().setTestPlanFile(f.getAbsolutePath()); Load.insertLoadedTree(1, tree); } catch (ConversionException e) { log.error("Failure loading test file", e); JMeterUtils.reportErrorToUser(SaveService.CEtoString(e)); } catch (Exception e) { log.error("Failure loading test file", e); JMeterUtils.reportErrorToUser(e.toString()); } finally { JOrphanUtils.closeQuietly(reader); } } } /** * Takes the command line arguments and uses them to determine how to * startup JMeter. */ public void start(String[] args) { CLArgsParser parser = new CLArgsParser(args, options); String error = parser.getErrorString(); if (error == null){// Check option combinations boolean gui = parser.getArgumentById(NONGUI_OPT)==null; boolean remoteStart = parser.getArgumentById(REMOTE_OPT)!=null || parser.getArgumentById(REMOTE_OPT_PARAM)!=null; if (gui && remoteStart) { error = "-r and -R are only valid in non-GUI mode"; } } if (null != error) { System.err.println("Error: " + error); System.out.println("Usage"); System.out.println(CLUtil.describeOptions(options).toString()); return; } try { initializeProperties(parser); // Also initialises JMeter logging /* * The following is needed for HTTPClient. * (originally tried doing this in HTTPSampler2, * but it appears that it was done too late when running in GUI mode) * Set the commons logging default to Avalon Logkit, if not already defined */ if (System.getProperty("org.apache.commons.logging.Log") == null) { // $NON-NLS-1$ System.setProperty("org.apache.commons.logging.Log" // $NON-NLS-1$ , "org.apache.commons.logging.impl.LogKitLogger"); // $NON-NLS-1$ } log.info(JMeterUtils.getJMeterCopyright()); log.info("Version " + JMeterUtils.getJMeterVersion()); logProperty("java.version"); //$NON-NLS-1$ logProperty("java.vm.name"); //$NON-NLS-1$ logProperty("os.name"); //$NON-NLS-1$ logProperty("os.arch"); //$NON-NLS-1$ logProperty("os.version"); //$NON-NLS-1$ logProperty("file.encoding"); // $NON-NLS-1$ log.info("Default Locale=" + Locale.getDefault().getDisplayName()); log.info("JMeter Locale=" + JMeterUtils.getLocale().getDisplayName()); log.info("JMeterHome=" + JMeterUtils.getJMeterHome()); logProperty("user.dir"," ="); //$NON-NLS-1$ log.info("PWD ="+new File(".").getCanonicalPath());//$NON-NLS-1$ log.info("IP: "+JMeterUtils.getLocalHostIP() +" Name: "+JMeterUtils.getLocalHostName() +" FullName: "+JMeterUtils.getLocalHostFullName()); setProxy(parser); updateClassLoader(); if (log.isDebugEnabled()) { String jcp=System.getProperty("java.class.path");// $NON-NLS-1$ String bits[] =jcp.split(File.pathSeparator); log.debug("ClassPath"); for(int i = 0; i<bits.length ;i++){ log.debug(bits[i]); } log.debug(jcp); } // Set some (hopefully!) useful properties long now=System.currentTimeMillis(); JMeterUtils.setProperty("START.MS",Long.toString(now));// $NON-NLS-1$ Date today=new Date(now); // so it agrees with above // TODO perhaps should share code with __time() function for this... JMeterUtils.setProperty("START.YMD",new SimpleDateFormat("yyyyMMdd").format(today));// $NON-NLS-1$ $NON-NLS-2$ JMeterUtils.setProperty("START.HMS",new SimpleDateFormat("HHmmss").format(today));// $NON-NLS-1$ $NON-NLS-2$ if (parser.getArgumentById(VERSION_OPT) != null) { System.out.println(JMeterUtils.getJMeterCopyright()); System.out.println("Version " + JMeterUtils.getJMeterVersion()); } else if (parser.getArgumentById(HELP_OPT) != null) { System.out.println(JMeterUtils.getResourceFileAsText("org/apache/jmeter/help.txt"));// $NON-NLS-1$ } else if (parser.getArgumentById(SERVER_OPT) != null) { // Start the server startServer(JMeterUtils.getPropDefault("server_port", 0));// $NON-NLS-1$ startOptionalServers(); } else { String testFile=null; CLOption testFileOpt = parser.getArgumentById(TESTFILE_OPT); if (testFileOpt != null){ testFile = testFileOpt.getArgument(); if (USE_LAST_JMX.equals(testFile)) { testFile = LoadRecentProject.getRecentFile(0);// most recent } } if (parser.getArgumentById(NONGUI_OPT) == null) { startGui(testFile); startOptionalServers(); } else { CLOption rem=parser.getArgumentById(REMOTE_OPT_PARAM); if (rem==null) { rem=parser.getArgumentById(REMOTE_OPT); } CLOption jtl = parser.getArgumentById(LOGFILE_OPT); String jtlFile = null; if (jtl != null){ jtlFile=processLAST(jtl.getArgument(), ".jtl"); // $NON-NLS-1$ } startNonGui(testFile, jtlFile, rem); startOptionalServers(); } } } catch (IllegalUserActionException e) { System.out.println(e.getMessage()); System.out.println("Incorrect Usage"); System.out.println(CLUtil.describeOptions(options).toString()); } catch (Throwable e) { if (log != null){ log.fatalError("An error occurred: ",e); } else { e.printStackTrace(); } System.out.println("An error occurred: " + e.getMessage()); System.exit(1); } } // Update classloader if necessary private void updateClassLoader() { updatePath("search_paths",";"); //$NON-NLS-1$//$NON-NLS-2$ updatePath("user.classpath",File.pathSeparator);//$NON-NLS-1$ } private void updatePath(String property, String sep) { String userpath= JMeterUtils.getPropDefault(property,"");// $NON-NLS-1$ if (userpath.length() <= 0) { return; } log.info(property+"="+userpath); //$NON-NLS-1$ StringTokenizer tok = new StringTokenizer(userpath, sep); while(tok.hasMoreTokens()) { String path=tok.nextToken(); File f=new File(path); if (!f.canRead() && !f.isDirectory()) { log.warn("Can't read "+path); } else { log.info("Adding to classpath: "+path); try { NewDriver.addPath(path); } catch (MalformedURLException e) { log.warn("Error adding: "+path+" "+e.getLocalizedMessage()); } } } } /** * */ private void startOptionalServers() { int bshport = JMeterUtils.getPropDefault("beanshell.server.port", 0);// $NON-NLS-1$ String bshfile = JMeterUtils.getPropDefault("beanshell.server.file", "");// $NON-NLS-1$ $NON-NLS-2$ if (bshport > 0) { log.info("Starting Beanshell server (" + bshport + "," + bshfile + ")"); Runnable t = new BeanShellServer(bshport, bshfile); t.run(); } // Should we run a beanshell script on startup? String bshinit = JMeterUtils.getProperty("beanshell.init.file");// $NON-NLS-1$ if (bshinit != null){ log.info("Run Beanshell on file: "+bshinit); try { BeanShellInterpreter bsi = new BeanShellInterpreter();//bshinit,log); bsi.source(bshinit); } catch (ClassNotFoundException e) { log.warn("Could not start Beanshell: "+e.getLocalizedMessage()); } catch (JMeterException e) { log.warn("Could not process Beanshell file: "+e.getLocalizedMessage()); } } int mirrorPort=JMeterUtils.getPropDefault("mirror.server.port", 0);// $NON-NLS-1$ if (mirrorPort > 0){ log.info("Starting Mirror server (" + mirrorPort + ")"); try { Object instance = ClassTools.construct( "org.apache.jmeter.protocol.http.control.HttpMirrorControl",// $NON-NLS-1$ mirrorPort); ClassTools.invoke(instance,"startHttpMirror"); } catch (JMeterException e) { log.warn("Could not start Mirror server",e); } } } /** * Sets a proxy server for the JVM if the command line arguments are * specified. */ private void setProxy(CLArgsParser parser) throws IllegalUserActionException { if (parser.getArgumentById(PROXY_USERNAME) != null) { Properties jmeterProps = JMeterUtils.getJMeterProperties(); if (parser.getArgumentById(PROXY_PASSWORD) != null) { String u, p; Authenticator.setDefault(new ProxyAuthenticator(u = parser.getArgumentById(PROXY_USERNAME) .getArgument(), p = parser.getArgumentById(PROXY_PASSWORD).getArgument())); log.info("Set Proxy login: " + u + "/" + p); jmeterProps.setProperty(HTTP_PROXY_USER, u);//for Httpclient jmeterProps.setProperty(HTTP_PROXY_PASS, p);//for Httpclient } else { String u; Authenticator.setDefault(new ProxyAuthenticator(u = parser.getArgumentById(PROXY_USERNAME) .getArgument(), "")); log.info("Set Proxy login: " + u); jmeterProps.setProperty(HTTP_PROXY_USER, u); } } if (parser.getArgumentById(PROXY_HOST) != null && parser.getArgumentById(PROXY_PORT) != null) { String h = parser.getArgumentById(PROXY_HOST).getArgument(); String p = parser.getArgumentById(PROXY_PORT).getArgument(); System.setProperty("http.proxyHost", h );// $NON-NLS-1$ System.setProperty("https.proxyHost", h);// $NON-NLS-1$ System.setProperty("http.proxyPort", p);// $NON-NLS-1$ System.setProperty("https.proxyPort", p);// $NON-NLS-1$ log.info("Set http[s].proxyHost: " + h + " Port: " + p); } else if (parser.getArgumentById(PROXY_HOST) != null || parser.getArgumentById(PROXY_PORT) != null) { throw new IllegalUserActionException(JMeterUtils.getResString("proxy_cl_error"));// $NON-NLS-1$ } if (parser.getArgumentById(NONPROXY_HOSTS) != null) { String n = parser.getArgumentById(NONPROXY_HOSTS).getArgument(); System.setProperty("http.nonProxyHosts", n );// $NON-NLS-1$ System.setProperty("https.nonProxyHosts", n );// $NON-NLS-1$ log.info("Set http[s].nonProxyHosts: "+n); } } private void initializeProperties(CLArgsParser parser) { if (parser.getArgumentById(PROPFILE_OPT) != null) { JMeterUtils.loadJMeterProperties(parser.getArgumentById(PROPFILE_OPT).getArgument()); } else { JMeterUtils.loadJMeterProperties(NewDriver.getJMeterDir() + File.separator + "bin" + File.separator // $NON-NLS-1$ + "jmeter.properties");// $NON-NLS-1$ } if (parser.getArgumentById(JMLOGFILE_OPT) != null){ String jmlogfile=parser.getArgumentById(JMLOGFILE_OPT).getArgument(); jmlogfile = processLAST(jmlogfile, ".log");// $NON-NLS-1$ JMeterUtils.setProperty(LoggingManager.LOG_FILE,jmlogfile); } JMeterUtils.initLogging(); JMeterUtils.initLocale(); // Bug 33845 - allow direct override of Home dir if (parser.getArgumentById(JMETER_HOME_OPT) == null) { JMeterUtils.setJMeterHome(NewDriver.getJMeterDir()); } else { JMeterUtils.setJMeterHome(parser.getArgumentById(JMETER_HOME_OPT).getArgument()); } Properties jmeterProps = JMeterUtils.getJMeterProperties(); remoteProps = new Properties(); // Add local JMeter properties, if the file is found String userProp = JMeterUtils.getPropDefault("user.properties",""); //$NON-NLS-1$ if (userProp.length() > 0){ //$NON-NLS-1$ FileInputStream fis=null; try { File file = JMeterUtils.findFile(userProp); if (file.canRead()){ log.info("Loading user properties from: "+file.getCanonicalPath()); fis = new FileInputStream(file); Properties tmp = new Properties(); tmp.load(fis); jmeterProps.putAll(tmp); LoggingManager.setLoggingLevels(tmp);//Do what would be done earlier } } catch (IOException e) { log.warn("Error loading user property file: " + userProp, e); } finally { JOrphanUtils.closeQuietly(fis); } } // Add local system properties, if the file is found String sysProp = JMeterUtils.getPropDefault("system.properties",""); //$NON-NLS-1$ if (sysProp.length() > 0){ FileInputStream fis=null; try { File file = JMeterUtils.findFile(sysProp); if (file.canRead()){ log.info("Loading system properties from: "+file.getCanonicalPath()); fis = new FileInputStream(file); System.getProperties().load(fis); } } catch (IOException e) { log.warn("Error loading system property file: " + sysProp, e); } finally { JOrphanUtils.closeQuietly(fis); } } // Process command line property definitions // These can potentially occur multiple times List clOptions = parser.getArguments(); int size = clOptions.size(); for (int i = 0; i < size; i++) { CLOption option = (CLOption) clOptions.get(i); String name = option.getArgument(0); String value = option.getArgument(1); FileInputStream fis = null; switch (option.getDescriptor().getId()) { // Should not have any text arguments case CLOption.TEXT_ARGUMENT: throw new IllegalArgumentException("Unknown arg: "+option.getArgument()); case PROPFILE2_OPT: // Bug 33920 - allow multiple props try { fis = new FileInputStream(new File(name)); Properties tmp = new Properties(); tmp.load(fis); jmeterProps.putAll(tmp); LoggingManager.setLoggingLevels(tmp);//Do what would be done earlier } catch (FileNotFoundException e) { log.warn("Can't find additional property file: " + name, e); } catch (IOException e) { log.warn("Error loading additional property file: " + name, e); } finally { JOrphanUtils.closeQuietly(fis); } break; case SYSTEM_PROPFILE: log.info("Setting System properties from file: " + name); try { fis = new FileInputStream(new File(name)); System.getProperties().load(fis); } catch (IOException e) { log.warn("Cannot find system property file "+e.getLocalizedMessage()); } finally { JOrphanUtils.closeQuietly(fis); } break; case SYSTEM_PROPERTY: if (value.length() > 0) { // Set it log.info("Setting System property: " + name + "=" + value); System.getProperties().setProperty(name, value); } else { // Reset it log.warn("Removing System property: " + name); System.getProperties().remove(name); } break; case JMETER_PROPERTY: if (value.length() > 0) { // Set it log.info("Setting JMeter property: " + name + "=" + value); jmeterProps.setProperty(name, value); } else { // Reset it log.warn("Removing JMeter property: " + name); jmeterProps.remove(name); } break; case JMETER_GLOBAL_PROP: if (value.length() > 0) { // Set it log.info("Setting Global property: " + name + "=" + value); remoteProps.setProperty(name, value); } else { File propFile = new File(name); if (propFile.canRead()) { log.info("Setting Global properties from the file "+name); try { fis = new FileInputStream(propFile); remoteProps.load(fis); } catch (FileNotFoundException e) { log.warn("Could not find properties file: "+e.getLocalizedMessage()); } catch (IOException e) { log.warn("Could not load properties file: "+e.getLocalizedMessage()); } finally { JOrphanUtils.closeQuietly(fis); } } } break; case LOGLEVEL: if (value.length() > 0) { // Set category log.info("LogLevel: " + name + "=" + value); LoggingManager.setPriority(value, name); } else { // Set root level log.warn("LogLevel: " + name); LoggingManager.setPriority(name); } break; case REMOTE_STOP: remoteStop = true; break; } } } /* * Checks for LAST or LASTsuffix. * Returns the LAST name with .JMX replaced by suffix. */ private String processLAST(String jmlogfile, String suffix) { if (USE_LAST_JMX.equals(jmlogfile) || USE_LAST_JMX.concat(suffix).equals(jmlogfile)){ String last = LoadRecentProject.getRecentFile(0);// most recent final String JMX_SUFFIX = ".JMX"; // $NON-NLS-1$ if (last.toUpperCase(Locale.ENGLISH).endsWith(JMX_SUFFIX)){ jmlogfile=last.substring(0, last.length() - JMX_SUFFIX.length()).concat(suffix); } } return jmlogfile; } private void startServer(int port) { try { new RemoteJMeterEngineImpl(port); } catch (Exception ex) { log.error("Giving up, as server failed with:", ex); System.err.println("Server failed to start: "+ex); System.exit(1);// Give up } } private void startNonGui(String testFile, String logFile, CLOption remoteStart) throws IllegalUserActionException { // add a system property so samplers can check to see if JMeter // is running in NonGui mode System.setProperty("JMeter.NonGui", "true");// $NON-NLS-1$ JMeter driver = new JMeter();// TODO - why does it create a new instance? driver.remoteProps = this.remoteProps; driver.remoteStop = this.remoteStop; driver.parent = this; PluginManager.install(this, false); String remote_hosts_string = null; if (remoteStart != null) { remote_hosts_string = remoteStart.getArgument(); if (remote_hosts_string == null) { remote_hosts_string = JMeterUtils.getPropDefault( "remote_hosts", //$NON-NLS-1$ "127.0.0.1");//$NON-NLS-1$ } } if (testFile == null) { throw new IllegalUserActionException("Non-GUI runs require a test plan"); } if (logFile == null) { driver.run(testFile, null, remoteStart != null,remote_hosts_string); } else { driver.run(testFile, logFile, remoteStart != null,remote_hosts_string); } } // run test in batch mode private void run(String testFile, String logFile, boolean remoteStart, String remote_hosts_string) { FileInputStream reader = null; try { File f = new File(testFile); if (!f.exists() || !f.isFile()) { println("Could not open " + testFile); return; } FileServer.getFileServer().setBasedir(f.getAbsolutePath()); reader = new FileInputStream(f); log.info("Loading file: " + f); HashTree tree = SaveService.loadTree(reader); JMeterTreeModel treeModel = new JMeterTreeModel(new Object());// Create non-GUI version to avoid headless problems JMeterTreeNode root = (JMeterTreeNode) treeModel.getRoot(); treeModel.addSubTree(tree, root); // Hack to resolve ModuleControllers in non GUI mode SearchByClass replaceableControllers = new SearchByClass(ReplaceableController.class); tree.traverse(replaceableControllers); Collection replaceableControllersRes = replaceableControllers.getSearchResults(); for (Iterator iter = replaceableControllersRes.iterator(); iter.hasNext();) { ReplaceableController replaceableController = (ReplaceableController) iter.next(); replaceableController.resolveReplacementSubTree(root); } // Remove the disabled items // For GUI runs this is done in Start.java convertSubTree(tree); if (logFile != null) { ResultCollector logger = new ResultCollector(); logger.setFilename(logFile); tree.add(tree.getArray()[0], logger); } String summariserName = JMeterUtils.getPropDefault("summariser.name", "");//$NON-NLS-1$ if (summariserName.length() > 0) { log.info("Creating summariser <" + summariserName + ">"); println("Creating summariser <" + summariserName + ">"); Summariser summer = new Summariser(summariserName); tree.add(tree.getArray()[0], summer); } List engines = new LinkedList(); tree.add(tree.getArray()[0], new ListenToTest(parent, (remoteStart && remoteStop) ? engines : null)); println("Created the tree successfully using "+testFile); JMeterEngine engine = null; if (!remoteStart) { engine = new StandardJMeterEngine(); engine.configure(tree); long now=System.currentTimeMillis(); println("Starting the test @ "+new Date(now)+" ("+now+")"); engine.runTest(); } else { java.util.StringTokenizer st = new java.util.StringTokenizer(remote_hosts_string, ",");//$NON-NLS-1$ while (st.hasMoreElements()) { String el = (String) st.nextElement(); println("Configuring remote engine for " + el); engines.add(doRemoteInit(el.trim(), tree)); } println("Starting remote engines"); long now=System.currentTimeMillis(); println("Starting the test @ "+new Date(now)+" ("+now+")"); Iterator iter = engines.iterator(); while (iter.hasNext()) { engine = (JMeterEngine) iter.next(); engine.runTest(); } println("Remote engines have been started"); } } catch (Exception e) { System.out.println("Error in NonGUIDriver " + e.toString()); log.error("", e); } finally { JOrphanUtils.closeQuietly(reader); } } /** * Refactored from AbstractAction.java * * @param tree */ public static void convertSubTree(HashTree tree) { Iterator iter = new LinkedList(tree.list()).iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof TestElement) { TestElement item = (TestElement) o; if (item.isEnabled()) { if (item instanceof ReplaceableController) { // HACK: force the controller to load its tree ReplaceableController rc = (ReplaceableController) item .clone(); HashTree subTree = tree.getTree(item); if (subTree != null) { HashTree replacementTree = rc .getReplacementSubTree(); if (replacementTree != null) { convertSubTree(replacementTree); tree.replace(item, rc); tree.set(rc, replacementTree); } } else { convertSubTree(tree.getTree(item)); } } else { convertSubTree(tree.getTree(item)); } } else { tree.remove(item); } } else { JMeterTreeNode item = (JMeterTreeNode) o; if (item.isEnabled()) { // Replacement only needs to occur when starting the engine // @see StandardJMeterEngine.run() if (item.getUserObject() instanceof ReplaceableController) { ReplaceableController rc = (ReplaceableController) item .getTestElement(); HashTree subTree = tree.getTree(item); if (subTree != null) { HashTree replacementTree = rc .getReplacementSubTree(); if (replacementTree != null) { convertSubTree(replacementTree); tree.replace(item, rc); tree.set(rc, replacementTree); } } } else { convertSubTree(tree.getTree(item)); TestElement testElement = item.getTestElement(); tree.replace(item, testElement); } } else { tree.remove(item); } } } } private JMeterEngine doRemoteInit(String hostName, HashTree testTree) { JMeterEngine engine = null; try { engine = new ClientJMeterEngine(hostName); } catch (Exception e) { log.fatalError("Failure connecting to remote host", e); System.err.println("Failure connecting to remote host"+e); System.exit(1); } engine.configure(testTree); if (!remoteProps.isEmpty()) { engine.setProperties(remoteProps); } return engine; } /* * Listen to test and handle tidyup after non-GUI test completes. * If running a remote test, then after waiting a few seconds for listeners to finish files, * it calls System.exit to deal with the Naming Timer Thread. */ private static class ListenToTest implements TestListener, Runnable, Remoteable { private int started = 0; // keep track of remote tests //NOT YET USED private JMeter _parent; private List engines; public ListenToTest(JMeter parent, List engines) { //_parent = parent; this.engines=engines; } public synchronized void testEnded(String host) { started--; long now=System.currentTimeMillis(); log.info("Finished remote host: " + host + " ("+now+")"); if (started <= 0) { Thread stopSoon = new Thread(this); stopSoon.start(); } } public void testEnded() { long now = System.currentTimeMillis(); println("Tidying up ... @ "+new Date(now)+" ("+now+")"); println("... end of run"); } public synchronized void testStarted(String host) { started++; long now=System.currentTimeMillis(); log.info("Started remote host: " + host + " ("+now+")"); } public void testStarted() { long now=System.currentTimeMillis(); log.info(JMeterUtils.getResString("running_test")+" ("+now+")");//$NON-NLS-1$ } /** * This is a hack to allow listeners a chance to close their files. Must * implement a queue for sample responses tied to the engine, and the * engine won't deliver testEnded signal till all sample responses have * been delivered. Should also improve performance of remote JMeter * testing. */ public void run() { long now = System.currentTimeMillis(); println("Tidying up ... @ "+new Date(now)+" ("+now+")"); /* * Note: although it should not be necessary to call System.exit here, in the case * of a remote test, a Timer thread seems to be generated by the Naming.lookup() * method, and it does not die. */ if (engines!=null){ // it will be null unless remoteStop = true System.out.println("Exitting remote servers"); Iterator it = engines.iterator(); while(it.hasNext()){ JMeterEngine e = (JMeterEngine) it.next(); e.exit(); } } try { Thread.sleep(5000); // Allow listeners to close files } catch (InterruptedException ignored) { } println("... end of run"); System.exit(0); } /** * @see TestListener#testIterationStart(LoopIterationEvent) */ public void testIterationStart(LoopIterationEvent event) { // ignored } } private static void println(String str) { System.out.println(str); } private static final String[][] DEFAULT_ICONS = { { "org.apache.jmeter.control.gui.TestPlanGui", "org/apache/jmeter/images/beaker.gif" }, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.timers.gui.AbstractTimerGui", "org/apache/jmeter/images/timer.gif" }, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.threads.gui.ThreadGroupGui", "org/apache/jmeter/images/thread.gif" }, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.visualizers.gui.AbstractListenerGui", "org/apache/jmeter/images/meter.png" }, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.config.gui.AbstractConfigGui", "org/apache/jmeter/images/testtubes.png" }, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.processor.gui.AbstractPreProcessorGui", "org/apache/jmeter/images/leafnode.gif"}, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.processor.gui.AbstractPostProcessorGui","org/apache/jmeter/images/leafnodeflip.gif"},//$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.control.gui.AbstractControllerGui", "org/apache/jmeter/images/knob.gif" }, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.control.gui.WorkBenchGui", "org/apache/jmeter/images/clipboard.gif" }, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.samplers.gui.AbstractSamplerGui", "org/apache/jmeter/images/pipet.png" }, //$NON-NLS-1$ $NON-NLS-2$ { "org.apache.jmeter.assertions.gui.AbstractAssertionGui", "org/apache/jmeter/images/question.gif"} //$NON-NLS-1$ $NON-NLS-2$ }; public String[][] getIconMappings() { final String defaultIconProp = "org/apache/jmeter/images/icon.properties"; //$NON-NLS-1$ String iconProp = JMeterUtils.getPropDefault("jmeter.icons", defaultIconProp);//$NON-NLS-1$ Properties p = JMeterUtils.loadProperties(iconProp); if (p == null && !iconProp.equals(defaultIconProp)) { log.info(iconProp + " not found - using " + defaultIconProp); iconProp = defaultIconProp; p = JMeterUtils.loadProperties(iconProp); } if (p == null) { log.info(iconProp + " not found - using inbuilt icon set"); return DEFAULT_ICONS; } log.info("Loaded icon properties from " + iconProp); String[][] iconlist = new String[p.size()][3]; Enumeration pe = p.keys(); int i = 0; while (pe.hasMoreElements()) { String key = (String) pe.nextElement(); String icons[] = JOrphanUtils.split(p.getProperty(key), " ");//$NON-NLS-1$ iconlist[i][0] = key; iconlist[i][1] = icons[0]; if (icons.length > 1) { iconlist[i][2] = icons[1]; } i++; } return iconlist; } public String[][] getResourceBundles() { return new String[0][]; } private void logProperty(String prop){ log.info(prop+"="+System.getProperty(prop));//$NON-NLS-1$ } private void logProperty(String prop,String separator){ log.info(prop+separator+System.getProperty(prop));//$NON-NLS-1$ } }

The table below shows all metrics for JMeter.java.

MetricValueDescription
BLOCKS156.00Number of blocks
BLOCK_COMMENT37.00Number of block comment lines
COMMENTS111.00Comment lines
COMMENT_DENSITY 0.16Comment density
COMPARISONS103.00Number of comparison operators
CYCLOMATIC134.00Cyclomatic complexity
DECL_COMMENTS20.00Comments in declarations
DOC_COMMENT43.00Number of javadoc comment lines
ELOC698.00Effective lines of code
EXEC_COMMENTS19.00Comments in executable code
EXITS156.00Procedure exits
FUNCTIONS26.00Number of function declarations
HALSTEAD_DIFFICULTY93.85Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY63.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 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 1.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 3.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 1.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 2.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 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 1.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
JAVA0108 3.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.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 1.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 2.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 2.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 1.00JAVA0128 Public constructor in non-public class
JAVA0130 7.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 2.00JAVA0143 Synchronized method
JAVA014411.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 5.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 1.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 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 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 4.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 1.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 1.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 1.00JAVA0265 Use of Throwable.printStackTrace()
JAVA026612.00JAVA0266 Use of System.out
JAVA0267 3.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 2.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
LINES1002.00Number of lines in the source file
LINE_COMMENT31.00Number of line comments
LOC807.00Lines of code
LOGICAL_LINES456.00Number of statements
LOOPS 9.00Number of loops
NEST_DEPTH 7.00Maximum nesting depth
OPERANDS2259.00Number of operands
OPERATORS3876.00Number of operators
PARAMS28.00Number of formal parameter declarations
PROGRAM_LENGTH6135.00Halstead program length
PROGRAM_VOCAB743.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS35.00Number of return points from functions
SIZE46613.00Size of the file in bytes
UNIQUE_OPERANDS686.00Number of unique operands
UNIQUE_OPERATORS57.00Number of unique operators
WHITESPACE84.00Number of whitespace lines