StandardPreverifier.java

Index Score
eclipseme.core.model.impl
EclipseME

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
DECL_COMMENTSComments in declarations
UNIQUE_OPERANDSNumber of unique operands
JAVA0130JAVA0130 Non-static method does not use instance fields
PROGRAM_VOCABHalstead program vocabulary
LINE_COMMENTNumber of line comments
INTERFACE_COMPLEXITYInterface complexity
RETURNSNumber of return points from functions
SIZESize of the file in bytes
OPERANDSNumber of operands
DOC_COMMENTNumber of javadoc comment lines
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
EXEC_COMMENTSComments in executable code
PROGRAM_LENGTHHalstead program length
LINESNumber of lines in the source file
ELOCEffective lines of code
LOGICAL_LINESNumber of statements
OPERATORSNumber of operators
PARAMSNumber of formal parameter declarations
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
LOCLines of code
COMMENTSComment lines
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
CYCLOMATICCyclomatic complexity
JAVA0034JAVA0034 Missing braces in if statement
LOOPSNumber of loops
COMPARISONSNumber of comparison operators
BLOCKSNumber of blocks
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0109JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0173JAVA0173 Unused method parameter
FUNCTIONSNumber of function declarations
JAVA0163JAVA0163 Empty statement
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0145JAVA0145 Tab character used in source file
JAVA0117JAVA0117 Missing javadoc: method 'method'
UNIQUE_OPERATORSNumber of unique operators
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0032JAVA0032 Switch statement missing default
JAVA0174JAVA0174 Assigned local variable never used
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0064JAVA0064 N variations of identifier name (maximum: M)
JAVA0087JAVA0087 Use of Thread.sleep()
/** * Copyright (c) 2003-2006 Craig Setera * All Rights Reserved. * Licensed under the Eclipse Public License - v 1.0 * For more information see http://www.eclipse.org/legal/epl-v10.html */ package eclipseme.core.model.impl; import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.debug.core.IStreamListener; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IStreamMonitor; import org.eclipse.debug.core.model.IStreamsProxy; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.launching.IVMInstall; import org.eclipse.jdt.launching.IVMInstallType; import org.eclipse.jdt.launching.JavaRuntime; import eclipseme.core.BuildLoggingConfiguration; import eclipseme.core.IEclipseMECoreConstants; import eclipseme.core.console.BuildConsoleProxy; import eclipseme.core.console.IBuildConsoleProxy; import eclipseme.core.internal.EclipseMECorePlugin; import eclipseme.core.internal.PreferenceAccessor; import eclipseme.core.internal.utils.EnvironmentVariables; import eclipseme.core.internal.utils.TemporaryFileManager; import eclipseme.core.internal.utils.Utils; import eclipseme.core.model.IMidletSuiteProject; import eclipseme.core.model.IPreverifier; import eclipseme.core.model.Version; import eclipseme.core.persistence.IPersistenceProvider; import eclipseme.core.persistence.PersistenceException; import eclipseme.preverifier.results.IClassErrorInformation; import eclipseme.preverifier.results.PreverificationError; import eclipseme.preverifier.results.PreverificationErrorLocation; import eclipseme.preverifier.results.PreverificationErrorLocationType; import eclipseme.preverifier.results.PreverificationErrorType; /** * A standard preverifier implementation. This preverifier * requires the preverification binary and the available * CLDC parameters to be specified. Once created, the * preverifier may be stored and retrieved using the standard * persistence mechanism. * <p /> * Copyright (c) 2003-2006 Craig Setera<br> * All Rights Reserved.<br> * Licensed under the Eclipse Public License - v 1.0<p/> * <br> * $Revision: 1.7 $ * <br> * $Date: 2006/12/18 02:13:47 $ * <br> * @author Craig Setera */ public class StandardPreverifier implements IPreverifier { private static final int MAX_COMMAND_LENGTH = 2000; // The regular expression we will use to match the preverify // error private static final String PREV_ERR_REGEX = "^Error preverifying class (\\S*)$"; // The compiled pattern for regular expression matching private static final Pattern PREV_ERR_PATTERN = Pattern.compile(PREV_ERR_REGEX, Pattern.MULTILINE); /** * Extract the class name from the specified * IResource within the specified java project. * * @param javaProject the java project to provide the relative name * @param resource the resource to extract a class name * @return the class name or <code>null</code> if the resource * name cannot be converted for some reason. * @throws JavaModelException */ public static String extractClassName( IJavaProject javaProject, IResource resource) throws JavaModelException { IPath classPath = extractResourcePath(javaProject, resource); return (classPath == null) ? null : classPath.removeFileExtension().toString().replace('/', '.'); } /** * Extract the class path from the specified * IResource within the specified java project. * * @param javaProject * @param resource * @return the extracted resource path * @throws JavaModelException */ public static IPath extractResourcePath( IJavaProject javaProject, IResource resource) throws JavaModelException { IPath resultPath = null; IPath projectOutputPath = javaProject.getOutputLocation().makeAbsolute(); IPath resourcePath = resource.getFullPath(); IClasspathEntry[] classpath = javaProject.getRawClasspath(); for (int i = 0; i < classpath.length; i++) { IClasspathEntry entry = classpath[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath entryPath = entry.getOutputLocation(); entryPath = (entryPath == null) ? projectOutputPath : entryPath.makeAbsolute(); if (entryPath.isPrefixOf(resourcePath)) { resultPath = resourcePath.removeFirstSegments(entryPath.segmentCount()); } } } return resultPath; } // The executable to use for preverification private File preverifierExecutable; // The parameters to use private StandardPreverifierParameters parameters; /** * @see eclipseme.core.persistence.IPersistable#loadUsing(eclipseme.core.persistence.IPersistenceProvider) */ public void loadUsing(IPersistenceProvider persistenceProvider) throws PersistenceException { String preverifierExeString = persistenceProvider.loadString("preverifierExecutable"); preverifierExecutable = new File(preverifierExeString); parameters = (StandardPreverifierParameters) persistenceProvider.loadPersistable("parameters"); } /** * @see eclipseme.core.model.IPreverifier#preverify(eclipseme.core.model.IMidletSuiteProject, org.eclipse.core.resources.IResource[], org.eclipse.core.resources.IFolder, org.eclipse.core.runtime.IProgressMonitor) */ public PreverificationError[] preverify( IMidletSuiteProject midletProject, IResource[] toVerify, IFolder outputFolder, IProgressMonitor monitor) throws CoreException, IOException { ArrayList allErrors = new ArrayList(); // Create the temporary file of commands for // the verifier ensureFolderExists(outputFolder, monitor); File outputFile = outputFolder.getLocation().toFile(); ArrayList baseArguments = constructCommandLine( midletProject, outputFile, monitor); ArrayList arguments = new ArrayList(baseArguments); for (int i = 0; i < toVerify.length; i++) { IResource resource = toVerify[i]; switch (resource.getType()) { case IResource.FOLDER: case IResource.PROJECT: arguments.add(resource.getLocation().toOSString()); break; case IResource.FILE: if (resource.getName().endsWith(".class")) { addClassTarget(arguments, resource); } else if (resource.getName().endsWith(".jar")) { arguments.add(resource.getLocation().toOSString()); } break; } if (commandLength(arguments) > MAX_COMMAND_LENGTH) { // Launch the system process String[] commandLine = (String[]) arguments.toArray(new String[arguments.size()]); PreverificationError[] errors = runPreverifier(commandLine, null, monitor); allErrors.addAll(Arrays.asList(errors)); arguments = new ArrayList(baseArguments); } } if (arguments.size() != baseArguments.size()) { // Launch the system process String[] commandLine = (String[]) arguments.toArray(new String[arguments.size()]); PreverificationError[] errors = runPreverifier(commandLine, null, monitor); allErrors.addAll(Arrays.asList(errors)); } return (PreverificationError[]) allErrors.toArray(new PreverificationError[allErrors.size()]); } /** * @see eclipseme.core.model.IPreverifier#preverifyJarFile(eclipseme.core.model.IMidletSuiteProject, java.io.File, org.eclipse.core.resources.IFolder, org.eclipse.core.runtime.IProgressMonitor) */ public PreverificationError[] preverifyJarFile( IMidletSuiteProject midletProject, File jarFile, IFolder outputFolder, IProgressMonitor monitor) throws CoreException, IOException { // Rather than trying to preverify a jar file, we will expand it // first and then preverify against the expanded classes. File srcDirectory = TemporaryFileManager.instance.createTempDirectory( jarFile.getName().replace('.', '_') + "_", ".tmp"); srcDirectory.mkdirs(); Utils.extractArchive(jarFile, srcDirectory); // Create the target directory for the preverification. We will // tell the preverifier to use this when doing the preverification. File tgtDirectory = TemporaryFileManager.instance.createTempDirectory( jarFile.getName().replace('.', '_') + "_", ".tmp"); tgtDirectory.mkdirs(); ArrayList arguments = constructCommandLine( midletProject, tgtDirectory, monitor); arguments.add(srcDirectory.toString()); // Launch the system process String[] environment = getEnvironment(jarFile); String[] commandLine = (String[]) arguments.toArray(new String[arguments.size()]); PreverificationError[] errors = runPreverifier(commandLine, environment, monitor); // TODO we need to test the outcome of the previous before going much further // here... // Copy all of the non-class resources so they end up back in the // jar file FileFilter classFilter = new FileFilter() { public boolean accept(File pathname) { return pathname.isDirectory() || !pathname.getName().endsWith(".class"); } }; Utils.copy(srcDirectory, tgtDirectory, classFilter); // Finally, re-jar the output of the preverification into the requested jar file... File outputJarFile = new File(outputFolder.getLocation().toFile(), jarFile.getName()); Utils.createArchive(outputJarFile, tgtDirectory); return errors; } /** * Return the length of the command-line length given the specified argument list. * * @param arguments * @return */ private int commandLength(ArrayList arguments) { int length = 0; Iterator iter = arguments.iterator(); while (iter.hasNext()) { Object arg = (Object) iter.next(); length += arg.toString().length(); if (iter.hasNext()) length++; } return length; } /** * Construct the command line for the specified preverification. * * @param midletProject * @param target * @return * @throws CoreException */ private ArrayList constructCommandLine( IMidletSuiteProject midletProject, File target, IProgressMonitor monitor) throws CoreException { ArrayList arguments = new ArrayList(); // The program we are running... arguments.add(preverifierExecutable.toString()); // Configuration parameters String[] configurationParameters = getCLDCConfigurationParameters(midletProject); for (int i = 0; i < configurationParameters.length; i++) { arguments.add(configurationParameters[i]); } addClasspath(arguments, midletProject, monitor); addOptions(arguments, configurationParameters, target); return arguments; } /** * @return Returns the parameters. */ public StandardPreverifierParameters getParameters() { return parameters; } /** * @return Returns the preverifierExecutable. */ public File getPreverifierExecutable() { return preverifierExecutable; } /** * @param parameters The parameters to set. */ public void setParameters(StandardPreverifierParameters parameters) { this.parameters = parameters; } /** * @param preverifierExecutable The preverifierExecutable to set. */ public void setPreverifierExecutable(File preverifierExecutable) { this.preverifierExecutable = preverifierExecutable; } /** * @see eclipseme.core.persistence.IPersistable#storeUsing(eclipseme.core.persistence.IPersistenceProvider) */ public void storeUsing(IPersistenceProvider persistenceProvider) throws PersistenceException { persistenceProvider.storeString("preverifierExecutable", preverifierExecutable.toString()); persistenceProvider.storePersistable("parameters", parameters); } /** * Return the parameters to be used for controlling the CLDC * preverification. * * @param midletProject * @return * @throws CoreException if an error occurs working with the midlet project. */ protected String[] getCLDCConfigurationParameters(IMidletSuiteProject midletProject) throws CoreException { IProject project = midletProject.getProject(); Version configVersion = PreferenceAccessor.instance.getPreverificationConfigurationVersion(project); return isCLDC1_0(configVersion) ? parameters.cldc10 : parameters.cldc11; } /** * Return a boolean indicating whether the specified configuration * is a 1.0 CLDC config. * * @param configSpec * @return */ protected boolean isCLDC1_0(Version configVersion) { return (configVersion.getMajor().equals("1") && configVersion.getMinor().equals("0")); } /** * Run the preverifier program and capture the errors that * occurred during preverification. * * @param commandLine * @param environment * @throws CoreException */ protected PreverificationError[] runPreverifier( String[] commandLine, String[] environment, IProgressMonitor monitor) throws CoreException { final ArrayList errorList = new ArrayList(); IProcess process = Utils.launchApplication( commandLine, null, environment, "Preverifier", "CLDC Preverifier"); // Listen on the process output streams IStreamsProxy proxy = process.getStreamsProxy(); if (BuildLoggingConfiguration.instance.isPreverifierOutputEnabled()) { BuildConsoleProxy.instance.traceln("======================== Launching Preverification ========================="); BuildConsoleProxy.instance.addConsoleStreamListener( IBuildConsoleProxy.ID_ERROR_STREAM, proxy.getErrorStreamMonitor()); BuildConsoleProxy.instance.addConsoleStreamListener( IBuildConsoleProxy.ID_OUTPUT_STREAM, proxy.getOutputStreamMonitor()); } proxy.getErrorStreamMonitor().addListener(new IStreamListener() { public void streamAppended(String text, IStreamMonitor monitor) { handleErrorReceived(text, errorList); } }); // Wait until completion while ((!monitor.isCanceled()) && (!process.isTerminated())) { try { Thread.sleep(100); } catch (InterruptedException e) {}; } if (BuildLoggingConfiguration.instance.isPreverifierOutputEnabled()) { BuildConsoleProxy.instance.traceln("======================== Preverification exited with code: " + process.getExitValue()); } return (PreverificationError[]) errorList.toArray(new PreverificationError[errorList.size()]); } /** * Add classpath information to the arguments for * the specified java project and referenced projects. * * @param commandLine * @param midletProject * @throws CoreException */ private void addClasspath(ArrayList args, IMidletSuiteProject midletProject, IProgressMonitor monitor) throws CoreException { String classpath = getFullClasspath(midletProject); args.add("-classpath"); args.add(classpath); } /** * Add a class target to the resources to be verified. * * @param args * @param resource * @throws JavaModelException */ private void addClassTarget( List args, IResource resource) throws JavaModelException { // Find the source directory this class resides in IProject project = resource.getProject(); IJavaProject javaProject = JavaCore.create(project); String className = extractClassName(javaProject, resource); if (className != null) { args.add(className); } } /** * Add the options to the argument list. * * @param args * @param configurationParameters * @param outputDir */ private void addOptions( ArrayList args, String[] configurationParameters, File outputDir) { args.add("-d"); args.add(outputDir.toString()); } /** * Ensure the specified output folder exists or create if it does not already * exist. * * @param folder * @param monitor * @throws CoreException */ private void ensureFolderExists(IFolder folder, IProgressMonitor monitor) throws CoreException { // Make sure the output folder exists before we start if (!folder.exists()) { folder.create(true, true, monitor); } } /** * Get the environment values for the preverification processing. * * @param The resources to verify. If this is a jar file, the * jar program must be available on the path. * @return * @throws CoreException */ private String[] getEnvironment(File jarFileToVerify) throws CoreException { String[] environment = null; if (jarFileToVerify != null) { // See if the jar executable is available already... if (!isJarExecutableOnPath()) { // See if we can get it from the VM installation IVMInstall fullJDK = searchForVMInstallWithJar(); if (fullJDK == null) { IStatus status = EclipseMECorePlugin.newStatus( IStatus.ERROR, IEclipseMECoreConstants.ERR_COULD_NOT_FIND_JAR_TOOL, "Could not find jar tool executable."); EclipseMECorePlugin.statusPrompt(status, this); } else { // Found a VM installation with the jar tool... // Set the PATH environment value so that the // preverifier can find the jar tool. String pathValue = new File(fullJDK.getInstallLocation(), "bin").toString(); environment = getEnvironmentWithAugmentedPath(pathValue); } } } return environment; } /** * Augment the PATH environment variables and return them * in a form that can be used in an exec() call. * * @param pathValue * @return * @throws CoreException */ private String[] getEnvironmentWithAugmentedPath(String pathValue) throws CoreException { String[] environment = null; try { EnvironmentVariables envVars = new EnvironmentVariables(); String path = envVars.getVariable("PATH"); path = path + File.pathSeparator + pathValue; envVars.setVariable("PATH", path); environment = envVars.convertToStrings(); } catch (IOException e) { EclipseMECorePlugin.throwCoreException(IStatus.ERROR, -999, e); } return environment; } /** * Get the full classpath including all J2ME libraries. * * @param midletProject * @return * @throws CoreException */ private String getFullClasspath(IMidletSuiteProject midletProject) throws CoreException { IJavaProject javaProject = midletProject.getJavaProject(); String[] entries = JavaRuntime.computeDefaultRuntimeClassPath(javaProject); StringBuffer sb = new StringBuffer(); for (int i = 0; i < entries.length; i++) { if (i != 0) { sb.append(File.pathSeparatorChar); } sb.append(entries[i]); } return sb.toString(); } /** * Get the executable for creation of jar files. * * @return */ private String getJarExecutable() { String executable = null; String os = System.getProperty("os.name").toLowerCase(); if ( (os.indexOf("windows 9") > -1) || (os.indexOf("nt") > -1) || (os.indexOf("windows 2000") > -1) || (os.indexOf("windows xp") > -1)) { executable = "jar.exe"; } else { executable = "jar"; } return executable; } /** * Handle the arrival of text on the error stream. * * @param text * @param errorList */ protected void handleErrorReceived(String text, List errorList) { text = text.trim(); Matcher matcher = PREV_ERR_PATTERN.matcher(text); if (matcher.find()) { // Found a match for the error... if (matcher.groupCount() > 0) { final String classname = matcher.group(1); String errorText = "Error preverifying class"; if (matcher.end() < text.length()) { StringBuffer sb = new StringBuffer(errorText); sb.append(": "); String detail = text.substring(matcher.end()); detail = detail.trim(); sb.append(detail); errorText = sb.toString(); } IClassErrorInformation classInfo = new IClassErrorInformation() { public String getName() { return classname; } public String getSourceFile() { return null; } }; PreverificationErrorLocation location = new PreverificationErrorLocation( PreverificationErrorLocationType.UNKNOWN_LOCATION, classInfo, null, null, -1); PreverificationError error = new PreverificationError( PreverificationErrorType.UNKNOWN_ERROR, location, text); errorList.add(error); } } else { EclipseMECorePlugin.log(IStatus.WARNING, text); } } /** * Return a boolean indicating whether the specified * virtual machine installation appears to have the * jar executable within it. * * @param install * @return */ private boolean installContainsJarExecutable(IVMInstall install) { boolean containsJar = false; File installLocation = install.getInstallLocation(); if (installLocation != null) { File bin = new File(installLocation, "bin"); if (bin.exists()) { File[] matches = bin.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().startsWith("jar"); } }); containsJar = ((matches != null) && (matches.length > 0)); } } return containsJar; } /** * Return a boolean indicating whether the JAR executable can be * found on the system path. * * @param testJar * @return * @throws CoreException */ private boolean isJarExecutableOnPath() throws CoreException { boolean onPath = false; String executable = getJarExecutable(); try { EnvironmentVariables envVars = new EnvironmentVariables(); String pathString = envVars.getVariable("PATH"); StringTokenizer st = new StringTokenizer(pathString, File.pathSeparator); while (st.hasMoreTokens()) { File path = new File(st.nextToken()); File jar = new File(path, executable); if (jar.exists()) { onPath = true; break; } } } catch (IOException e) { EclipseMECorePlugin.throwCoreException(IStatus.ERROR, -999, e); } return onPath; } /** * Search for and return a virtual machine installation that appears * to have the jar tool executable contained within. * * @return */ private IVMInstall searchForVMInstallWithJar() { IVMInstall fullJDK = null; IVMInstall install = JavaRuntime.getDefaultVMInstall(); if (installContainsJarExecutable(install)) { fullJDK = install; } else { IVMInstallType installType = install.getVMInstallType(); IVMInstall[] installs = installType.getVMInstalls(); for (int i = 0; i < installs.length; i++) { install = installs[i]; if (installContainsJarExecutable(install)) { fullJDK = install; break; } } } return fullJDK; } }

The table below shows all metrics for StandardPreverifier.java.

MetricValueDescription
BLOCKS73.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS220.00Comment lines
COMMENT_DENSITY 0.59Comment density
COMPARISONS52.00Number of comparison operators
CYCLOMATIC79.00Cyclomatic complexity
DECL_COMMENTS33.00Comments in declarations
DOC_COMMENT189.00Number of javadoc comment lines
ELOC373.00Effective lines of code
EXEC_COMMENTS18.00Comments in executable code
EXITS114.00Procedure exits
FUNCTIONS32.00Number of function declarations
HALSTEAD_DIFFICULTY74.36Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY111.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 1.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 1.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 1.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 2.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 2.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 1.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 1.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 6.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 4.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 3.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 6.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 8.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 1.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 3.00JAVA0144 Line exceeds maximum M characters
JAVA01451416.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 1.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 2.00JAVA0173 Unused method parameter
JAVA0174 1.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 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 4.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
LINES764.00Number of lines in the source file
LINE_COMMENT31.00Number of line comments
LOC455.00Lines of code
LOGICAL_LINES227.00Number of statements
LOOPS 8.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS1146.00Number of operands
OPERATORS1902.00Number of operators
PARAMS45.00Number of formal parameter declarations
PROGRAM_LENGTH3048.00Halstead program length
PROGRAM_VOCAB444.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS66.00Number of return points from functions
SIZE23493.00Size of the file in bytes
UNIQUE_OPERANDS393.00Number of unique operands
UNIQUE_OPERATORS51.00Number of unique operators
WHITESPACE89.00Number of whitespace lines