Sample

Schnappinger/argoUML/org.argouml.notation.providers.uml.ClassifierRoleNotationUml

Human rating uses the original dataset scale.

Human2.01
Lines299

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
25.1Δ 20.1
Scalabrino0.7210–1; higher is more readable
43.2Δ 38.2
Dorn0.0450–1; higher is more readable
28.1Δ 23.1
Mi0.5190–1; higher is more readable
37.0Δ 32.0
LLOC106Logical lines; fewer is more readable
23.1Δ 18.2
DeepSeek V4 Pro120–20; mean of three runs
15.5Δ 10.6
GPT-6.1 Sol12.330–20; mean of three runs
6.9Δ 2.0
BTTF0.2530–1; higher is more readable
16.8Δ 11.9
Human2.011–4; original rating
5.0

Views

Source code

/* $Id: ClassifierRoleNotationUml.java 18852 2010-11-20 19:27:11Z mvw $ ***************************************************************************** * Copyright (c) 2009-2010 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: * Michiel van der Wulp ***************************************************************************** * * Some portions of this file was previously release using the BSD License: */ // Copyright (c) 2006-2009 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.notation.providers.uml; import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import org.argouml.application.events.ArgoEventPump; import org.argouml.application.events.ArgoEventTypes; import org.argouml.application.events.ArgoHelpEvent; import org.argouml.i18n.Translator; import org.argouml.model.Model; import org.argouml.notation.NotationSettings; import org.argouml.notation.providers.ClassifierRoleNotation; import org.argouml.util.MyTokenizer; /** * The UML notation for a ClassifierRole. <p> * * The following is supported: <p> * * <pre> * baselist := [base] [, base]* * classifierRole := [name] [/ role] [: baselist] * </pre> * * The <code>role </code> and <code>baselist</code> can be given in * any order.<p> * * The <code>name</code> is the Instance name, not used for a ClassifierRole.<p> * * This syntax is compatible with the UML 1.3 and 1.4 specification. * * @author Michiel van der Wulp */ public class ClassifierRoleNotationUml extends ClassifierRoleNotation { /** * The Constructor. * * @param classifierRole the UML ClassifierRole */ public ClassifierRoleNotationUml(Object classifierRole) { super(classifierRole); } /* * @see org.argouml.notation.providers.NotationProvider#getParsingHelp() */ public String getParsingHelp() { return "parsing.help.fig-classifierrole"; } /* * @see org.argouml.notation.providers.NotationProvider#parse(java.lang.Object, java.lang.String) */ public void parse(Object modelElement, String text) { try { parseClassifierRole(modelElement, text); } catch (ParseException pe) { String msg = "statusmsg.bar.error.parsing.classifierrole"; Object[] args = {pe.getLocalizedMessage(), Integer.valueOf(pe.getErrorOffset()), }; ArgoEventPump.fireEvent(new ArgoHelpEvent( ArgoEventTypes.HELP_CHANGED, this, Translator.messageFormat(msg, args))); } } /** * Parses a ClassifierRole represented by the following line of the format: * * <pre> * baselist := [base] [, base]* * classifierRole := [name] [/ role] [: baselist] * </pre> * * <code>role </code> and <code>baselist</code> can be given in * any order.<p> * * This syntax is compatible with the UML 1.3 specification. * * (formerly: "name: base" ) * * @param cls the classifier role to apply any changes to * @param s the String to parse * @return the classifier role with the applied changes * @throws ParseException when it detects an error in the attribute string. * See also ParseError.getErrorOffset(). */ protected Object parseClassifierRole(Object cls, String s) throws ParseException { String name = null; String token; String role = null; String base = null; List<String> bases = null; boolean hasColon = false; boolean hasSlash = false; try { MyTokenizer st = new MyTokenizer(s, " ,\t,/,:,\\,"); while (st.hasMoreTokens()) { token = st.nextToken(); if (" ".equals(token) || "\t".equals(token)) { /* Do nothing. */ } else if ("/".equals(token)) { hasSlash = true; hasColon = false; if (base != null) { if (bases == null) { bases = new ArrayList<String>(); } bases.add(base); } base = null; } else if (":".equals(token)) { hasColon = true; hasSlash = false; if (bases == null) { bases = new ArrayList<String>(); } if (base != null) { bases.add(base); } base = null; } else if (",".equals(token)) { if (base != null) { if (bases == null) { bases = new ArrayList<String>(); } bases.add(base); } base = null; } else if (hasColon) { if (base != null) { String msg = "parsing.error.classifier.extra-test"; throw new ParseException( Translator.localize(msg), st.getTokenIndex()); } base = token; } else if (hasSlash) { if (role != null) { String msg = "parsing.error.classifier.extra-test"; throw new ParseException( Translator.localize(msg), st.getTokenIndex()); } role = token; } else { if (name != null) { String msg = "parsing.error.classifier.extra-test"; throw new ParseException( Translator.localize(msg), st.getTokenIndex()); } name = token; } } } catch (NoSuchElementException nsee) { String msg = "parsing.error.classifier.unexpected-end-attribute"; throw new ParseException(Translator.localize(msg), s.length()); } if (base != null) { if (bases == null) { bases = new ArrayList<String>(); } bases.add(base); } // TODO: What to do about object name??? // if (name != null) // ; if (role != null) { Model.getCoreHelper().setName(cls, role.trim()); } if (bases != null) { // Remove bases that aren't there anymore // copy - can't iterate modify live collection while iterating it Collection b = new ArrayList(Model.getFacade().getBases(cls)); Iterator it = b.iterator(); Object c; Object ns = Model.getFacade().getNamespace(cls); if (ns != null && Model.getFacade().getNamespace(ns) != null) { ns = Model.getFacade().getNamespace(ns); } else { ns = Model.getFacade().getRoot(cls); } while (it.hasNext()) { c = it.next(); if (!bases.contains(Model.getFacade().getName(c))) { Model.getCollaborationsHelper().removeBase(cls, c); } } it = bases.iterator(); addBases: while (it.hasNext()) { String d = ((String) it.next()).trim(); Iterator it2 = b.iterator(); while (it2.hasNext()) { c = it2.next(); if (d.equals(Model.getFacade().getName(c))) { continue addBases; } } c = NotationUtilityUml.getType(d, ns); if (Model.getFacade().isACollaboration( Model.getFacade().getNamespace(c))) { Model.getCoreHelper().setNamespace(c, ns); } Model.getCollaborationsHelper().addBase(cls, c); } } return cls; } private String toString(Object modelElement) { String nameString = Model.getFacade().getName(modelElement); if (nameString == null) { nameString = ""; } nameString = nameString.trim(); // Loop through all base classes, building a comma separated list StringBuilder baseString = NotationUtilityUml.formatNameList( Model.getFacade().getBases(modelElement)); baseString = new StringBuilder(baseString.toString().trim()); // Build the final string if (nameString.length() != 0) { nameString = "/" + nameString; } if (baseString.length() != 0) { baseString = baseString.insert(0, ":"); } return nameString + baseString.toString(); } @Override public String toString(Object modelElement, NotationSettings settings) { return toString(modelElement); } }

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.8483.41−279.953
Source linesThe number of non-empty source lines.299+119.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.549−6.823

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

Score0.721

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.300−9.586
Indentation frequencyHow rapidly indentation changes from line to line.211+6.561
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.211−4.421
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.298.922+3.769
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.100.973+0.825
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.100.97−0.611
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.063+0.334

Intercept 0.07 + feature contributions = -3.06 (log-odds).
Score = sigmoid(-3.06) = 0.045.

Score0.519
Score106
Run 1

The code is a UML notation parser for ClassifierRole, with all methods in one class. It has clear intent with extensive comments, but suffers from significant readability issues. The parseClassifierRole method is overly long (over 100 lines), with a complex token-handling loop that has several deeply nested if-else branches and repeated code blocks. The logic for handling bases is duplicated multiple times when encountering '/', ':', or ',' tokens. The code has unused variables (hasColon, hasSlash flags are assigned but never read), commented-out code, and inconsistent indentation. Method names like parseClassifierRole are descriptive, but the single giant method could be split into smaller focused methods. The code has a high cyclomatic complexity and uses labels (addBases:) for flow control, making it harder to follow. While it is logically structured, the method length and nested logic reduce its overall readability. The class-level documentation is helpful, but the implementation could use refactoring for better maintainability.

Run 2

The code is structured logically with clear class and method separation. However, the parseClassifierRole method is difficult to follow due to its length and complex branching logic. While the method maintains flat nesting with if-else chains, the token processing loop contains multiple state flags and repeated null checks that obscure the parsing flow. The action granularity is mostly acceptable, but many lines combine multiple operations. Several sections contain duplicated code (e.g., adding to bases list), and variable names like 'c', 'ns', 'it2' are terse. The Javadoc is thorough, especially the grammar description, but the method-level comments don't fully compensate for the implementation complexity. The formatNameList and trim operations in toString() show moderate clarity. The parsing error messages have inconsistent indentation and potentially incorrect message keys ('extra-test'). Overall, the code is maintainable but the parse method needs refactoring into smaller helper methods.

Run 3

The code has clear class-level documentation and logical separation of methods, which aids understanding. However, readability is significantly hindered by multiple factors: the header contains excessive license comments that bury the actual code; the tokenizer loop is deeply nested with many conditional branches, making the parsing logic hard to follow; several variables have unclear names like 's', 'c', 'd', 'b', and 'ns'; the `parseClassifierRole` method is overly long and mixes multiple responsibilities (tokenization, validation, model updates); and there is inconsistent formatting (tabs vs spaces, indentation issues). The use of labeled `continue` adds complexity. While each line generally performs one action, the overall flow is convoluted and requires careful study to understand the grammar being parsed and the model mutations performed.

Run 1

Code Structure: The class separates parsing, error reporting, and formatting, but parseClassifierRole combines token interpretation with model updates in one large method. Nesting: Several nested conditionals and loops, plus a labeled continue, increase mental effort. Clarity of intent: Grammar documentation and descriptive API calls explain the purpose, while abbreviated variables (s, cls, b, c, d), raw collections, and interacting parser flags obscure details. Code length: Repeated base-list initialization and identical error-handling blocks make parsing unnecessarily verbose; obsolete commented-out code adds clutter. Action granularity: Statements generally perform one action per line, with reasonable wrapping of longer calls. Reading flow: Execution broadly follows parsing, validation, updating, and formatting, but repeated branches, namespace resolution embedded in updates, and inconsistent indentation interrupt the flow.

Run 2

Code Structure: The class separates parsing, error reporting, and formatting, but parseClassifierRole combines token interpretation, validation, and model updates in one large method. Nesting: Multiple nested conditionals and loops, particularly base reconciliation, increase cognitive load; the labeled continue complicates control flow. Clarity of intent: Grammar documentation and descriptive API calls explain the purpose, but abbreviated variables, raw collections, boolean parsing states, and an unused parsed name obscure details. Code length: Repeated base accumulation and error construction make the implementation longer than necessary; duplicated documentation and obsolete commented code add clutter. Action granularity: Most statements perform one action per line, although chained model calls require additional interpretation. Reading flow: Parsing followed by model updates is broadly logical, and formatting is straightforward, but inconsistent indentation, repeated state handling, and mixed responsibilities interrupt the flow.

Run 3

Code Structure: The class separates parsing, error reporting, and formatting, but parseClassifierRole combines token interpretation and model updates in one large method. Nesting: Several nested conditionals and loops, plus a labeled continue, increase cognitive load. Clarity of intent: Grammar documentation and descriptive public method names help, but short variables such as cls, s, b, c, and d, raw collections, and boolean parsing states obscure details. Code length: Repeated base-list initialization, duplicate error handling, and verbose boilerplate make the implementation longer than necessary. Action granularity: Most statements perform one action per line, although chained model-access calls require additional interpretation. Reading flow: Execution generally progresses naturally from tokenization to model updates, but repeated branches, inconsistent indentation, an unresolved TODO, and labeled loop control interrupt readability.