Sample

Schnappinger/argoUML/org.argouml.uml.ui.ActionImportFromSources

Human rating uses the original dataset scale.

Human2.87
Lines162

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
36.1Δ 16.6
Scalabrino0.7530–1; higher is more readable
50.0Δ 30.5
Dorn0.2910–1; higher is more readable
47.2Δ 27.7
Mi0.5810–1; higher is more readable
55.1Δ 35.6
LLOC41Logical lines; fewer is more readable
42.9Δ 23.4
DeepSeek V4 Pro15.330–20; mean of three runs
41.3Δ 21.8
GPT-6.1 Sol160–20; mean of three runs
38.9Δ 19.5
BTTF0.5410–1; higher is more readable
48.2Δ 28.7
Human2.871–4; original rating
19.5

Views

Source code

/* $Id: ActionImportFromSources.java 19907 2012-12-30 13:06:01Z closettop_nightlybuild $ ***************************************************************************** * Copyright (c) 2009-2012 Contributors - see below * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * bobtarling ***************************************************************************** * * Some portions of this file was previously release using the BSD License: */ // Copyright (c) 1996-2006 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this // software and its documentation without fee, and without a written // agreement is hereby granted, provided that the above copyright notice // and this paragraph appear in all copies. This software program and // documentation are copyrighted by The Regents of the University of // California. The software program and documentation are supplied "AS // IS", without any accompanying services from The Regents. The Regents // does not warrant that the operation of the program will be // uninterrupted or error-free. The end-user understands that the program // was developed for research purposes and is advised not to rely // exclusively on the program for any reason. IN NO EVENT SHALL THE // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. package org.argouml.uml.ui; import java.awt.event.ActionEvent; import java.io.File; import java.util.Collection; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.Action; import javax.swing.JFrame; import org.argouml.application.api.CommandLineInterface; import org.argouml.application.helpers.ResourceLoaderWrapper; import org.argouml.i18n.Translator; import org.argouml.ui.ExceptionDialog; import org.argouml.ui.UndoableAction; import org.argouml.uml.reveng.Import; import org.argouml.uml.reveng.ImportInterface; import org.argouml.uml.reveng.ImporterManager; import org.argouml.uml.reveng.ui.ImportStatusScreen; import org.argouml.util.ArgoFrame; /** Action to trigger importing from sources. * @stereotype singleton */ public class ActionImportFromSources extends UndoableAction implements CommandLineInterface { /** * Logger. */ private static final Logger LOG = Logger.getLogger(ActionImportFromSources.class.getName()); /** * The singleton. */ private static final ActionImportFromSources SINGLETON = new ActionImportFromSources(); /** * The constructor. */ public ActionImportFromSources() { // this is never downlighted... super(Translator.localize("action.import-sources"), ResourceLoaderWrapper.lookupIcon("action.import-sources")); // Set the tooltip string: putValue(Action.SHORT_DESCRIPTION, Translator.localize("action.import-sources")); } /* * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent event) { super.actionPerformed(event); if (ImporterManager.getInstance().hasImporters()) { new Import(ArgoFrame.getFrame()); } else { LOG.log(Level.INFO, "Import sources dialog not shown: no importers!"); ExceptionDialog ed = new ExceptionDialog(ArgoFrame.getFrame(), Translator.localize("dialog.title.problem"), Translator.localize("dialog.import.no-importers.intro"), Translator.localize("dialog.import.no-importers.message")); ed.setModal(true); ed.setVisible(true); } } /** * @return Returns the SINGLETON. */ public static ActionImportFromSources getInstance() { return SINGLETON; } /** * Command line command for importing a directory or file. * * @param argument Formatted string (<importmodule>:<importpath>) * @return true if the command was performed successfully. */ public boolean doCommand(String argument) { if (argument == null) { LOG.log(Level.SEVERE, "An argument has to be provided."); return false; } int index = argument.indexOf(':'); if (index == -1 || argument.length() <= index) { LOG.log(Level.SEVERE, "Argument must be <importmodule>:<importpath>"); return false; } Import imp = new Import(null); Collection languages = imp.getLanguages(); if (languages == null || languages.isEmpty()) { LOG.log(Level.SEVERE, "No importers available."); return false; } String importerName = argument.substring(0, index); ImportInterface importer = imp.getImporter(importerName); if (importer == null) { LOG.log(Level.SEVERE, "No import support for language " + importerName); return false; } imp.setCurrentModule(importer); File file = new File(argument.substring(index + 1)); if (!file.exists()) { LOG.log(Level.SEVERE, "The specified file/directory doesn't exist."); return false; } imp.setFiles(new File[]{file}); ImportStatusScreen iss = new ImportStatusScreen(new JFrame(), "Importing", "Splash"); imp.doImport(iss); return true; } } /* end class ActionImportFromSources */

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.4228.151−139.529
Source linesThe number of non-empty source lines.162+64.8
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.5.007−7.51

Intercept 8.87 + feature contributions = -73.369 (log-odds).
Score = sigmoid(-73.369) = 0.

Score0.753

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.163−4.735
Indentation frequencyHow rapidly indentation changes from line to line.107+2.964
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.107−2.034
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.161.955+1.854
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.87.417+0.606
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.051+0.446
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.87.963−0.061

Intercept 0.07 + feature contributions = -0.891 (log-odds).
Score = sigmoid(-0.891) = 0.291.

Score0.581
Score41
Run 1

The code is generally readable with a clear class structure, logical method separation, and descriptive variable names. It benefits from flat nesting, minimal cyclomatic complexity, and one action per line in most places. The actionPerformed and doCommand methods have clear purposes, and logging messages aid understandability. However, several issues lower the score: the doCommand method is long and performs multiple responsibilities (parsing, validation, file handling, import execution) without helper methods. Some nested if statements create minor complexity. Import statements and logging are verbose, but not excessive. Inconsistent indentation in the actionPerformed method (mixed spaces/tabs) hurts visual flow. The comment block at the top is lengthy and detracts from immediate code comprehension. Overall, the code is approachable for a developer, but would benefit from refactoring doCommand into smaller methods and standardizing formatting to improve readability further.

Run 2

The code is generally well-structured and readable. It follows clear logical organization with separate methods for different concerns (constructor, action handling, command execution). The nesting is minimal, with the deepest level being 2-3 levels in the doCommand method. Intent is clearly expressed through descriptive method names and comments. Code length is appropriate for the functionality - not overly verbose. Action granularity is mostly one action per line, though some lines combine multiple operations. The reading flow is natural, progressing logically from class declaration through methods. Minor deductions for: the mixed indentation (tabs vs spaces) in some blocks, excessive copyright comments at the top that push code down, and the doCommand method could benefit from extracting validation logic into smaller helper methods. The error handling is repetitive with similar null/empty checks that could be consolidated. Overall, this is clean, maintainable code that would be easy for another developer to understand and modify.

Run 3

The code is generally readable but has some issues. Structure is logical with clear separation of methods, and the class follows a recognizable pattern. However, there are inconsistencies: mixed indentation (tabs vs spaces), excessive license headers, and inconsistent Javadoc formatting. Nesting is mostly flat, which is good. Intent is clear for most methods, though the doCommand method is somewhat long and performs multiple validation steps. Variable naming could be more descriptive (e.g., 'imp', 'ed', 'iss'). Action granularity is reasonable with one major operation per line. The reading flow is acceptable but interrupted by the inconsistent formatting and verbose logging statements. The code would benefit from cleaner separation of concerns in doCommand, perhaps extracting validation logic into helper methods.

Run 1

Code Structure: Clearly separated constructor, GUI action handler, singleton accessor, and command-line handler, although doCommand combines validation, importer setup, and execution. Nesting: Shallow conditionals and early returns make execution paths easy to follow. Clarity of intent: Descriptive class and method names, explicit error messages, and parameter documentation explain the purpose; abbreviations such as imp, ed, and iss reduce local clarity. Code length: Implementation is reasonably concise, but lengthy license headers and redundant comments add reading overhead. Action granularity: Statements generally perform one action per line, with clear separation between validation and setup. Reading flow: The command-line method progresses naturally from argument validation to import execution. Mixed indentation, inconsistent comment formatting, and constructor-triggered GUI behavior slightly disrupt readability.

Run 2

Code Structure: Clearly organized into initialization, UI handling, singleton access, and command-line importing, although UI and CLI responsibilities share one class. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: Descriptive method names, logging, and argument documentation explain the purpose; abbreviations such as imp, ed, and iss reduce local clarity. Code length: Implementation is reasonably concise, but lengthy license headers and redundant comments add visual overhead. Action granularity: Statements generally perform one action per line, with readable wrapping of longer calls. Reading flow: Command-line validation proceeds naturally toward importing, but inconsistent indentation, a misaligned documentation delimiter, and raw Collection usage slightly interrupt readability.

Run 3

Code Structure: Clearly organized into initialization, GUI handling, singleton access, and command-line importing, although GUI and CLI responsibilities share one class. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: Descriptive method names and specific error messages explain the import workflow; abbreviated variables such as imp, iss, and ed and an obscure constructor comment reduce clarity. Code length: Implementation is reasonably concise, but extensive license headers and redundant comments add reading overhead. Action granularity: Statements generally perform one action per line, with sensible wrapping of longer calls. Reading flow: Validation proceeds naturally from argument parsing through importer selection, file checking, and execution. Inconsistent indentation and a misaligned Javadoc closing delimiter slightly disrupt presentation.