Sample

Schnappinger/argoUML/org.argouml.model.euml.UMLUtil

Human rating uses the original dataset scale.

Human2.17
Lines199

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
26.8Δ 17.2
Scalabrino0.6080–1; higher is more readable
23.6Δ 14.1
Dorn0.0350–1; higher is more readable
26.1Δ 16.5
Mi0.2040–1; higher is more readable
15.5Δ 5.9
LLOC59Logical lines; fewer is more readable
35.3Δ 25.7
DeepSeek V4 Pro12.330–20; mean of three runs
17.2Δ 7.6
GPT-6.1 Sol15.670–20; mean of three runs
32.3Δ 22.8
BTTF0.2990–1; higher is more readable
20.1Δ 10.6
Human2.171–4; original rating
9.6

Views

Source code

// $Id: UMLUtil.java 19105 2011-03-05 01:04:10Z thn $ /******************************************************************************* * Copyright (c) 2007,2010 Bogdan Pistol and other contributors * 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: * Bogdan Pistol - initial API and implementation *******************************************************************************/ package org.argouml.model.euml; import org.eclipse.emf.common.command.Command; import org.eclipse.emf.common.command.StrictCompoundCommand; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.edit.command.CopyToClipboardCommand; import org.eclipse.emf.edit.command.PasteFromClipboardCommand; import org.eclipse.uml2.uml.Association; import org.eclipse.uml2.uml.AssociationClass; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.Operation; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.Type; /** * This class exposes protected methods from * {@link org.eclipse.uml2.uml.UMLUtil} and adds additional util methods * * @author Bogdan Pistol */ public class UMLUtil extends org.eclipse.uml2.uml.util.UMLUtil { /** * The default URI used for eUML */ public static final URI DEFAULT_URI = URI.createURI("http://argouml.tigris.org/euml/resource/default_uri.xmi"); //$NON-NLS-1$ /** * Getter for the attributes of a Type * * @param type * The Type that owns the attributes * @return the attributes or null */ public static EList<Property> getOwnedAttributes(Type type) { if (type instanceof AssociationClass) { return ((AssociationClass) type).getOwnedAttributes(); } else if (type instanceof Association) { return ((Association) type).getOwnedEnds(); } else { return org.eclipse.uml2.uml.util.UMLUtil.getOwnedAttributes(type); } } /** * Getter for the operations of a Type * * @param type * The Type that owns the operations * @return the operations or null */ public static EList<Operation> getOwnedOperations(Type type) { return org.eclipse.uml2.uml.util.UMLUtil.getOwnedOperations(type); } /** * Copy a tree of UML elements into a destination location * * @param modelImplementation * the eUML model implementation * @param source * the tree of UML elements to be copied * @param destination * the destination container * @return the root of the newly copied tree of UML elements or null */ public static Element copy(EUMLModelImplementation modelImplementation, Element source, Element destination) { Command copyToClipboard = CopyToClipboardCommand.create( modelImplementation.getEditingDomain(), source); Command pasteFromClipboard = PasteFromClipboardCommand.create( modelImplementation.getEditingDomain(), destination, null); StrictCompoundCommand copyCommand = new StrictCompoundCommand() { { isPessimistic = true; } }; copyCommand.append(copyToClipboard); copyCommand.append(pasteFromClipboard); copyCommand.setLabel("Copy a tree of UML elements to a destination"); //$NON-NLS-1$ if (copyCommand.canExecute()) { modelImplementation.getModelEventPump().getRootContainer().setHoldEvents( true); modelImplementation.getEditingDomain().getCommandStack().execute( copyCommand); if (modelImplementation.getEditingDomain().getCommandStack().getMostRecentCommand().getAffectedObjects().size() == 1) { modelImplementation.getModelEventPump().getRootContainer().setHoldEvents( false); return (Element) modelImplementation.getEditingDomain().getCommandStack().getMostRecentCommand().getAffectedObjects().iterator().next(); } else { modelImplementation.getEditingDomain().getCommandStack().undo(); modelImplementation.getModelEventPump().getRootContainer().clearHeldEvents(); modelImplementation.getModelEventPump().getRootContainer().setHoldEvents( false); } } return null; } /** * Returns information about an Object. * <p> * If it's an Element it returns its metaclass name, and if it's a * NamedElement it appends its name. * * @param o * The object * @return the String description */ public static String toString(Object o) { if (o == null) { return "null"; //$NON-NLS-1$ } if (!(o instanceof Element)) { return o.toString(); } StringBuilder sb = new StringBuilder("'"); //$NON-NLS-1$ boolean named = false; if (o instanceof NamedElement && ((NamedElement) o).getName() != null && !((NamedElement) o).getName().equals("")) { //$NON-NLS-1$ named = true; sb.append(((NamedElement) o).getName() + " ["); //$NON-NLS-1$ } sb.append(((Element) o).eClass().getName()); if (named) { sb.append("]"); //$NON-NLS-1$ } sb.append("'"); //$NON-NLS-1$ return sb.toString(); } /** * Returns the Resource associated with an URI or creates the resource if it * does not exist * * @param modelImplementation * the eUML implementation * @param uri * the URI which identifies the resource * @return the retrieved or created resource */ static Resource getResource( EUMLModelImplementation modelImplementation, URI uri, boolean readOnly) { if (!"xmi".equals(uri.fileExtension()) //$NON-NLS-1$ && !"uml".equals(uri.fileExtension())) { //$NON-NLS-1$ // Make sure we have a recognized file extension uri = uri.appendFileExtension("xmi"); //$NON-NLS-1$ } Resource r = modelImplementation.getEditingDomain().getResourceSet() .getResource(uri, false); if (r == null) { r = modelImplementation.getEditingDomain().getResourceSet() .createResource(uri); } if (r == null) { throw new NullPointerException("Failed to create resource for URI " //$NON-NLS-1$ + uri); } modelImplementation.getReadOnlyMap().put(r, Boolean.valueOf(readOnly)); return r; } @SuppressWarnings("unchecked") static void checkArgs(Object[] args, Class[] types) { if (args.length != types.length) { throw new IllegalArgumentException( "Mismatched array lengths for args and types"); //$NON-NLS-1$ } for (int i = 0; i < args.length; i++) { if (!types[i].isAssignableFrom(args[i].getClass())) { throw new IllegalArgumentException( "Parameter " + i + " must be of type " + types[i]); //$NON-NLS-1$//$NON-NLS-2$ } } } }

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.6863.4−226.492
Source linesThe number of non-empty source lines.199+79.6
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.645−6.968

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

Score0.608

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.200−6.045
Indentation frequencyHow rapidly indentation changes from line to line.127+3.656
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.151.98−2.772
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.126−2.47
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.198.922+2.371
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.151.995+1.648
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.073+0.237

Intercept 0.07 + feature contributions = -3.306 (log-odds).
Score = sigmoid(-3.306) = 0.035.

Score0.204
Score59
Run 1

The code is generally readable but has inconsistencies. Structure is straightforward with clear method separation and JavaDoc, but comments like '$Id$' are outdated. Nesting is moderate: the copy() method has a deeply nested if-else block with long chained calls, reducing clarity. Intent is mostly clear, though the copy method's use of clipboard commands to copy elements is not immediately obvious. Code length is reasonable but some lines are excessively long (e.g., getMostRecentCommand().getAffectedObjects() chains), hurting readability. Action granularity is mixed: many lines are single-action, but several long lines perform multiple operations. Reading flow is natural for utility methods, but dense command-stack manipulation breaks it. Overall, the code is functional but would benefit from refactoring long expressions and flattening the copy() logic.

Run 2

The code has some positive aspects like clear method names and Javadoc comments, but suffers from major readability issues. The 'copy' method is deeply nested with multiple long method chains on single lines, violating the action granularity criterion. Lines exceed reasonable length with calls like 'modelImplementation.getModelEventPump().getRootContainer().setHoldEvents(true)'. The if-else structure in 'copy' creates complex nesting and poor reading flow. Several methods have multiple actions per line, particularly in the toString method. While the class structure is logical and imports are organized, the implementation details in the copy method make the intent hard to follow. The use of anonymous inner class with instance initializer block is an unusual pattern that reduces clarity. Overall, the code requires significant vertical scrolling and care to understand, especially in the copy method which handles multiple concerns without breaking them into smaller helper methods.

Run 3

The code demonstrates generally good structure: clear package and imports, Javadoc comments, and methods organized by purpose. However, readability is reduced by long method chains, especially in the copy() method, where multiple deeply nested calls with repeated access to editing domain and command stack hinder clarity. Nesting levels are moderate overall, but the copy() logic contains several nested if/else branches. Action granularity suffers in places—multiple operations are packed into single long lines. Variable names like 'r' are overly terse, and some methods lack inline comments explaining non-obvious logic. The getResource() method has reasonable flow, but the copy() method feels tangled and would benefit from extraction of helper methods. Javadoc is helpful, but the code's density and repetitive verbosity reduce reading flow.

Run 1

Code Structure: Well-separated utility methods with consistent formatting and useful documentation, though copy mixes command setup, execution, event management, and rollback. Nesting: Generally shallow; copy has modest nested branching, while early returns simplify toString. Clarity of intent: Descriptive method names and comments explain most behavior, but terse variables such as o, sb, and r and the anonymous initializer reduce clarity. Code length: Mostly concise, although repeated framework access chains and verbose boilerplate add visual weight. Action granularity: Usually one action per statement, but long chained expressions make some lines difficult to parse. Reading flow: Methods generally progress naturally from validation to operation and return; copy interrupts this flow with duplicated event-management calls and lengthy expressions. Overall, readable and logically organized, with localized complexity rather than pervasive confusion.

Run 2

Code Structure: Methods are logically separated by utility task, although copy combines command construction, execution, event handling, and rollback. Nesting: Generally shallow; copy has moderately nested branching and an unusual anonymous-class initializer. Clarity of intent: Descriptive method names and Javadoc explain most purposes, but short names such as o, r, and sb, repeated casts, and undocumented checkArgs reduce clarity. Code length: Mostly concise, though repeated access chains and verbose documentation add bulk. Action granularity: Most statements perform one action, but long chained expressions pack several retrieval steps into single lines. Reading flow: Consistent formatting and early returns support natural reading; excessively long lines, repeated event-management calls, and inline localization markers interrupt it.

Run 3

Code Structure: Methods are logically separated by utility function, with helpful documentation. Nesting: Most methods are shallow; copy has moderately nested execution and rollback branches plus an unusual anonymous-class initializer. Clarity of intent: Descriptive method names and comments explain most behavior, but short names such as o, r, and sb, repeated casts, and undocumented checkArgs reduce clarity. Code length: Generally concise, although repeated access chains in copy and verbose boilerplate add unnecessary reading effort. Action granularity: Statements generally perform one action per line, but long chained calls and complex expressions obscure intermediate steps. Reading flow: Consistent formatting and early returns support natural reading; unusually long lines, repeated event-management calls, and inline localization markers interrupt the flow.