Macros.java

Index Score
org.gjt.sp.jedit
jEdit

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
DECL_COMMENTSComments in declarations
LINE_COMMENTNumber of line comments
JAVA0034JAVA0034 Missing braces in if statement
PARAMSNumber of formal parameter declarations
INTERFACE_COMPLEXITYInterface complexity
EXITSProcedure exits
LINESNumber of lines in the source file
COMMENTSComment lines
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
LOCLines of code
ELOCEffective lines of code
RETURNSNumber of return points from functions
FUNCTIONSNumber of function declarations
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
SIZESize of the file in bytes
UNIQUE_OPERANDSNumber of unique operands
DOC_COMMENTNumber of javadoc comment lines
PROGRAM_VOCABHalstead program vocabulary
CYCLOMATICCyclomatic complexity
BLOCKSNumber of blocks
LOGICAL_LINESNumber of statements
PROGRAM_LENGTHHalstead program length
OPERATORSNumber of operators
OPERANDSNumber of operands
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0145JAVA0145 Tab character used in source file
JAVA0166JAVA0166 Generic exception caught
JAVA0035JAVA0035 Missing braces in for statement
JAVA0053JAVA0053 Unused label
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0150JAVA0150 java.lang.Error (or subclass) thrown
COMPARISONSNumber of comparison operators
LOOPSNumber of loops
UNIQUE_OPERATORSNumber of unique operators
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
WHITESPACENumber of whitespace lines
JAVA0126JAVA0126 Method declares unchecked exception in throws
EXEC_COMMENTSComments in executable code
JAVA0173JAVA0173 Unused method parameter
/* * Macros.java - Macro manager * :tabSize=8:indentSize=8:noTabs=false: * :folding=explicit:collapseFolds=1: * * Copyright (C) 1999, 2004 Slava Pestov * Portions copyright (C) 2002 mike dillon * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.gjt.sp.jedit; //{{{ Imports import org.gjt.sp.jedit.msg.BufferUpdate; import org.gjt.sp.jedit.msg.DynamicMenuChanged; import org.gjt.sp.util.Log; import org.gjt.sp.util.StandardUtilities; import javax.swing.*; import java.awt.*; import java.io.File; import java.io.Reader; import java.util.*; import java.util.List; import java.util.regex.Pattern; //}}} /** * This class records and runs macros.<p> * * It also contains a few methods useful for displaying output messages * or obtaining input from a macro: * * <ul> * <li>{@link #confirm(Component,String,int)}</li> * <li>{@link #confirm(Component,String,int,int)}</li> * <li>{@link #error(Component,String)}</li> * <li>{@link #input(Component,String)}</li> * <li>{@link #input(Component,String,String)}</li> * <li>{@link #message(Component,String)}</li> * </ul> * * Note that plugins should not use the above methods. Call * the methods in the {@link GUIUtilities} class instead. * * @author Slava Pestov * @version $Id: Macros.java 12946 2008-06-27 08:40:42Z kpouer $ */ public class Macros { //{{{ showRunScriptDialog() method /** * Prompts for one or more files to run as macros * @param view The view * @since jEdit 4.0pre7 */ public static void showRunScriptDialog(View view) { String[] paths = GUIUtilities.showVFSFileDialog(view, null,JFileChooser.OPEN_DIALOG,true); if(paths != null) { Buffer buffer = view.getBuffer(); try { buffer.beginCompoundEdit(); file_loop: for(int i = 0; i < paths.length; i++) runScript(view,paths[i],false); } finally { buffer.endCompoundEdit(); } } } //}}} //{{{ runScript() method /** * Runs the specified script. * Unlike the {@link BeanShell#runScript(View,String,Reader,boolean)} * method, this method can run scripts supported * by any registered macro handler. * @param view The view * @param path The VFS path of the script * @param ignoreUnknown If true, then unknown file types will be * ignored; otherwise, a warning message will be printed and they will * be evaluated as BeanShell scripts. * * @since jEdit 4.1pre2 */ public static void runScript(View view, String path, boolean ignoreUnknown) { Handler handler = getHandlerForPathName(path); if(handler != null) { try { Macro newMacro = handler.createMacro( MiscUtilities.getFileName(path), path); newMacro.invoke(view); } catch (Exception e) { Log.log(Log.ERROR, Macros.class, e); return; } return; } // only executed if above loop falls // through, ie there is no handler for // this file if(ignoreUnknown) { Log.log(Log.NOTICE,Macros.class,path + ": Cannot find a suitable macro handler"); } else { Log.log(Log.ERROR,Macros.class,path + ": Cannot find a suitable macro handler, " + "assuming BeanShell"); getHandler("beanshell").createMacro( path,path).invoke(view); } } //}}} //{{{ message() method /** * Utility method that can be used to display a message dialog in a macro. * @param comp The component to show the dialog on behalf of, this * will usually be a view instance * @param message The message * @since jEdit 2.7pre2 */ public static void message(Component comp, String message) { GUIUtilities.hideSplashScreen(); JOptionPane.showMessageDialog(comp,message, jEdit.getProperty("macro-message.title"), JOptionPane.INFORMATION_MESSAGE); } //}}} //{{{ error() method /** * Utility method that can be used to display an error dialog in a macro. * @param comp The component to show the dialog on behalf of, this * will usually be a view instance * @param message The message * @since jEdit 2.7pre2 */ public static void error(Component comp, String message) { GUIUtilities.hideSplashScreen(); JOptionPane.showMessageDialog(comp,message, jEdit.getProperty("macro-message.title"), JOptionPane.ERROR_MESSAGE); } //}}} //{{{ input() method /** * Utility method that can be used to prompt for input in a macro. * @param comp The component to show the dialog on behalf of, this * will usually be a view instance * @param prompt The prompt string * @since jEdit 2.7pre2 */ public static String input(Component comp, String prompt) { GUIUtilities.hideSplashScreen(); return input(comp,prompt,null); } //}}} //{{{ input() method /** * Utility method that can be used to prompt for input in a macro. * @param comp The component to show the dialog on behalf of, this * will usually be a view instance * @param prompt The prompt string * @since jEdit 3.1final */ public static String input(Component comp, String prompt, String defaultValue) { GUIUtilities.hideSplashScreen(); return (String)JOptionPane.showInputDialog(comp,prompt, jEdit.getProperty("macro-input.title"), JOptionPane.QUESTION_MESSAGE,null,null,defaultValue); } //}}} //{{{ confirm() method /** * Utility method that can be used to ask for confirmation in a macro. * @param comp The component to show the dialog on behalf of, this * will usually be a view instance * @param prompt The prompt string * @param buttons The buttons to display - for example, * JOptionPane.YES_NO_CANCEL_OPTION * @since jEdit 4.0pre2 */ public static int confirm(Component comp, String prompt, int buttons) { GUIUtilities.hideSplashScreen(); return JOptionPane.showConfirmDialog(comp,prompt, jEdit.getProperty("macro-confirm.title"),buttons, JOptionPane.QUESTION_MESSAGE); } //}}} //{{{ confirm() method /** * Utility method that can be used to ask for confirmation in a macro. * @param comp The component to show the dialog on behalf of, this * will usually be a view instance * @param prompt The prompt string * @param buttons The buttons to display - for example, * JOptionPane.YES_NO_CANCEL_OPTION * @param type The dialog type - for example, * JOptionPane.WARNING_MESSAGE */ public static int confirm(Component comp, String prompt, int buttons, int type) { GUIUtilities.hideSplashScreen(); return JOptionPane.showConfirmDialog(comp,prompt, jEdit.getProperty("macro-confirm.title"),buttons,type); } //}}} //{{{ loadMacros() method /** * Rebuilds the macros list, and sends a MacrosChanged message * (views update their Macros menu upon receiving it) * @since jEdit 2.2pre4 */ public static void loadMacros() { macroActionSet.removeAllActions(); macroHierarchy.removeAllElements(); macroHash.clear(); // since subsequent macros with the same name are ignored, // load user macros first so that they override the system // macros. String settings = jEdit.getSettingsDirectory(); if(settings != null) { userMacroPath = MiscUtilities.constructPath( settings,"macros"); loadMacros(macroHierarchy,"",new File(userMacroPath)); } if(jEdit.getJEditHome() != null) { systemMacroPath = MiscUtilities.constructPath( jEdit.getJEditHome(),"macros"); loadMacros(macroHierarchy,"",new File(systemMacroPath)); } EditBus.send(new DynamicMenuChanged("macros")); } //}}} //{{{ registerHandler() method /** * Adds a macro handler to the handlers list * @since jEdit 4.0pre6 */ public static void registerHandler(Handler handler) { if (getHandler(handler.getName()) != null) { Log.log(Log.ERROR, Macros.class, "Cannot register more than one macro handler with the same name"); return; } Log.log(Log.DEBUG,Macros.class,"Registered " + handler.getName() + " macro handler"); macroHandlers.add(handler); } //}}} //{{{ getHandlers() method /** * Returns an array containing the list of registered macro handlers * @since jEdit 4.0pre6 */ public static Handler[] getHandlers() { Handler[] handlers = new Handler[macroHandlers.size()]; return macroHandlers.toArray(handlers); } //}}} //{{{ getHandlerForFileName() method /** * Returns the macro handler suitable for running the specified file * name, or null if there is no suitable handler. * @since jEdit 4.1pre3 */ public static Handler getHandlerForPathName(String pathName) { for (int i = 0; i < macroHandlers.size(); i++) { Handler handler = macroHandlers.get(i); if (handler.accept(pathName)) return handler; } return null; } //}}} //{{{ getHandler() method /** * Returns the macro handler with the specified name, or null if * there is no registered handler with that name. * @since jEdit 4.0pre6 */ public static Handler getHandler(String name) { for (int i = 0; i < macroHandlers.size(); i++) { Handler handler = macroHandlers.get(i); if (handler.getName().equals(name)) return handler; } return null; } //}}} //{{{ getMacroHierarchy() method /** * Returns a vector hierarchy with all known macros in it. * Each element of this vector is either a macro name string, * or another vector. If it is a vector, the first element is a * string label, the rest are again, either macro name strings * or vectors. * @since jEdit 2.6pre1 */ public static Vector getMacroHierarchy() { return macroHierarchy; } //}}} //{{{ getMacroActionSet() method /** * Returns an action set with all known macros in it. * @since jEdit 4.0pre1 */ public static ActionSet getMacroActionSet() { return macroActionSet; } //}}} //{{{ getMacro() method /** * Returns the macro with the specified name. * @param macro The macro's name * @since jEdit 2.6pre1 */ public static Macro getMacro(String macro) { return macroHash.get(macro); } //}}} //{{{ getLastMacro() method /** * @since jEdit 4.3pre1 */ public static Macro getLastMacro() { return lastMacro; } //}}} //{{{ setLastMacro() method /** * @since jEdit 4.3pre1 */ public static void setLastMacro(Macro macro) { lastMacro = macro; } //}}} //{{{ Macro class /** * Encapsulates the macro's label, name and path. * @since jEdit 2.2pre4 */ public static class Macro extends EditAction { //{{{ Macro constructor public Macro(Handler handler, String name, String label, String path) { super(name); this.handler = handler; this.label = label; this.path = path; } //}}} //{{{ getHandler() method public Handler getHandler() { return handler; } //}}} //{{{ getPath() method public String getPath() { return path; } //}}} //{{{ invoke() method @Override public void invoke(View view) { setLastMacro(this); if(view == null) handler.runMacro(null,this); else { try { view.getBuffer().beginCompoundEdit(); handler.runMacro(view,this); } finally { view.getBuffer().endCompoundEdit(); } } } //}}} //{{{ getCode() method @Override public String getCode() { return "Macros.getMacro(\"" + getName() + "\").invoke(view);"; } //}}} //{{{ macroNameToLabel() method public static String macroNameToLabel(String macroName) { int index = macroName.lastIndexOf('/'); return macroName.substring(index + 1).replace('_', ' '); } //}}} //{{{ Private members private Handler handler; private String path; String label; //}}} } //}}} //{{{ recordTemporaryMacro() method /** * Starts recording a temporary macro. * @param view The view * @since jEdit 2.7pre2 */ public static void recordTemporaryMacro(View view) { String settings = jEdit.getSettingsDirectory(); if(settings == null) { GUIUtilities.error(view,"no-settings",new String[0]); return; } if(view.getMacroRecorder() != null) { GUIUtilities.error(view,"already-recording",new String[0]); return; } Buffer buffer = jEdit.openFile(null,settings + File.separator + "macros","Temporary_Macro.bsh",true,null); if(buffer == null) return; buffer.remove(0,buffer.getLength()); buffer.insert(0,jEdit.getProperty("macro.temp.header")); recordMacro(view,buffer,true); } //}}} //{{{ recordMacro() method /** * Starts recording a macro. * @param view The view * @since jEdit 2.7pre2 */ public static void recordMacro(View view) { String settings = jEdit.getSettingsDirectory(); if(settings == null) { GUIUtilities.error(view,"no-settings",new String[0]); return; } if(view.getMacroRecorder() != null) { GUIUtilities.error(view,"already-recording",new String[0]); return; } String name = GUIUtilities.input(view,"record",null); if(name == null) return; name = name.replace(' ','_'); Buffer buffer = jEdit.openFile(null,null, MiscUtilities.constructPath(settings,"macros", name + ".bsh"),true,null); if(buffer == null) return; buffer.remove(0,buffer.getLength()); buffer.insert(0,jEdit.getProperty("macro.header")); recordMacro(view,buffer,false); } //}}} //{{{ stopRecording() method /** * Stops a recording currently in progress. * @param view The view * @since jEdit 2.7pre2 */ public static void stopRecording(View view) { Recorder recorder = view.getMacroRecorder(); if(recorder == null) GUIUtilities.error(view,"macro-not-recording",null); else { view.setMacroRecorder(null); if(!recorder.temporary) view.setBuffer(recorder.buffer); recorder.dispose(); } } //}}} //{{{ runTemporaryMacro() method /** * Runs the temporary macro. * @param view The view * @since jEdit 2.7pre2 */ public static void runTemporaryMacro(View view) { String settings = jEdit.getSettingsDirectory(); if(settings == null) { GUIUtilities.error(view,"no-settings",null); return; } String path = MiscUtilities.constructPath( jEdit.getSettingsDirectory(),"macros", "Temporary_Macro.bsh"); if(jEdit.getBuffer(path) == null) { GUIUtilities.error(view,"no-temp-macro",null); return; } Handler handler = getHandler("beanshell"); Macro temp = handler.createMacro(path,path); Buffer buffer = view.getBuffer(); try { buffer.beginCompoundEdit(); temp.invoke(view); } finally { /* I already wrote a comment expaining this in * Macro.invoke(). */ if(buffer.insideCompoundEdit()) buffer.endCompoundEdit(); } } //}}} //{{{ Private members //{{{ Static variables private static String systemMacroPath; private static String userMacroPath; private static List<Handler> macroHandlers; private static ActionSet macroActionSet; private static Vector macroHierarchy; private static Map<String, Macro> macroHash; private static Macro lastMacro; //}}} //{{{ Class initializer static { macroHandlers = new ArrayList<Handler>(); registerHandler(new BeanShellHandler()); macroActionSet = new ActionSet(jEdit.getProperty("action-set.macros")); jEdit.addActionSet(macroActionSet); macroHierarchy = new Vector(); macroHash = new Hashtable<String, Macro>(); } //}}} //{{{ loadMacros() method private static void loadMacros(List vector, String path, File directory) { lastMacro = null; File[] macroFiles = directory.listFiles(); if(macroFiles == null || macroFiles.length == 0) return; for(int i = 0; i < macroFiles.length; i++) { File file = macroFiles[i]; String fileName = file.getName(); if(file.isHidden()) { /* do nothing! */ } else if(file.isDirectory()) { String submenuName = fileName.replace('_',' '); List submenu = null; //{{{ try to merge with an existing menu first for(int j = 0; j < vector.size(); j++) { Object obj = vector.get(j); if(obj instanceof List) { List vec = (List)obj; if(submenuName.equals(vec.get(0))) { submenu = vec; break; } } } //}}} if(submenu == null) { submenu = new Vector(); submenu.add(submenuName); vector.add(submenu); } loadMacros(submenu,path + fileName + '/',file); } else { addMacro(file,path,vector); } } } //}}} //{{{ addMacro() method private static void addMacro(File file, String path, List vector) { String fileName = file.getName(); Handler handler = getHandlerForPathName(file.getPath()); if(handler == null) return; try { // in case macro file name has a space in it. // spaces break the view.toolBar property, for instance, // since it uses spaces to delimit action names. String macroName = (path + fileName).replace(' ','_'); Macro newMacro = handler.createMacro(macroName, file.getPath()); // ignore if already added. // see comment in loadMacros(). if(macroHash.get(newMacro.getName()) != null) return; vector.add(newMacro.getName()); jEdit.setTemporaryProperty(newMacro.getName() + ".label", newMacro.label); jEdit.setTemporaryProperty(newMacro.getName() + ".mouse-over", handler.getLabel() + " - " + file.getPath()); macroActionSet.addAction(newMacro); macroHash.put(newMacro.getName(),newMacro); } catch (Exception e) { Log.log(Log.ERROR, Macros.class, e); macroHandlers.remove(handler); } } //}}} //{{{ recordMacro() method /** * Starts recording a macro. * @param view The view * @param buffer The buffer to record to * @param temporary True if this is a temporary macro * @since jEdit 3.0pre5 */ private static void recordMacro(View view, Buffer buffer, boolean temporary) { view.setMacroRecorder(new Recorder(view,buffer,temporary)); // setting the message to 'null' causes the status bar to check // if a recording is in progress view.getStatus().setMessage(null); } //}}} //}}} //{{{ Recorder class /** * Handles macro recording. */ public static class Recorder implements EBComponent { View view; Buffer buffer; boolean temporary; boolean lastWasInput; boolean lastWasOverwrite; int overwriteCount; //{{{ Recorder constructor public Recorder(View view, Buffer buffer, boolean temporary) { this.view = view; this.buffer = buffer; this.temporary = temporary; EditBus.addToBus(this); } //}}} //{{{ record() method public void record(String code) { if (BeanShell.isScriptRunning()) return; flushInput(); append("\n"); append(code); } //}}} //{{{ record() method public void record(int repeat, String code) { if(repeat == 1) record(code); else { record("for(int i = 1; i <= " + repeat + "; i++)\n" + "{\n" + code + '\n' + '}'); } } //}}} //{{{ recordInput() method /** * @since jEdit 4.2pre5 */ public void recordInput(int repeat, char ch, boolean overwrite) { // record \n and \t on lines specially so that auto indent // can take place if(ch == '\n') record(repeat,"textArea.userInput(\'\\n\');"); else if(ch == '\t') record(repeat,"textArea.userInput(\'\\t\');"); else { StringBuilder buf = new StringBuilder(repeat); for(int i = 0; i < repeat; i++) buf.append(ch); recordInput(buf.toString(),overwrite); } } //}}} //{{{ recordInput() method /** * @since jEdit 4.2pre5 */ public void recordInput(String str, boolean overwrite) { String charStr = StandardUtilities.charsToEscapes(str); if(overwrite) { if(lastWasOverwrite) { overwriteCount++; append(charStr); } else { flushInput(); overwriteCount = 1; lastWasOverwrite = true; append("\ntextArea.setSelectedText(\"" + charStr); } } else { if(lastWasInput) append(charStr); else { flushInput(); lastWasInput = true; append("\ntextArea.setSelectedText(\"" + charStr); } } } //}}} //{{{ handleMessage() method public void handleMessage(EBMessage msg) { if(msg instanceof BufferUpdate) { BufferUpdate bmsg = (BufferUpdate)msg; if(bmsg.getWhat() == BufferUpdate.CLOSED) { if(bmsg.getBuffer() == buffer) stopRecording(view); } } } //}}} //{{{ append() method private void append(String str) { buffer.insert(buffer.getLength(),str); } //}}} //{{{ dispose() method private void dispose() { flushInput(); for(int i = 0; i < buffer.getLineCount(); i++) { buffer.indentLine(i,true); } EditBus.removeFromBus(this); // setting the message to 'null' causes the status bar to // check if a recording is in progress view.getStatus().setMessage(null); } //}}} //{{{ flushInput() method /** * We try to merge consecutive inputs. This helper method is * called when something other than input is to be recorded. */ private void flushInput() { if(lastWasInput) { lastWasInput = false; append("\");"); } if(lastWasOverwrite) { lastWasOverwrite = false; append("\");\n"); append("offset = buffer.getLineEndOffset(" + "textArea.getCaretLine()) - 1;\n"); append("buffer.remove(textArea.getCaretPosition()," + "Math.min(" + overwriteCount + ",offset - " + "textArea.getCaretPosition()));"); } } //}}} } //}}} //{{{ Handler class /** * Encapsulates creating and invoking macros in arbitrary scripting languages * @since jEdit 4.0pre6 */ public abstract static class Handler { //{{{ getName() method public String getName() { return name; } //}}} //{{{ getLabel() method public String getLabel() { return label; } //}}} //{{{ accept() method public boolean accept(String path) { return filter.matcher(MiscUtilities.getFileName(path)).matches(); } //}}} //{{{ createMacro() method public abstract Macro createMacro(String macroName, String path); //}}} //{{{ runMacro() method /** * Runs the specified macro. * @param view The view - may be null. * @param macro The macro. */ public abstract void runMacro(View view, Macro macro); //}}} //{{{ runMacro() method /** * Runs the specified macro. This method is optional; it is * called if the specified macro is a startup script. The * default behavior is to simply call {@link #runMacro(View,Macros.Macro)}. * * @param view The view - may be null. * @param macro The macro. * @param ownNamespace A hint indicating whenever functions and * variables defined in the script are to be self-contained, or * made available to other scripts. The macro handler may ignore * this parameter. * @since jEdit 4.1pre3 */ public void runMacro(View view, Macro macro, boolean ownNamespace) { runMacro(view,macro); } //}}} //{{{ Handler constructor protected Handler(String name) { this.name = name; label = jEdit.getProperty("macro-handler." + name + ".label", name); try { filter = Pattern.compile(StandardUtilities.globToRE( jEdit.getProperty( "macro-handler." + name + ".glob"))); } catch (Exception e) { throw new InternalError("Missing or invalid glob for handler " + name); } } //}}} //{{{ Private members private String name; private String label; private Pattern filter; //}}} } //}}} //{{{ BeanShellHandler class private static class BeanShellHandler extends Handler { //{{{ BeanShellHandler constructor BeanShellHandler() { super("beanshell"); } //}}} //{{{ createMacro() method @Override public Macro createMacro(String macroName, String path) { // Remove '.bsh' macroName = macroName.substring(0, macroName.length() - 4); return new Macro(this, macroName, Macro.macroNameToLabel(macroName), path); } //}}} //{{{ runMacro() method @Override public void runMacro(View view, Macro macro) { BeanShell.runScript(view,macro.getPath(),null,true); } //}}} //{{{ runMacro() method @Override public void runMacro(View view, Macro macro, boolean ownNamespace) { BeanShell.runScript(view,macro.getPath(),null,ownNamespace); } //}}} } //}}} }

The table below shows all metrics for Macros.java.

MetricValueDescription
BLOCKS99.00Number of blocks
BLOCK_COMMENT25.00Number of block comment lines
COMMENTS313.00Comment lines
COMMENT_DENSITY 0.70Comment density
COMPARISONS47.00Number of comparison operators
CYCLOMATIC101.00Cyclomatic complexity
DECL_COMMENTS104.00Comments in declarations
DOC_COMMENT198.00Number of javadoc comment lines
ELOC448.00Effective lines of code
EXEC_COMMENTS11.00Comments in executable code
EXITS97.00Procedure exits
FUNCTIONS51.00Number of function declarations
HALSTEAD_DIFFICULTY77.58Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY146.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 1.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003418.00JAVA0034 Missing braces in if statement
JAVA0035 2.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 1.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 1.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 1.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
JAVA010810.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011011.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 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA011712.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA01451882.00JAVA0145 Tab character used in source file
JAVA0150 1.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 3.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 1.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 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 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 2.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
LINES1033.00Number of lines in the source file
LINE_COMMENT90.00Number of line comments
LOC604.00Lines of code
LOGICAL_LINES242.00Number of statements
LOOPS 7.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS1104.00Number of operands
OPERATORS2052.00Number of operators
PARAMS73.00Number of formal parameter declarations
PROGRAM_LENGTH3156.00Halstead program length
PROGRAM_VOCAB422.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS73.00Number of return points from functions
SIZE24662.00Size of the file in bytes
UNIQUE_OPERANDS370.00Number of unique operands
UNIQUE_OPERATORS52.00Number of unique operators
WHITESPACE116.00Number of whitespace lines