MainFrameTest.java

Index Score
edu.rice.cs.drjava.ui
DrJava

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
LINE_COMMENTNumber of line comments
FUNCTIONSNumber of function declarations
RETURNSNumber of return points from functions
SIZESize of the file in bytes
LOGICAL_LINESNumber of statements
UNIQUE_OPERANDSNumber of unique operands
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
OPERANDSNumber of operands
INTERFACE_COMPLEXITYInterface complexity
JAVA0020JAVA0020 Field name does not have required form
PROGRAM_VOCABHalstead program vocabulary
ELOCEffective lines of code
EXITSProcedure exits
LOCLines of code
LINESNumber of lines in the source file
JAVA0160JAVA0160 Method does not throw specified exception
BLOCKSNumber of blocks
JAVA0025JAVA0025 Method override is empty
CYCLOMATICCyclomatic complexity
JAVA0009JAVA0009 Protected member in final class
JAVA0036JAVA0036 Missing braces in while statement
WHITESPACENumber of whitespace lines
DECL_COMMENTSComments in declarations
JAVA0171JAVA0171 Unused local variable
PARAMSNumber of formal parameter declarations
JAVA0034JAVA0034 Missing braces in if statement
JAVA0170JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0166JAVA0166 Generic exception caught
PROGRAM_VOLUMEHalstead program volume
COMMENTSComment lines
JAVA0266JAVA0266 Use of System.out
UNIQUE_OPERATORSNumber of unique operators
COMPARISONSNumber of comparison operators
JAVA0030JAVA0030 Private field not used
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0068JAVA0068 Modifiers not declared in recommended order
JAVA0145JAVA0145 Tab character used in source file
/*BEGIN_COPYRIGHT_BLOCK * * Copyright (c) 2001-2008, JavaPLT group at Rice University (drjava@rice.edu) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software is Open Source Initiative approved Open Source Software. * Open Source Initative Approved is a trademark of the Open Source Initiative. * * This file is part of DrJava. Download the current version of this project * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/ * * END_COPYRIGHT_BLOCK*/ package edu.rice.cs.drjava.ui; import java.awt.Component; import java.awt.EventQueue; import java.awt.event.*; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.Toolkit; import javax.swing.*; import javax.swing.text.*; import java.io.*; import java.util.List; import edu.rice.cs.drjava.model.*; import edu.rice.cs.drjava.model.repl.*; import edu.rice.cs.drjava.model.repl.InteractionsDocumentTest.TestBeep; import edu.rice.cs.drjava.DrJava; import edu.rice.cs.drjava.config.OptionConstants; import edu.rice.cs.plt.io.IOUtil; import edu.rice.cs.util.FileOpenSelector; import edu.rice.cs.util.*; import edu.rice.cs.util.text.*; import edu.rice.cs.util.swing.Utilities; /** Test functions of MainFrame. * @version $Id: MainFrameTest.java 4618 2008-07-28 21:53:19Z rcartwright $ */ public final class MainFrameTest extends MultiThreadedTestCase { private volatile MainFrame _frame; /** A temporary directory */ private volatile File _tempDir; /* Flag and lock for signalling when file has been opened and active document changed. */ protected volatile boolean _openDone; protected final Object _openLock = new Object(); /* Flag and lock for signalling when file has been closed. */ protected volatile boolean _closeDone; protected final Object _closeLock = new Object(); /* Flag and lock for signalling when compilation is done. */ protected volatile boolean _compileDone; protected final Object _compileLock = new Object(); private final static Log _log = new Log("MainFrameTest.txt", false); /** Setup method for each JUnit test case. */ public void setUp() throws Exception { super.setUp(); _log.log("super.setUp() for next test completed"); _frame = new MainFrame(); _log.log("new MainFrame() for next test completed"); EventQueue.invokeLater(new Runnable() { public void run() { _frame.pack(); } }); _log.log("setUp complete for next test"); } public void tearDown() throws Exception { // Utilities.invokeLater(new Runnable() { // public void run() { _frame.dispose(); // disposes GUI elements of _frame _frame.getModel().dispose(); // explicitly kills the slave JVM _frame = null; /* try { */ MainFrameTest.super.tearDown(); /* } */ // catch(Exception e) { throw new UnexpectedException(e); } // } // }); } JButton _but; /** Tests that the returned JButton of <code>createManualToolbarButton</code>: * 1. Is disabled upon return. * 2. Inherits the tooltip of the Action parameter <code>a</code>. */ public void testCreateManualToolbarButton() { final Action a = new AbstractAction("Test Action") { public void actionPerformed(ActionEvent ae) { } }; a.putValue(Action.SHORT_DESCRIPTION, "test tooltip"); Utilities.invokeAndWait(new Runnable() { public void run() { _but = _frame._createManualToolbarButton(a); } }); assertTrue("Returned JButton is enabled.", ! _but.isEnabled()); assertEquals("Tooltip text not set.", "test tooltip", _but.getToolTipText()); _log.log("testCreateManualToobarButton completed"); } /** Tests that the current location of a document is equal to the caret Position after switching to another document and back. */ public void testDocLocationAfterSwitch() throws BadLocationException { final DefinitionsPane pane = _frame.getCurrentDefPane(); final OpenDefinitionsDocument doc = pane.getOpenDefDocument(); setDocText(doc.getDocument(), "abcd"); Utilities.invokeAndWait(new Runnable() { public void run() { doc.setCurrentLocation(3); pane.setCaretPosition(3); // The caret is not affected by setCurrentLocation } }); assertEquals("Location of old doc before switch", 3, doc.getCurrentLocation()); assertEquals("Location of cursor in old document", 3, pane.getCaretPosition()); // Create a new file SingleDisplayModel model = _frame.getModel(); final OpenDefinitionsDocument oldDoc = doc; final DefinitionsPane oldPane = pane; final OpenDefinitionsDocument newDoc = model.newFile(); // Current pane should be new doc, pos 0 DefinitionsPane curPane; OpenDefinitionsDocument curDoc; curPane = _frame.getCurrentDefPane(); curDoc = curPane.getOpenDefDocument();//.getDocument(); assertEquals("New curr DefPane's document", newDoc, curDoc); assertEquals("Location in new document", 0, newDoc.getCurrentLocation()); // Switch back to old document model.setActiveNextDocument(); Utilities.clearEventQueue(); assertEquals("Next active doc", oldDoc, model.getActiveDocument()); // Current pane should be old doc, pos 3 curPane = _frame.getCurrentDefPane(); curDoc = curPane.getOpenDefDocument();//.getDocument(); assertEquals("Next active pane", oldPane, curPane); assertEquals("Current document is old document", oldDoc, curDoc); assertEquals("Location of caret in old document", 3, curPane.getCaretPosition()); _log.log("testDocLocationAfterSwitch completed"); } private String _data; private String _newData; /** Tests that the clipboard is unmodified after a "clear line" action. */ public void testClearLine() throws BadLocationException, UnsupportedFlavorException, IOException { // First, copy some data out of the main document. final DefinitionsPane pane = _frame.getCurrentDefPane(); final OpenDefinitionsDocument doc = pane.getOpenDefDocument(); final String clipString = "***Clipboard***"; // _frame.setVisible(true); Utilities.invokeAndWait(new Runnable() { public void run() { try { doc.insertString(0, "abcdefg", null); pane.setCaretPosition(5); // ActionMap actionMap = _pane.getActionMap(); // String selString = DefaultEditorKit.selectionEndLineAction; // actionMap.get(selString).actionPerformed(new ActionEvent(this, 0, "SelectionEndLine")); // _frame.cutAction.actionPerformed(new ActionEvent(this, 0, "Cut")); _frame.validate(); // _frame.paint(_frame.getGraphics()); // ActionMap actionMap = _pane.getActionMap(); // String selString = DefaultEditorKit.selectionEndLineAction; // actionMap.get(selString).actionPerformed(new ActionEvent(this, 0, "SelectionEndLine")); // pane.setSelectionStart(2); // pane.setSelectionEnd(7); // Get a copy of the current clipboard. Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); // Insert valid string in clipboars. clip.setContents(new StringSelection(clipString), _frame); Transferable contents = clip.getContents(_frame); // Trigger the Clear Line action from a new position. pane.setCaretPosition(2); _frame.validate(); // _frame.paint(_frame.getGraphics()); _frame._clearLineAction.actionPerformed(new ActionEvent(pane, 0, "Clear Line")); // _frame.paint(_frame.getGraphics()); _frame.validate(); // Verify that the clipboard contents are still the same. contents = clip.getContents(null); _data = (String) contents.getTransferData(DataFlavor.stringFlavor); } catch(Throwable t) { listenerFail(t.getMessage()); } } }); Utilities.clearEventQueue(); assertEquals("Clipboard contents should be unchanged after Clear Line.", clipString, _data); // Verify that the document text is what we expect. assertEquals("Current line of text should be truncated by Clear Line.", "ab", doc.getText()); _log.log("testClearLine completed"); } /** Tests that the clipboard is modified after a "cut line" action. * NOTE: Commented out for commit because of failures, despite proper behavior in GUI. * This may not work unless ActionEvents are dropped in the event queue */ public void testCutLine() throws BadLocationException { // First, copy some data out of the main document. final DefinitionsPane pane = _frame.getCurrentDefPane(); final OpenDefinitionsDocument doc = pane.getOpenDefDocument(); // _frame.setVisible(true); Utilities.invokeAndWait(new Runnable() { public void run() { try { doc.insertString(0, "abcdefg", null); pane.setCaretPosition(5); _frame.validate(); // _frame.paint(_frame.getGraphics()); // ActionMap actionMap = _pane.getActionMap(); // String selString = DefaultEditorKit.selectionEndLineAction; // actionMap.get(selString).actionPerformed(new ActionEvent(pane, 0, "SelectionEndLine")); pane.setSelectionStart(2); pane.setSelectionEnd(7); _frame.validate(); pane.cut(); // _frame.cutAction.actionPerformed(new ActionEvent(pane, 0, "Cut")); // Get a copy of the current clipboard. // Trigger the Cut Line action from a new position. // _pane.setCaretPosition(2); _frame.validate(); // _frame.paint(_frame.getGraphics()); // _frame._cutLineAction.actionPerformed(new ActionEvent(this, 0, "Cut Line")); // _frame.dispatchEvent(new ActionEvent(this, 0, "Cut Line")); // Verify that the clipboard contents are what we expect. Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable contents = clip.getContents(null); _data = (String) contents.getTransferData(DataFlavor.stringFlavor); } catch(Throwable t) { listenerFail(t.getMessage()); } } }); Utilities.clearEventQueue(); assertEquals("Clipboard contents should be changed after Cut Line.", "cdefg", _data); // Verify that the document text is what we expect. assertEquals("Current line of text should be truncated by Cut Line.", "ab", doc.getText()); _log.log("testCutLine completed"); } /** Make sure that the InteractionsPane is displaying the correct InteractionsDocument. (SourceForge bug #681547) * Also make sure this document cannot be edited before the prompt. */ public void testCorrectInteractionsDocument() throws EditDocumentException { InteractionsPane pane = _frame.getInteractionsPane(); final SingleDisplayModel model = _frame.getModel(); InteractionsDJDocument doc = model.getSwingInteractionsDocument(); // Make the test silent Utilities.invokeAndWait(new Runnable() { public void run() { model.getInteractionsModel().getDocument().setBeep(new TestBeep()); } }); Utilities.clearEventQueue(); // Test for strict == equality assertTrue("UI's int. doc. should equals Model's int. doc.", pane.getDocument() == doc); int origLength = doc.getLength(); doc.insertText(1, "typed text", InteractionsDocument.DEFAULT_STYLE); Utilities.clearEventQueue(); assertEquals("Document should not have changed.", origLength, doc.getLength()); _log.log("testCorrectInteractionsDocument completed"); } /** Tests that undoing/redoing a multi-line indent will restore the caret position. */ public void testMultilineIndentAfterScroll() throws BadLocationException, InterruptedException { String text = "public class stuff {\n" + "private int _int;\n" + "private Bar _bar;\n" + "public void foo() {\n" + "_bar.baz(_int);\n" + "}\n" + "}\n"; String indented = "public class stuff {\n" + " private int _int;\n" + " private Bar _bar;\n" + " public void foo() {\n" + " _bar.baz(_int);\n" + " }\n" + "}\n"; final int newPos = 20; final DefinitionsPane pane = _frame.getCurrentDefPane(); final OpenDefinitionsDocument doc = pane.getOpenDefDocument(); setConfigSetting(OptionConstants.INDENT_LEVEL, Integer.valueOf(2)); doc.append(text, null); Utilities.invokeAndWait(new Runnable() { public void run() { pane.setCaretPosition(0); pane.endCompoundEdit(); } }); Utilities.clearEventQueue(); assertEquals("Should have inserted correctly.", text, doc.getText()); doc.indentLines(0, doc.getLength()); assertEquals("Should have indented.", indented, doc.getText()); Utilities.invokeAndWait(new Runnable() { public void run() { doc.getUndoManager().undo(); // System.err.println("New position is: " + pane.getCaretPosition()); } }); assertEquals("Should have undone.", text, doc.getText()); int rePos = doc.getCurrentLocation(); // System.err.println("Restored position is: " + rePos); // cursor will be located at beginning of first line that is changed // assertEquals("Undo should have restored cursor position.", oldPos, rePos); Utilities.invokeAndWait(new Runnable() { public void run() { pane.setCaretPosition(newPos); doc.getUndoManager().redo(); } }); Utilities.clearEventQueue(); assertEquals("redo",indented, doc.getText()); // assertEquals("redo restores caret position", oldPos, pane.getCaretPosition()); _log.log("testMultilineIndentAfterScroll completed"); } JScrollPane _pane1, _pane2; DefinitionsPane _defPane1, _defPane2; /** Ensure that a document's editable status is set appropriately throughout the compile process. Since the behavior * is interesting only when the model changes its active document, that's what this test looks most like. */ public void testGlassPaneEditableState() { SingleDisplayModel model = _frame.getModel(); final OpenDefinitionsDocument doc1 = model.newFile(); final OpenDefinitionsDocument doc2 = model.newFile(); // doc2 is now active Utilities.invokeAndWait(new Runnable() { public void run() { _pane1 = _frame._createDefScrollPane(doc1); _pane2 = _frame._createDefScrollPane(doc2); _defPane1 = (DefinitionsPane) _pane1.getViewport().getView(); _defPane2 = (DefinitionsPane) _pane2.getViewport().getView(); _frame._switchDefScrollPane(); } }); Utilities.clearEventQueue(); // Execute all pending asynchronous tasks; assertTrue("Start: defPane1", _defPane1.isEditable()); assertTrue("Start: defPane2", _defPane2.isEditable()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.hourglassOn(); } }); Utilities.clearEventQueue(); assertTrue("Glass on: defPane1", _defPane1.isEditable()); assertTrue("Glass on: defPane2",(! _defPane2.isEditable())); model.setActiveDocument(doc1); Utilities.invokeAndWait(new Runnable() { public void run() { _frame._switchDefScrollPane(); } }); Utilities.clearEventQueue(); assertTrue("Doc Switch: defPane1",(! _defPane1.isEditable())); assertTrue("Doc Switch: defPane2", _defPane2.isEditable()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.hourglassOff(); } }); Utilities.clearEventQueue(); assertTrue("End: defPane1", _defPane1.isEditable()); assertTrue("End: defPane2", _defPane2.isEditable()); _log.log("testGlassPaneEditableState completed"); } private KeyEvent makeFindKeyEvent(Component c, long when) { return new KeyEvent(c, KeyEvent.KEY_PRESSED, when, KeyEvent.CTRL_MASK, KeyEvent.VK_F, 'F'); } /** Ensure that all key events are disabled when the glass pane is up. */ public void testGlassPaneHidesKeyEvents() { SingleDisplayModel model = _frame.getModel(); final OpenDefinitionsDocument doc1 = model.newFile(); final OpenDefinitionsDocument doc2 = model.newFile(); // doc2 is now active Utilities.invokeAndWait(new Runnable() { public void run() { _pane1 = _frame._createDefScrollPane(doc1); _pane2 = _frame._createDefScrollPane(doc2); _defPane1 = (DefinitionsPane) _pane1.getViewport().getView(); _defPane2 = (DefinitionsPane) _pane2.getViewport().getView(); _frame.validate(); _frame.hourglassOn(); _defPane1.processKeyEvent(makeFindKeyEvent(_defPane1, 70)); _frame.validate(); } }); Utilities.clearEventQueue(); assertTrue("the find replace dialog should not come up", ! _frame.getFindReplaceDialog().isDisplayed()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.getInteractionsPane().processKeyEvent(makeFindKeyEvent(_frame.getInteractionsPane(), 0)); _frame.validate(); } }); Utilities.clearEventQueue(); assertTrue("the find replace dialog should not come up", ! _frame.getFindReplaceDialog().isDisplayed()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.hourglassOff(); } }); _log.log("testGlassPaneHidesKeyEvents completed"); } /** Tests that the save button does not set itself as enabled immediately after opening a file. */ public void testSaveButtonEnabled() throws IOException { String user = System.getProperty("user.name"); _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); File forceOpenClass1_file = new File(_tempDir, "ForceOpenClass1.java"); String forceOpenClass1_string = "public class ForceOpenClass1 {\n" + " ForceOpenClass2 class2;\n" + " ForceOpenClass3 class3;\n\n" + " public ForceOpenClass1() {\n" + " class2 = new ForceOpenClass2();\n" + " class3 = new ForceOpenClass3();\n" + " }\n" + "}"; IOUtil.writeStringToFile(forceOpenClass1_file, forceOpenClass1_string); forceOpenClass1_file.deleteOnExit(); //_frame.setVisible(true); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.pack(); _frame.open(new FileOpenSelector() { public File[] getFiles() { File[] return_me = new File[1]; return_me[0] = new File(_tempDir, "ForceOpenClass1.java"); return return_me; } }); } }); Utilities.clearEventQueue(); assertTrue("the save button should not be enabled after opening a document", !_frame.saveEnabledHuh()); _log.log("testSaveButtonEnabled completed"); } /** A Test to guarantee that the Dancing UI bug will not rear its ugly head again. * Basically, add a component listener to the leftComponent of _docSplitPane and * make certain its size does not change while compiling a class which depends on * another class. */ public void testDancingUIFileOpened() throws IOException { //System.out.println("DEBUG: Entering messed up test"); /** Maybe this sequence of calls should be incorporated into one function createTestDir(), which would get * the username and create the temporary directory. Only sticky part is deciding where to put it, in FileOps * maybe? */ _log.log("Starting testingDancingUIFileOpened"); final GlobalModel _model = _frame.getModel(); String user = System.getProperty("user.name"); _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); File forceOpenClass1_file = new File(_tempDir, "ForceOpenClass1.java"); String forceOpenClass1_string = "public class ForceOpenClass1 {\n" + " ForceOpenClass2 class2;\n" + " ForceOpenClass3 class3;\n\n" + " public ForceOpenClass1() {\n" + " class2 = new ForceOpenClass2();\n" + " class3 = new ForceOpenClass3();\n" + " }\n" + "}"; File forceOpenClass2_file = new File(_tempDir, "ForceOpenClass2.java"); String forceOpenClass2_string = "public class ForceOpenClass2 {\n" + " inx x = 4;\n" + "}"; File forceOpenClass3_file = new File(_tempDir, "ForceOpenClass3.java"); String forceOpenClass3_string = "public class ForceOpenClass3 {\n" + " String s = \"asf\";\n" + "}"; IOUtil.writeStringToFile(forceOpenClass1_file, forceOpenClass1_string); IOUtil.writeStringToFile(forceOpenClass2_file, forceOpenClass2_string); IOUtil.writeStringToFile(forceOpenClass3_file, forceOpenClass3_string); forceOpenClass1_file.deleteOnExit(); forceOpenClass2_file.deleteOnExit(); forceOpenClass3_file.deleteOnExit(); _log.log("DancingUIFileOpened Set Up"); //_frame.setVisible(true); // set up listeners and signal flags final ComponentAdapter listener = new ComponentAdapter() { public void componentResized(ComponentEvent event) { _testFailed = true; fail("testDancingUI: Open Documents List danced!"); } }; final SingleDisplayModelFileOpenedListener openListener = new SingleDisplayModelFileOpenedListener(); final SingleDisplayModelCompileListener compileListener = new SingleDisplayModelCompileListener(); _openDone = false; Utilities.invokeAndWait(new Runnable() { public void run() { // _frame.setVisible(true); _frame.pack(); _frame.addComponentListenerToOpenDocumentsList(listener); } }); Utilities.clearEventQueue(); _model.addListener(openListener); _log.log("opening file"); Utilities.invokeLater(new Runnable() { public void run() { _frame.open(new FileOpenSelector() { public File[] getFiles() { File[] return_me = new File[1]; return_me[0] = new File(_tempDir, "ForceOpenClass1.java"); return return_me; } }); } }); Utilities.clearEventQueue(); /* wait until file has been open and active document changed. */ synchronized(_openLock) { try { while (! _openDone) _openLock.wait(); } catch(InterruptedException e) { fail(e.toString()); } } _model.removeListener(openListener); _log.log("File opened"); _compileDone = false; _model.addListener(compileListener); // save and compile the new file asynchronously Utilities.invokeLater(new Runnable() { public void run() { _log.log("saving all files"); _frame._saveAll(); _log.log("invoking compileAll action"); _frame.getCompileAllButton().doClick(); } }); Utilities.clearEventQueue(); synchronized(_compileLock) { try { while (! _compileDone) _compileLock.wait(); } catch(InterruptedException e) { fail(e.toString()); } } _log.log("File saved and compiled"); if (! IOUtil.deleteRecursively(_tempDir)) System.out.println("Couldn't fully delete directory " + _tempDir.getAbsolutePath() + "\nDo it by hand.\n"); _log.log("testDancingUIFileOpened completed"); } /** A Test to guarantee that the Dancing UI bug will not rear its ugly head again. Basically, add a component listener * to the leftComponent of _docSplitPane and make certain its size does not change while closing an * OpenDefinitionsDocument outside the event thread. */ public void testDancingUIFileClosed() throws IOException { /** Maybe this sequence of calls should be incorporated into one function createTestDir(), which would get the * username and create the temporary directory. Only sticky part is deciding where to put it, in FileOps maybe? */ String user = System.getProperty("user.name"); _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); File forceOpenClass1_file = new File(_tempDir, "ForceOpenClass1.java"); String forceOpenClass1_string = "public class ForceOpenClass1 {\n" + " ForceOpenClass2 class2;\n" + " ForceOpenClass3 class3;\n\n" + " public ForceOpenClass1() {\n" + " class2 = new ForceOpenClass2();\n" + " class3 = new ForceOpenClass3();\n" + " }\n" + "}"; IOUtil.writeStringToFile(forceOpenClass1_file, forceOpenClass1_string); forceOpenClass1_file.deleteOnExit(); final ComponentAdapter listener = new ComponentAdapter() { public void componentResized(ComponentEvent event) { _testFailed = true; fail("testDancingUI: Open Documents List danced!"); } }; final SingleDisplayModelFileClosedListener closeListener = new SingleDisplayModelFileClosedListener(); _closeDone = false; Utilities.invokeAndWait(new Runnable() { public void run() { // _frame.setVisible(true); _frame.pack(); _frame.addComponentListenerToOpenDocumentsList(listener); _frame.open(new FileOpenSelector() { public File[] getFiles() { File[] return_me = new File[1]; return_me[0] = new File(_tempDir, "ForceOpenClass1.java"); return return_me; } }); _frame.getModel().addListener(closeListener); } }); Utilities.clearEventQueue(); /* Asynchronously close the file */ Utilities.invokeLater(new Runnable() { public void run() { _frame.getCloseButton().doClick(); } }); _log.log("Waiting for file closing"); synchronized(_closeLock) { try { while (! _closeDone) _closeLock.wait(); } catch(InterruptedException e) { fail(e.toString()); } } if (! IOUtil.deleteRecursively(_tempDir)) { System.out.println("Couldn't fully delete directory " + _tempDir.getAbsolutePath() + "\nDo it by hand.\n"); } _log.log("testDancingUIFileClosed completed"); } /** A CompileListener for SingleDisplayModel (instead of GlobalModel) */ class SingleDisplayModelCompileListener extends GlobalModelTestCase.TestListener implements GlobalModelListener { @Override public void compileStarted() { } /** Just notify when the compile has ended */ @Override public void compileEnded(File workDir, List<? extends File> excludedFiles) { synchronized(_compileLock) { _compileDone = true; _compileLock.notify(); } } @Override public void fileOpened(OpenDefinitionsDocument doc) { } @Override public void activeDocumentChanged(OpenDefinitionsDocument active) { } } /** A FileClosedListener for SingleDisplayModel (instead of GlobalModel) */ class SingleDisplayModelFileOpenedListener extends GlobalModelTestCase.TestListener implements GlobalModelListener { @Override public void fileClosed(OpenDefinitionsDocument doc) { } @Override public void fileOpened(OpenDefinitionsDocument doc) { } @Override public void newFileCreated(OpenDefinitionsDocument doc) { } @Override public void activeDocumentChanged(OpenDefinitionsDocument doc) { synchronized(_openLock) { _openDone = true; _openLock.notify(); } } } /** A FileClosedListener for SingleDisplayModel (instead of GlobalModel) */ class SingleDisplayModelFileClosedListener extends GlobalModelTestCase.TestListener implements GlobalModelListener { @Override public void fileClosed(OpenDefinitionsDocument doc) { synchronized(_closeLock) { _closeDone = true; _closeLock.notify(); } } @Override public void fileOpened(OpenDefinitionsDocument doc) { } @Override public void newFileCreated(OpenDefinitionsDocument doc) { } @Override public void activeDocumentChanged(OpenDefinitionsDocument active) { } } /** Create a new temporary file in _tempDir. */ protected File tempFile(String fileName) throws IOException { File f = File.createTempFile(fileName, ".java", _tempDir).getCanonicalFile(); f.deleteOnExit(); return f; } /** Tests that "go to file under cursor" works if unique. */ public void testGotoFileUnderCursor() throws IOException { // Utilities.show("Running testGotoFileUnderCursor"); String user = System.getProperty("user.name"); _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); final File goto1_file = new File(_tempDir, "GotoFileUnderCursor1.java"); String goto1_string = "GotoFileUnderCursorTest"; IOUtil.writeStringToFile(goto1_file, goto1_string); goto1_file.deleteOnExit(); final File goto2_file = new File(_tempDir, "GotoFileUnderCursorTest.java"); String goto2_string = "GotoFileUnderCursor1"; IOUtil.writeStringToFile(goto2_file, goto2_string); goto2_file.deleteOnExit(); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.pack(); _frame.open(new FileOpenSelector() { public File[] getFiles() { return new File[] { goto1_file, goto2_file }; } }); } }); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.initGotoFileDialog(); _frame._gotoFileDialog.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { throw new RuntimeException("Should not activate _gotoFileDialog"); } public void windowClosed(WindowEvent e) { throw new RuntimeException("Should not close _gotoFileDialog"); } public void windowClosing(WindowEvent e) { throw new RuntimeException("Should not be closing _gotoFileDialog"); } public void windowDeactivated(WindowEvent e) { throw new RuntimeException("Should not deactivate _gotoFileDialog"); } public void windowDeiconified(WindowEvent e) { throw new RuntimeException("Should not deiconify _gotoFileDialog"); } public void windowIconified(WindowEvent e) { throw new RuntimeException("Should not iconify _gotoFileDialog"); } public void windowOpened(WindowEvent e) { throw new RuntimeException("Should not open _gotoFileDialog"); } }); }}); Utilities.clearEventQueue(); SingleDisplayModel model = _frame.getModel(); OpenDefinitionsDocument goto1_doc = model.getDocumentForFile(goto1_file); OpenDefinitionsDocument goto2_doc = model.getDocumentForFile(goto2_file); model.setActiveDocument(model.getDocumentForFile(goto1_file)); assertEquals("Document contains the incorrect text", goto1_string, model.getActiveDocument().getText()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame._gotoFileUnderCursor(); } }); Utilities.clearEventQueue(); assertEquals("Incorrect active document; did not go to?", goto2_doc, model.getActiveDocument()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame._gotoFileUnderCursor(); } }); Utilities.clearEventQueue(); assertEquals("Incorrect active document; did not go to?", goto1_doc, model.getActiveDocument()); _log.log("gotoFileUnderCursor completed"); } /** Tests that "go to file under cursor" works if unique after appending ".java" */ public void testGotoFileUnderCursorAppendJava() throws IOException { String user = System.getProperty("user.name"); _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); final File goto1_file = new File(_tempDir, "GotoFileUnderCursor2Test.java"); String goto1_string = "GotoFileUnderCursor2"; IOUtil.writeStringToFile(goto1_file, goto1_string); goto1_file.deleteOnExit(); final File goto2_file = new File(_tempDir, "GotoFileUnderCursor2.java"); String goto2_string = "GotoFileUnderCursor2Test"; IOUtil.writeStringToFile(goto2_file, goto2_string); goto2_file.deleteOnExit(); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.pack(); _frame.open(new FileOpenSelector() { public File[] getFiles() { return new File[] { goto1_file, goto2_file }; } }); } }); Utilities.clearEventQueue(); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.initGotoFileDialog(); _frame._gotoFileDialog.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { throw new RuntimeException("Should not activate _gotoFileDialog"); } public void windowClosed(WindowEvent e) { throw new RuntimeException("Should not close _gotoFileDialog"); } public void windowClosing(WindowEvent e) { throw new RuntimeException("Should not be closing _gotoFileDialog"); } public void windowDeactivated(WindowEvent e) { throw new RuntimeException("Should not deactivate _gotoFileDialog"); } public void windowDeiconified(WindowEvent e) { throw new RuntimeException("Should not deiconify _gotoFileDialog"); } public void windowIconified(WindowEvent e) { throw new RuntimeException("Should not iconify _gotoFileDialog"); } public void windowOpened(WindowEvent e) { throw new RuntimeException("Should not open _gotoFileDialog"); } }); }}); Utilities.clearEventQueue(); SingleDisplayModel model = _frame.getModel(); OpenDefinitionsDocument goto1_doc = model.getDocumentForFile(goto1_file); OpenDefinitionsDocument goto2_doc = model.getDocumentForFile(goto2_file); model.setActiveDocument(model.getDocumentForFile(goto1_file)); assertEquals("Document contains the incorrect text", goto1_string, model.getActiveDocument().getText()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame._gotoFileUnderCursor(); } }); Utilities.clearEventQueue(); assertEquals("Incorrect active document; did not go to?", goto2_doc, model.getActiveDocument()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame._gotoFileUnderCursor(); } }); Utilities.clearEventQueue(); assertEquals("Incorrect active document; did not go to?", goto1_doc, model.getActiveDocument()); _log.log("gotoFileUnderCursorAppendJava completed"); } /** Tests that "go to file under cursor" displays the dialog if choice is not unique */ public void testGotoFileUnderCursorShowDialog() throws IOException { // Utilities.show("Running testGotoFileUnderCursorShowDialog()"); String user = System.getProperty("user.name"); _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, ""); final File goto1_file = new File(_tempDir, "GotoFileUnderCursor3.java"); String goto1_string = "GotoFileUnderCursor"; IOUtil.writeStringToFile(goto1_file, goto1_string); goto1_file.deleteOnExit(); final File goto2_file = new File(_tempDir, "GotoFileUnderCursor4.java"); String goto2_string = "GotoFileUnderCursor3"; IOUtil.writeStringToFile(goto2_file, goto2_string); goto2_file.deleteOnExit(); Utilities.invokeAndWait(new Runnable() { public void run() { _frame.pack(); _frame.open(new FileOpenSelector() { public File[] getFiles() { return new File[] { goto1_file, goto2_file }; } }); } }); final int[] count = new int[2]; Utilities.invokeAndWait(new Runnable() { public void run() { _frame.initGotoFileDialog(); _frame._gotoFileDialog.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { ++count[0]; } public void windowClosed(WindowEvent e) { throw new RuntimeException("Should not close _gotoFileDialog"); } public void windowClosing(WindowEvent e) { throw new RuntimeException("Should not be closing _gotoFileDialog"); } public void windowDeactivated(WindowEvent e) { /* throw new RuntimeException("Should not deactivate _gotoFileDialog"); */ } public void windowDeiconified(WindowEvent e) { throw new RuntimeException("Should not deiconify _gotoFileDialog"); } public void windowIconified(WindowEvent e) { throw new RuntimeException("Should not iconify _gotoFileDialog"); } public void windowOpened(WindowEvent e) { ++count[1]; } }); } }); Utilities.clearEventQueue(); SingleDisplayModel model = _frame.getModel(); OpenDefinitionsDocument goto1_doc = model.getDocumentForFile(goto1_file); OpenDefinitionsDocument goto2_doc = model.getDocumentForFile(goto2_file); model.setActiveDocument(model.getDocumentForFile(goto1_file)); assertEquals("Document contains the incorrect text", goto1_string, model.getActiveDocument().getText()); Utilities.invokeAndWait(new Runnable() { public void run() { _frame._gotoFileUnderCursor(); } }); Utilities.clearEventQueue(); // wait for any asynchronous actions to complete /* The following test was commented out before test following it was. It presumably fails even if * the "MainFrame.this.isVisible()" test mentioned below is removed from _gotoFileUnderCursor */ // assertEquals("Did not activate _gotoFileDialog", 1, count[0]); /* The following test was commented out after suppressing this display when _frame is not visible. If it is * uncommented, then the "MainFrame.this.isVisible()" test in _gotoFileDialog must be removed. */ // assertEquals("Did not open _gotoFileDialog", 1, count[1]); _log.log("gotoFileUnderCursorShowDialog completed"); } }

The table below shows all metrics for MainFrameTest.java.

MetricValueDescription
BLOCKS110.00Number of blocks
BLOCK_COMMENT44.00Number of block comment lines
COMMENTS155.00Comment lines
COMMENT_DENSITY 0.27Comment density
COMPARISONS 5.00Number of comparison operators
CYCLOMATIC103.00Cyclomatic complexity
DECL_COMMENTS26.00Comments in declarations
DOC_COMMENT48.00Number of javadoc comment lines
ELOC573.00Effective lines of code
EXEC_COMMENTS68.00Comments in executable code
EXITS98.00Procedure exits
FUNCTIONS93.00Number of function declarations
HALSTEAD_DIFFICULTY72.72Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY160.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 7.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
JAVA002012.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 1.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 9.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 1.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 3.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 1.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 3.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 1.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 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 1.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 1.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA011516.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 1.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 1.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 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 1.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 7.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 2.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 2.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 3.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 1.00JAVA0176 Local variable name does not have required form
JAVA0177 2.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 2.00JAVA0266 Use of System.out
JAVA0267 0.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
LINES960.00Number of lines in the source file
LINE_COMMENT63.00Number of line comments
LOC632.00Lines of code
LOGICAL_LINES427.00Number of statements
LOOPS 3.00Number of loops
NEST_DEPTH 3.00Maximum nesting depth
OPERANDS1705.00Number of operands
OPERATORS3186.00Number of operators
PARAMS39.00Number of formal parameter declarations
PROGRAM_LENGTH4891.00Halstead program length
PROGRAM_VOCAB598.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS121.00Number of return points from functions
SIZE39705.00Size of the file in bytes
UNIQUE_OPERANDS551.00Number of unique operands
UNIQUE_OPERATORS47.00Number of unique operators
WHITESPACE173.00Number of whitespace lines