FindBugs2.java

Index Score
edu.umd.cs.findbugs
FindBugs

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
EXEC_COMMENTSComments in executable code
EXITSProcedure exits
LINE_COMMENTNumber of line comments
UNIQUE_OPERANDSNumber of unique operands
SIZESize of the file in bytes
DECL_COMMENTSComments in declarations
PROGRAM_VOCABHalstead program vocabulary
BLOCKSNumber of blocks
LOGICAL_LINESNumber of statements
RETURNSNumber of return points from functions
PROGRAM_LENGTHHalstead program length
OPERANDSNumber of operands
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
OPERATORSNumber of operators
CYCLOMATICCyclomatic complexity
JAVA0266JAVA0266 Use of System.out
LINESNumber of lines in the source file
ELOCEffective lines of code
LOCLines of code
FUNCTIONSNumber of function declarations
INTERFACE_COMPLEXITYInterface complexity
COMMENTSComment lines
JAVA0267JAVA0267 Use of System.err
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
BLOCK_COMMENTNumber of block comment lines
JAVA0145JAVA0145 Tab character used in source file
JAVA0144JAVA0144 Line exceeds maximum M characters
COMPARISONSNumber of comparison operators
JAVA0150JAVA0150 java.lang.Error (or subclass) thrown
JAVA0034JAVA0034 Missing braces in if statement
WHITESPACENumber of whitespace lines
PARAMSNumber of formal parameter declarations
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0166JAVA0166 Generic exception caught
NEST_DEPTHMaximum nesting depth
UNIQUE_OPERATORSNumber of unique operators
JAVA0075JAVA0075 Method parameter hides field
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0160JAVA0160 Method does not throw specified exception
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0030JAVA0030 Private field not used
LOOPSNumber of loops
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0068JAVA0068 Modifiers not declared in recommended order
/* * FindBugs - Find Bugs in Java programs * Copyright (C) 2006-2008 University of Maryland * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package edu.umd.cs.findbugs; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.apache.bcel.classfile.ClassFormatException; import org.dom4j.DocumentException; import edu.umd.cs.findbugs.ba.AnalysisCacheToAnalysisContextAdapter; import edu.umd.cs.findbugs.ba.AnalysisContext; import edu.umd.cs.findbugs.ba.ObjectTypeFactory; import edu.umd.cs.findbugs.ba.SourceInfoMap; import edu.umd.cs.findbugs.ba.XClass; import edu.umd.cs.findbugs.ba.XFactory; import edu.umd.cs.findbugs.ba.jsr305.TypeQualifierAnnotation; import edu.umd.cs.findbugs.ba.jsr305.TypeQualifierApplications; import edu.umd.cs.findbugs.ba.jsr305.TypeQualifierValue; import edu.umd.cs.findbugs.classfile.CheckedAnalysisException; import edu.umd.cs.findbugs.classfile.ClassDescriptor; import edu.umd.cs.findbugs.classfile.DescriptorFactory; import edu.umd.cs.findbugs.classfile.Global; import edu.umd.cs.findbugs.classfile.IAnalysisCache; import edu.umd.cs.findbugs.classfile.IAnalysisEngineRegistrar; import edu.umd.cs.findbugs.classfile.IClassFactory; import edu.umd.cs.findbugs.classfile.IClassObserver; import edu.umd.cs.findbugs.classfile.IClassPath; import edu.umd.cs.findbugs.classfile.IClassPathBuilder; import edu.umd.cs.findbugs.classfile.ICodeBase; import edu.umd.cs.findbugs.classfile.MissingClassException; import edu.umd.cs.findbugs.classfile.analysis.ClassData; import edu.umd.cs.findbugs.classfile.analysis.ClassNameAndSuperclassInfo; import edu.umd.cs.findbugs.classfile.impl.ClassFactory; import edu.umd.cs.findbugs.config.AnalysisFeatureSetting; import edu.umd.cs.findbugs.config.UserPreferences; import edu.umd.cs.findbugs.filter.FilterException; import edu.umd.cs.findbugs.log.Profiler; import edu.umd.cs.findbugs.plan.AnalysisPass; import edu.umd.cs.findbugs.plan.ExecutionPlan; import edu.umd.cs.findbugs.plan.OrderingConstraintException; import edu.umd.cs.findbugs.util.ClassName; import edu.umd.cs.findbugs.util.Util; import edu.umd.cs.findbugs.util.TopologicalSort.OutEdges; import java.util.Map; /** * FindBugs driver class. * Orchestrates the analysis of a project, collection of results, etc. * * @author David Hovemeyer */ public class FindBugs2 implements IFindBugsEngine2 { private static final boolean LIST_ORDER = SystemProperties.getBoolean("findbugs.listOrder"); private static final boolean VERBOSE = SystemProperties.getBoolean("findbugs.verbose"); public static final boolean DEBUG = VERBOSE || SystemProperties.getBoolean("findbugs.debug"); private static final boolean SCREEN_FIRST_PASS_CLASSES = SystemProperties.getBoolean("findbugs.screenFirstPass"); private static final boolean DEBUG_UA = SystemProperties.getBoolean("ua.debug"); private List<IClassObserver> classObserverList; private ErrorCountingBugReporter bugReporter; private Project project; private IClassFactory classFactory; private IClassPath classPath; private IAnalysisCache analysisCache; private List<ClassDescriptor> appClassList; private Collection<ClassDescriptor> referencedClassSet; private DetectorFactoryCollection detectorFactoryCollection; private ExecutionPlan executionPlan; private UserPreferences userPreferences; private String currentClassName; private String releaseName; private String projectName; private String sourceInfoFileName; private AnalysisFeatureSetting[] analysisFeatureSettingList; private boolean relaxedReportingMode; private boolean abridgedMessages; private String trainingInputDir; private String trainingOutputDir; private FindBugsProgress progress; private IClassScreener classScreener; private boolean scanNestedArchives; private boolean noClassOk; private edu.umd.cs.findbugs.userAnnotations.Plugin userAnnotationPlugin; private boolean userAnnotationSync; /** * Constructor. */ public FindBugs2() { this.classObserverList = new LinkedList<IClassObserver>(); this.analysisFeatureSettingList = FindBugs.DEFAULT_EFFORT; this.progress = new NoOpFindBugsProgress(); // By default, do not exclude any classes via the class screener this.classScreener = new IClassScreener() { /* (non-Javadoc) * @see edu.umd.cs.findbugs.IClassScreener#matches(java.lang.String) */ public boolean matches(String fileName) { return true; } public boolean vacuous() { return true; } }; // By default, we do not want to scan nested archives this.scanNestedArchives = false; } /** * Set the detector factory collection to be used by this * FindBugs2 engine. This method should be called before * the execute() method is called. * * @param detectorFactoryCollection The detectorFactoryCollection to set. */ public void setDetectorFactoryCollection( DetectorFactoryCollection detectorFactoryCollection) { this.detectorFactoryCollection = detectorFactoryCollection; } /** * Execute the analysis. * For obscure reasons, CheckedAnalysisExceptions are re-thrown * as IOExceptions. However, these can only happen during the * setup phase where we scan codebases for classes. * * @throws IOException * @throws InterruptedException */ public void execute() throws IOException, InterruptedException { Profiler profiler = Profiler.getInstance(); try { // Get the class factory for creating classpath/codebase/etc. classFactory = ClassFactory.instance(); // The class path object createClassPath(); // The analysis cache object createAnalysisCache(); progress.reportNumberOfArchives(project.getFileCount() + project.getNumAuxClasspathEntries()); profiler.start(this.getClass()); // Discover all codebases in classpath and // enumerate all classes (application and non-application) buildClassPath(); // Build set of classes referenced by application classes buildReferencedClassSet(); // Create BCEL compatibility layer createAnalysisContext(project, appClassList, sourceInfoFileName); // Configure the BugCollection (if we are generating one) FindBugs.configureBugCollection(this); // Enable/disabled relaxed reporting mode FindBugsAnalysisFeatures.setRelaxedMode(relaxedReportingMode); FindBugsDisplayFeatures.setAbridgedMessages(abridgedMessages); // Configure training databases FindBugs.configureTrainingDatabases(this); // Configure analysis features configureAnalysisFeatures(); // Create the execution plan (which passes/detectors to execute) createExecutionPlan(); if (!classScreener.vacuous()) { final BugReporter origBugReporter = bugReporter.getDelegate(); BugReporter filterBugReporter = new DelegatingBugReporter(origBugReporter) { @Override public void reportBug(BugInstance bugInstance) { String className = bugInstance.getPrimaryClass().getClassName(); String resourceName = className.replace('.', '/') + ".class"; if (classScreener.matches(resourceName)) { this.getDelegate().reportBug(bugInstance); } } }; bugReporter.setDelegate(filterBugReporter); } if (appClassList.size() == 0) { if (noClassOk) { System.err.println("No classfiles specified; output will have no warnings"); } else { throw new NoClassesFoundToAnalyzeException(classPath); } } // Analyze the application analyzeApplication(); } catch (CheckedAnalysisException e) { IOException ioe = new IOException("IOException while scanning codebases"); ioe.initCause(e); throw ioe; } catch (OutOfMemoryError e) { System.err.println("Out of memory"); System.err.println("Total memory: " + Runtime.getRuntime().maxMemory() / 1000000 + "M"); System.err.println(" free memory: " + Runtime.getRuntime().freeMemory() / 1000000 + "M"); for (String s : project.getFileList()) { System.err.println("Analyzed: " + s); } for (String s : project.getAuxClasspathEntryList()) { System.err.println(" Aux: " + s); } throw e; } finally { AnalysisContext.removeCurrentAnalysisContext(); Global.removeAnalysisCacheForCurrentThread(); DescriptorFactory.clearInstance(); ObjectTypeFactory.clearInstance(); TypeQualifierApplications.clearInstance(); TypeQualifierAnnotation.clearInstance(); TypeQualifierValue.clearInstance(); // Make sure the codebases on the classpath are closed if (classPath != null) { classPath.close(); } profiler.end(this.getClass()); profiler.report(); } } /** * To avoid cyclic cross-references and allow GC after engine is not more needed. * (used by Eclipse plugin) */ public void dispose() { if (executionPlan != null) executionPlan.dispose(); if (appClassList != null) appClassList.clear(); if (classObserverList != null) classObserverList.clear(); if (referencedClassSet != null) referencedClassSet.clear(); analysisCache = null; analysisFeatureSettingList = null; bugReporter = null; classFactory = null; classPath = null; classScreener = null; detectorFactoryCollection = null; executionPlan = null; progress = null; project = null; userPreferences = null; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getBugReporter() */ public BugReporter getBugReporter() { return bugReporter; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getProject() */ public Project getProject() { return project; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#addClassObserver(edu.umd.cs.findbugs.classfile.IClassObserver) */ public void addClassObserver(IClassObserver classObserver) { classObserverList.add(classObserver); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#addFilter(java.lang.String, boolean) */ public void addFilter(String filterFileName, boolean include) throws IOException, FilterException { FindBugs.configureFilter(bugReporter, filterFileName, include); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#addBaselineBugs(java.lang.String) */ public void excludeBaselineBugs(String baselineBugs) throws IOException, DocumentException { FindBugs.configureBaselineFilter(bugReporter, baselineBugs); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#enableTrainingInput(java.lang.String) */ public void enableTrainingInput(String trainingInputDir) { this.trainingInputDir = trainingInputDir; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#enableTrainingOutput(java.lang.String) */ public void enableTrainingOutput(String trainingOutputDir) { this.trainingOutputDir = trainingOutputDir; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getBugCount() */ public int getBugCount() { return bugReporter.getBugCount(); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getCurrentClass() */ public String getCurrentClass() { return currentClassName; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getErrorCount() */ public int getErrorCount() { return bugReporter.getErrorCount(); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getMissingClassCount() */ public int getMissingClassCount() { return bugReporter.getMissingClassCount(); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getReleaseName() */ public String getReleaseName() { return releaseName; } public String getProjectName() { return projectName; } public void setProjectName(String name) { projectName = name; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setAnalysisFeatureSettings(edu.umd.cs.findbugs.config.AnalysisFeatureSetting[]) */ public void setAnalysisFeatureSettings(AnalysisFeatureSetting[] settingList) { this.analysisFeatureSettingList = settingList; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setBugReporter(edu.umd.cs.findbugs.BugReporter) */ public void setBugReporter(BugReporter bugReporter) { this.bugReporter = new ErrorCountingBugReporter(bugReporter); addClassObserver(bugReporter); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setClassScreener(edu.umd.cs.findbugs.ClassScreener) */ public void setClassScreener(IClassScreener classScreener) { this.classScreener = classScreener; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setProgressCallback(edu.umd.cs.findbugs.FindBugsProgress) */ public void setProgressCallback(FindBugsProgress progressCallback) { this.progress = progressCallback; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setProject(edu.umd.cs.findbugs.Project) */ public void setProject(Project project) { this.project = project; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setRelaxedReportingMode(boolean) */ public void setRelaxedReportingMode(boolean relaxedReportingMode) { this.relaxedReportingMode = relaxedReportingMode; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setReleaseName(java.lang.String) */ public void setReleaseName(String releaseName) { this.releaseName = releaseName; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setSourceInfoFile(java.lang.String) */ public void setSourceInfoFile(String sourceInfoFile) { this.sourceInfoFileName = sourceInfoFile; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setUserPreferences(edu.umd.cs.findbugs.config.UserPreferences) */ public void setUserPreferences(UserPreferences userPreferences) { this.userPreferences = userPreferences; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#emitTrainingOutput() */ public boolean emitTrainingOutput() { return trainingOutputDir != null; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getUserPreferences() */ public UserPreferences getUserPreferences() { return userPreferences; } /** * Create the classpath object. */ private void createClassPath() { classPath = classFactory.createClassPath(); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getTrainingInputDir() */ public String getTrainingInputDir() { return trainingInputDir; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#getTrainingOutputDir() */ public String getTrainingOutputDir() { return trainingOutputDir; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#useTrainingInput() */ public boolean useTrainingInput() { return trainingInputDir != null; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setScanNestedArchives(boolean) */ public void setScanNestedArchives(boolean scanNestedArchives) { this.scanNestedArchives = scanNestedArchives; } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setNoClassOk(boolean) */ public void setNoClassOk(boolean noClassOk) { this.noClassOk = noClassOk; } public void loadUserAnnotationPlugin(String userAnnotationPluginClassName, Map<String,String> configurationProperties) throws IOException { if (DEBUG_UA) { System.out.println("Attempting to load user annotation plugin " + userAnnotationPluginClassName + "..."); } try { // FIXME: need to think of how to specify what codebase // the user annotation plugin should be loaded from. Class<?> cls = Class.forName(userAnnotationPluginClassName); if (!edu.umd.cs.findbugs.userAnnotations.Plugin.class.isAssignableFrom(cls)) { throw new IOException("Class " + userAnnotationPluginClassName + " is not a user annotation plugin"); } Object instance = cls.newInstance(); this.userAnnotationPlugin = edu.umd.cs.findbugs.userAnnotations.Plugin.class.cast(instance); this.userAnnotationPlugin.setProperties(configurationProperties); if (DEBUG_UA) { System.out.println(" Successfully loaded and configured " + userAnnotationPluginClassName); } } catch (ClassNotFoundException e) { Util.throwIOException("Could not load user annotation plugin", e); } catch (InstantiationException e) { Util.throwIOException("Could not create instance of user annotation plugin object", e); } catch (IllegalAccessException e) { Util.throwIOException("Could not create instance of user annotation plugin object", e); } } public void setUserAnnotationSync(boolean userAnnotationSync) { if (DEBUG_UA) { System.out.println("Will synchronize user annotations"); } this.userAnnotationSync = userAnnotationSync; } /** * Create the analysis cache object. * * @throws IOException if error occurs registering analysis engines in a plugin */ private void createAnalysisCache() throws IOException { analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter); // Register the "built-in" analysis engines registerBuiltInAnalysisEngines(analysisCache); // Register analysis engines in plugins registerPluginAnalysisEngines(detectorFactoryCollection, analysisCache); // Install the DetectorFactoryCollection as a database analysisCache.eagerlyPutDatabase(DetectorFactoryCollection.class, detectorFactoryCollection); Global.setAnalysisCacheForCurrentThread(analysisCache); } /** * Register the "built-in" analysis engines with given IAnalysisCache. * * @param analysisCache an IAnalysisCache */ public static void registerBuiltInAnalysisEngines(IAnalysisCache analysisCache) { new edu.umd.cs.findbugs.classfile.engine.EngineRegistrar().registerAnalysisEngines(analysisCache); new edu.umd.cs.findbugs.classfile.engine.asm.EngineRegistrar().registerAnalysisEngines(analysisCache); new edu.umd.cs.findbugs.classfile.engine.bcel.EngineRegistrar().registerAnalysisEngines(analysisCache); } /** * Register all of the analysis engines defined in the plugins * contained in a DetectorFactoryCollection with an IAnalysisCache. * * @param detectorFactoryCollection a DetectorFactoryCollection * @param analysisCache an IAnalysisCache * @throws IOException */ public static void registerPluginAnalysisEngines( DetectorFactoryCollection detectorFactoryCollection, IAnalysisCache analysisCache) throws IOException { for (Iterator<Plugin> i = detectorFactoryCollection.pluginIterator(); i.hasNext(); ) { Plugin plugin = i.next(); Class<? extends IAnalysisEngineRegistrar> engineRegistrarClass = plugin.getEngineRegistrarClass(); if (engineRegistrarClass != null) { try { IAnalysisEngineRegistrar engineRegistrar = engineRegistrarClass.newInstance(); engineRegistrar.registerAnalysisEngines(analysisCache); } catch (InstantiationException e) { IOException ioe = new IOException( "Could not create analysis engine registrar for plugin " + plugin.getPluginId()); ioe.initCause(e); throw ioe; } catch (IllegalAccessException e) { IOException ioe = new IOException( "Could not create analysis engine registrar for plugin " + plugin.getPluginId()); ioe.initCause(e); throw ioe; } } } } /** * Build the classpath from project codebases and system codebases. * * @throws InterruptedException if the analysis thread is interrupted * @throws IOException if an I/O error occurs * @throws CheckedAnalysisException */ private void buildClassPath() throws InterruptedException, IOException, CheckedAnalysisException { IClassPathBuilder builder = classFactory.createClassPathBuilder(bugReporter); for (String path : project.getFileArray()) { builder.addCodeBase(classFactory.createFilesystemCodeBaseLocator(path), true); } for (String path : project.getAuxClasspathEntryList()) { builder.addCodeBase(classFactory.createFilesystemCodeBaseLocator(path), false); } builder.scanNestedArchives(scanNestedArchives); builder.build(classPath, progress); appClassList = builder.getAppClassList(); if (DEBUG) { System.out.println(appClassList.size() + " classes scanned"); } // If any of the application codebases contain source code, // add them to the source path. // Also, use the last modified time of application codebases // to set the project timestamp. for (Iterator<? extends ICodeBase> i = classPath.appCodeBaseIterator(); i.hasNext(); ){ ICodeBase appCodeBase = i.next(); if (appCodeBase.containsSourceFiles()) { String pathName = appCodeBase.getPathName(); if (pathName != null) { project.addSourceDir(pathName); } } project.addTimestamp(appCodeBase.getLastModifiedTime()); } } private void buildReferencedClassSet() throws CheckedAnalysisException, InterruptedException { // XXX: should drive progress dialog (scanning phase)? if (DEBUG) { System.out.println("Adding referenced classes"); } Set<String> referencedPackageSet = new HashSet<String>(); LinkedList<ClassDescriptor> workList = new LinkedList<ClassDescriptor>(); workList.addAll(appClassList); Set<ClassDescriptor> seen = new HashSet<ClassDescriptor>(); Set<ClassDescriptor> appClassSet = new HashSet<ClassDescriptor>(appClassList); Set<ClassDescriptor> badAppClassSet = new HashSet<ClassDescriptor>(); HashSet<ClassDescriptor> knownDescriptors = new HashSet<ClassDescriptor>(DescriptorFactory.instance().getAllClassDescriptors()); int count = 0; while (!workList.isEmpty()) { if (Thread.interrupted()) { throw new InterruptedException(); } ClassDescriptor classDesc = workList.removeFirst(); if (seen.contains(classDesc)) { continue; } seen.add(classDesc); if (!knownDescriptors.contains(classDesc)) { count++; if (DEBUG && count % 5000 == 0) { System.out.println("Adding referenced class " + classDesc); } } referencedPackageSet.add(classDesc.getPackageName()); // Get list of referenced classes and add them to set. // Add superclasses and superinterfaces to worklist. try { XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDesc); if (classNameAndInfo.getSuperclassDescriptor() != null) { workList.addLast(classNameAndInfo.getSuperclassDescriptor()); } for (ClassDescriptor ifaceDesc : classNameAndInfo.getInterfaceDescriptorList()) { workList.addLast(ifaceDesc); } } catch (RuntimeException e) { bugReporter.logError("Error scanning " + classDesc + " for referenced classes", e); if (appClassSet.contains(classDesc)) { badAppClassSet.add(classDesc); } } catch (MissingClassException e) { // Just log it as a missing class bugReporter.reportMissingClass(e.getClassDescriptor()); if (appClassSet.contains(classDesc)) { badAppClassSet.add(classDesc); } } catch (CheckedAnalysisException e) { // Failed to scan a referenced class --- just log the error and continue bugReporter.logError("Error scanning " + classDesc + " for referenced classes", e); if (appClassSet.contains(classDesc)) { badAppClassSet.add(classDesc); } } } // Delete any application classes that could not be read appClassList.removeAll(badAppClassSet); DescriptorFactory.instance().purge(badAppClassSet); for(ClassDescriptor d : DescriptorFactory.instance().getAllClassDescriptors()) { referencedPackageSet.add(d.getPackageName()); } // Based on referenced packages, add any resolvable package-info classes // to the set of referenced classes. if (DEBUG) { referencedPackageSet.remove(""); System.out.println("Added " + count + " referenced classes"); System.out.println("Total of " + referencedPackageSet.size() + " packages"); } // TODO the block below seems to be an old workaround which does not add any value // except even more "package-info not found" exceptions if(Boolean.getBoolean("fb.addPackageInfo")) for (String pkg : referencedPackageSet) { ClassDescriptor pkgInfoDesc = DescriptorFactory.instance().getClassDescriptorForDottedClassName(pkg + ".package-info"); if (DEBUG) { System.out.println("Checking package " + pkg + " for package-info..."); } try { analysisCache.getClassAnalysis(ClassData.class, pkgInfoDesc); // check that data is there analysisCache.getClassAnalysis(XClass.class, pkgInfoDesc); if (DEBUG) { System.out.println(" Adding " + pkgInfoDesc + " to referenced classes"); } } catch (CheckedAnalysisException e) { // Ignore } } referencedClassSet = new ArrayList<ClassDescriptor>(DescriptorFactory.instance().getAllClassDescriptors()); } public List<ClassDescriptor> sortByCallGraph(Collection<ClassDescriptor> classList, OutEdges<ClassDescriptor> outEdges) { List<ClassDescriptor> evaluationOrder = edu.umd.cs.findbugs.util.TopologicalSort.sortByCallGraph(classList, outEdges); edu.umd.cs.findbugs.util.TopologicalSort.countBadEdges(evaluationOrder, outEdges); return evaluationOrder; } public static void clearAnalysisContext() { AnalysisContext.removeCurrentAnalysisContext(); } /** * Create the AnalysisContext that will serve as the BCEL-compatibility * layer over the AnalysisCache. * @param project The project * @param appClassList list of ClassDescriptors identifying application classes * @param sourceInfoFileName name of source info file (null if none) */ public static void createAnalysisContext( Project project, List<ClassDescriptor> appClassList, String sourceInfoFileName) throws CheckedAnalysisException, IOException { AnalysisCacheToAnalysisContextAdapter analysisContext = new AnalysisCacheToAnalysisContextAdapter(); // Make this the current analysis context AnalysisContext.setCurrentAnalysisContext(analysisContext); // Make the AnalysisCache the backing store for // the BCEL Repository analysisContext.clearRepository(); // Specify which classes are application classes analysisContext.setAppClassList(appClassList); // If needed, load SourceInfoMap if (sourceInfoFileName != null) { SourceInfoMap sourceInfoMap = analysisContext.getSourceInfoMap(); sourceInfoMap.read(new FileInputStream(sourceInfoFileName)); } analysisContext.setSourcePath(project.getSourceDirList()); } /** * Configure analysis feature settings. */ private void configureAnalysisFeatures() { for (AnalysisFeatureSetting setting : analysisFeatureSettingList) { setting.configure(AnalysisContext.currentAnalysisContext()); } } /** * Create an execution plan. * * @throws OrderingConstraintException if the detector ordering constraints are inconsistent */ private void createExecutionPlan() throws OrderingConstraintException { executionPlan = new ExecutionPlan(); // Use user preferences to decide which detectors are enabled. DetectorFactoryChooser detectorFactoryChooser = new DetectorFactoryChooser() { HashSet<DetectorFactory> forcedEnabled = new HashSet<DetectorFactory>(); /* (non-Javadoc) * @see edu.umd.cs.findbugs.DetectorFactoryChooser#choose(edu.umd.cs.findbugs.DetectorFactory) */ public boolean choose(DetectorFactory factory) { return FindBugs.isDetectorEnabled(FindBugs2.this, factory) || forcedEnabled.contains(factory); } public void enable(DetectorFactory factory) { forcedEnabled.add(factory); factory.setEnabledButNonReporting(true); } }; executionPlan.setDetectorFactoryChooser(detectorFactoryChooser); // Add plugins for (Iterator<Plugin> i = detectorFactoryCollection.pluginIterator(); i.hasNext(); ) { Plugin plugin = i.next(); if (DEBUG) { System.out.println("Adding plugin " + plugin.getPluginId() + " to execution plan"); } executionPlan.addPlugin(plugin); } // Build the execution plan executionPlan.build(); // Stash the ExecutionPlan in the AnalysisCache. Global.getAnalysisCache().eagerlyPutDatabase(ExecutionPlan.class, executionPlan); if (DEBUG) { System.out.println(executionPlan.getNumPasses() + " passes in execution plan"); } } static private final boolean USE_REFERENCES = SystemProperties.getBoolean("tsort.references"); /** * Analyze the classes in the application codebase. */ private void analyzeApplication() throws InterruptedException { int passCount = 0; Profiler profiler = Profiler.getInstance(); profiler.start(this.getClass()); AnalysisContext.currentXFactory().canonicalizeAll(); try { boolean multiplePasses = executionPlan.getNumPasses() > 1; if (executionPlan.getNumPasses() == 0) { throw new AssertionError("no analysis passes"); } int[] classesPerPass = new int[executionPlan.getNumPasses()]; classesPerPass[0] = referencedClassSet.size(); for (int i = 0; i < classesPerPass.length; i++) { classesPerPass[i] = i == 0 ? referencedClassSet.size() : appClassList.size(); } progress.predictPassCount(classesPerPass); XFactory factory = AnalysisContext.currentXFactory(); for (ClassDescriptor desc : referencedClassSet) { try { XClass info = Global.getAnalysisCache().getClassAnalysis(XClass.class, desc); factory.intern(info); } catch (CheckedAnalysisException e) { AnalysisContext.logError("Couldn't get class info for " + desc, e); } } for (Iterator<AnalysisPass> i = executionPlan.passIterator(); i.hasNext();) { AnalysisPass pass = i.next(); // The first pass is generally a non-reporting pass which // gathers information about referenced classes. boolean isNonReportingFirstPass = multiplePasses && passCount == 0; // Instantiate the detectors Detector2[] detectorList = pass.instantiateDetector2sInPass(bugReporter); // If there are multiple passes, then on the first pass, // we apply detectors to all classes referenced by the application classes. // On subsequent passes, we apply detector only to application classes. Collection<ClassDescriptor> classCollection = (isNonReportingFirstPass) ? referencedClassSet : appClassList; AnalysisContext.currentXFactory().canonicalizeAll(); if (DEBUG || LIST_ORDER) { System.out.println("Pass " + (passCount) + ": " + classCollection.size() + " classes"); XFactory.profile(); } if (!isNonReportingFirstPass) { OutEdges<ClassDescriptor> outEdges = new OutEdges<ClassDescriptor>() { public Collection<ClassDescriptor> getOutEdges(ClassDescriptor e) { try { XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, e); if (classNameAndInfo instanceof ClassNameAndSuperclassInfo) { return ((ClassNameAndSuperclassInfo) classNameAndInfo).getCalledClassDescriptorList(); } assert false; return Collections.<ClassDescriptor>emptyList(); } catch (CheckedAnalysisException e2) { AnalysisContext.logError("error while analyzing " + e.getClassName(), e2); return Collections.<ClassDescriptor>emptyList(); } } }; List<ClassDescriptor> result = sortByCallGraph(classCollection, outEdges); classCollection = result; } if (LIST_ORDER) { System.out.println("Analysis order:"); for (ClassDescriptor c : classCollection) { System.out.println(" " + c); } } progress.startAnalysis(classCollection.size()); int count = 0; Global.getAnalysisCache().purgeAllMethodAnalysis(); for (ClassDescriptor classDescriptor : classCollection) { if (DEBUG) { System.out.println(count + "/" + classCollection.size() + ": Class " + classDescriptor); count++; } // Check to see if class is excluded by the class screener. // In general, we do not want to screen classes from the // first pass, even if they would otherwise be excluded. if ((SCREEN_FIRST_PASS_CLASSES || !isNonReportingFirstPass) && !classScreener.matches(classDescriptor.toResourceName())) { if (DEBUG) { System.out.println("*** Excluded by class screener"); } continue; } boolean isHuge = AnalysisContext.currentAnalysisContext().isTooBig(classDescriptor); if (isHuge && AnalysisContext.currentAnalysisContext().isApplicationClass(classDescriptor)) { bugReporter.reportBug(new BugInstance("SKIPPED_CLASS_TOO_BIG", Priorities.NORMAL_PRIORITY).addClass(classDescriptor)); } currentClassName = ClassName.toDottedClassName(classDescriptor.getClassName()); notifyClassObservers(classDescriptor); for (Detector2 detector : detectorList) { if (Thread.interrupted()) { throw new InterruptedException(); } if (isHuge && !NonReportingDetector.class.isAssignableFrom(detector.getClass())) { continue; } if (DEBUG) { System.out.println("Applying " + detector.getDetectorClassName() + " to " + classDescriptor + ", huge:" + isHuge + ", isNonReportingFirstPass: " + isNonReportingFirstPass); //System.out.println("foo: " + NonReportingDetector.class.isAssignableFrom(detector.getClass()) + ", bar: " + detector.getClass().getName()); } try { profiler.start(detector.getClass()); detector.visitClass(classDescriptor); } catch (ClassFormatException e) { logRecoverableException(classDescriptor, detector, e); } catch (MissingClassException e) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(e.getClassDescriptor()); } catch (CheckedAnalysisException e) { logRecoverableException(classDescriptor, detector, e); // } catch (UncheckedAnalysisException e) { // logRecoverableException(classDescriptor, detector, e); // } catch (ArrayIndexOutOfBoundsException e) { // logRecoverableException(classDescriptor, detector, e); // } catch (ClassCastException e) { // logRecoverableException(classDescriptor, detector, e); } catch (RuntimeException e) { logRecoverableException(classDescriptor, detector, e); } finally { profiler.end(detector.getClass()); } } progress.finishClass(); } // Call finishPass on each detector for (Detector2 detector : detectorList) { detector.finishPass(); } AnalysisContext.currentAnalysisContext().updateDatabases(passCount); progress.finishPerClassAnalysis(); passCount++; } // If the user requested it, // try to load user annotations from the loaded // user annotation plugin. if (userAnnotationPlugin != null && userAnnotationSync) { syncUserAnnotations(); } // Flush any queued bug reports bugReporter.finish(); // if (baselineBugs != null) new Update().removeBaselineBugs(baselineBugs, bugReporter.); // Flush any queued error reports bugReporter.reportQueuedErrors(); } finally { profiler.end(this.getClass()); } } /** * Notify all IClassObservers that we are visiting given class. * * @param classDescriptor the class being visited */ private void notifyClassObservers(ClassDescriptor classDescriptor) { for (IClassObserver observer : classObserverList) { observer.observeClass(classDescriptor); } } /** * Report an exception that occurred while analyzing a class * with a detector. * * @param classDescriptor class being analyzed * @param detector detector doing the analysis * @param e the exception */ private void logRecoverableException( ClassDescriptor classDescriptor, Detector2 detector, Throwable e) { bugReporter.logError("Exception analyzing " + classDescriptor.toDottedClassName() + " using detector " + detector.getDetectorClassName(), e); } public static void main(String[] args) throws Exception { // Sanity-check the loaded BCEL classes if(!CheckBcel.check()) { System.exit(1); } // Create FindBugs2 engine FindBugs2 findBugs = new FindBugs2(); // Parse command line and configure the engine TextUICommandLine commandLine = new TextUICommandLine(); FindBugs.processCommandLine(commandLine, args, findBugs); // Away we go! FindBugs.runMain(findBugs, commandLine); } /* (non-Javadoc) * @see edu.umd.cs.findbugs.IFindBugsEngine#setAbridgedMessages(boolean) */ public void setAbridgedMessages(boolean xmlWithAbridgedMessages) { abridgedMessages = xmlWithAbridgedMessages; } private void syncUserAnnotations() { if (DEBUG_UA) { System.out.println("About to sync user annotations..."); } BugReporter realBugReporter = bugReporter.getRealBugReporter(); if (!(realBugReporter instanceof BugCollectionBugReporter)) { bugReporter.logError("Cannot load user annotations because there is no BugCollection: use -xml output option"); } else { BugCollection bugCollection = ((BugCollectionBugReporter) realBugReporter).getBugCollection(); try { userAnnotationPlugin.loadUserAnnotations(bugCollection); } catch (Exception e) { bugReporter.logError("Could not sync user annotations using plugin", e); } } } }

The table below shows all metrics for FindBugs2.java.

MetricValueDescription
BLOCKS156.00Number of blocks
BLOCK_COMMENT111.00Number of block comment lines
COMMENTS271.00Comment lines
COMMENT_DENSITY 0.51Comment density
COMPARISONS62.00Number of comparison operators
CYCLOMATIC144.00Cyclomatic complexity
DECL_COMMENTS48.00Comments in declarations
DOC_COMMENT88.00Number of javadoc comment lines
ELOC535.00Effective lines of code
EXEC_COMMENTS55.00Comments in executable code
EXITS193.00Procedure exits
FUNCTIONS59.00Number of function declarations
HALSTEAD_DIFFICULTY74.94Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY137.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 1.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 5.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'
JAVA004912.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 1.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 1.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 2.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 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 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 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 3.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 1.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 3.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 1.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 1.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 5.00JAVA0144 Line exceeds maximum M characters
JAVA01452122.00JAVA0145 Tab character used in source file
JAVA0150 2.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 1.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 3.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 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 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 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 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()
JAVA026619.00JAVA0266 Use of System.out
JAVA0267 6.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1100.00Number of lines in the source file
LINE_COMMENT72.00Number of line comments
LOC669.00Lines of code
LOGICAL_LINES367.00Number of statements
LOOPS 6.00Number of loops
NEST_DEPTH 7.00Maximum nesting depth
OPERANDS1693.00Number of operands
OPERATORS3105.00Number of operators
PARAMS41.00Number of formal parameter declarations
PROGRAM_LENGTH4798.00Halstead program length
PROGRAM_VOCAB664.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS96.00Number of return points from functions
SIZE39195.00Size of the file in bytes
UNIQUE_OPERANDS610.00Number of unique operands
UNIQUE_OPERATORS54.00Number of unique operators
WHITESPACE160.00Number of whitespace lines