Sample

Schnappinger/argoUML/org.argouml.uml.cognitive.critics.CrInvalidForkTriggerOrGuard

Human rating uses the original dataset scale.

Human3
Lines123

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
45.8Δ 16.8
Scalabrino0.480–1; higher is more readable
7.9Δ 21.2
Dorn0.4120–1; higher is more readable
56.1Δ 27.1
Mi0.5360–1; higher is more readable
38.6Δ 9.6
LLOC29Logical lines; fewer is more readable
50.0Δ 21.0
DeepSeek V4 Pro120–20; mean of three runs
15.5Δ 13.5
GPT-6.1 Sol150–20; mean of three runs
25.7Δ 3.3
BTTF0.4710–1; higher is more readable
42.2Δ 13.2
Human31–4; original rating
29.0

Views

Source code

/* $Id: CrInvalidForkTriggerOrGuard.java 19577 2011-06-22 20:37:05Z linus $ ***************************************************************************** * Copyright (c) 2009 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: * maurelio1234 ***************************************************************************** * * Some portions of this file was previously release using the BSD License: */ // Copyright (c) 2003-2007 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.cognitive.critics; import java.util.HashSet; import java.util.Set; import org.argouml.cognitive.Designer; import org.argouml.model.Model; import org.argouml.uml.cognitive.UMLDecision; /** * UML 1.5 Well-formedness rule [1] for Transition, to remove * a trigger or guard from fork outgoing transition. * * Well-formedness rule [1] for Transition. See page 139 of UML 1.4 * Semantics. OMG document UML 1.4.2 formal/04-07-02. * * @author pepargouml@yahoo.es */ public class CrInvalidForkTriggerOrGuard extends CrUML { /** * The constructor. */ public CrInvalidForkTriggerOrGuard() { setupHeadAndDesc(); addSupportedDecision(UMLDecision.STATE_MACHINES); addTrigger("trigger"); addTrigger("guard"); } /* * @see org.argouml.uml.cognitive.critics.CrUML#predicate2(java.lang.Object, * org.argouml.cognitive.Designer) */ @Override public boolean predicate2(Object dm, Designer dsgr) { if (!(Model.getFacade().isATransition(dm))) { return NO_PROBLEM; } Object tr = dm; Object t = Model.getFacade().getTrigger(tr); Object g = Model.getFacade().getGuard(tr); Object sv = Model.getFacade().getSource(tr); if (!(Model.getFacade().isAPseudostate(sv))) { return NO_PROBLEM; } Object k = Model.getFacade().getKind(sv); if (!Model.getFacade(). equalsPseudostateKind(k, Model.getPseudostateKind().getFork())) { return NO_PROBLEM; } boolean hasTrigger = (t != null && Model.getFacade().getName(t) != null && Model.getFacade().getName(t).length() > 0); if (hasTrigger) { return PROBLEM_FOUND; } boolean noGuard = (g == null || Model.getFacade().getExpression(g) == null || Model.getFacade().getBody(Model.getFacade() .getExpression(g)) == null || Model.getFacade().getBody(Model.getFacade() .getExpression(g)).toString().length() == 0); if (!noGuard) { return PROBLEM_FOUND; } return NO_PROBLEM; } /* * @see org.argouml.uml.cognitive.critics.CrUML#getCriticizedDesignMaterials() */ @Override public Set<Object> getCriticizedDesignMaterials() { Set<Object> ret = new HashSet<Object>(); ret.add(Model.getMetaTypes().getTransition()); return ret; } /** * The UID. */ private static final long serialVersionUID = -713044875133409390L; }

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.2712.961−89.528
Source linesThe number of non-empty source lines.123+49.2
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.13−7.695

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

Score0.48

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.124−3.354
Indentation frequencyHow rapidly indentation changes from line to line.71+1.719
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.122.952+1.309
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.71−1.208
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.80+0.486
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.428
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.81.935+0.195

Intercept 0.07 + feature contributions = -0.356 (log-odds).
Score = sigmoid(-0.356) = 0.412.

Score0.536
Score29
Run 1

The code is generally readable but has some issues. The structure is logical - constructor, predicate method, and helper method - with clear separation. Variable naming is poor (dm, tr, t, g, sv, k) which hurts clarity of intent. The predicate2 method has moderate nesting and some awkward line breaks that disrupt reading flow. Action granularity is mostly good with one operation per line, though the chained method calls in noGuard are complex. The guard condition checking is verbose and could be extracted to a helper method for better readability. Comments are helpful where present. The line breaks in method chaining (Model.getFacade().equalsPseudostateKind...) are awkward. Overall, the code is understandable but could benefit from better variable names and cleaner conditional logic.

Run 2

The code is generally well-structured and readable. It has clear separation of concerns, good method length, and mostly one action per line. The class has a clear purpose with a descriptive name and Javadoc explaining the UML rule being enforced. However, the predicate2 method contains some deeply nested boolean expressions (particularly the guard/noGuard checks) that hurt readability. The equalsPseudostateKind call is awkwardly line-broken, interrupting visual flow. Some variables have single-letter names (t, g, sv, k) which reduces clarity despite reasonable contextual usage. The boolean logic for 'noGuard' could be extracted into a helper method. The overall structure is fine, but the complex conditional expressions would benefit from refactoring into smaller well-named methods.

Run 3

The code has clear intent with a well-defined purpose and is logically organized with setup, predicate, and materials retrieval. However, readability suffers from several issues: the method 'predicate2' lacks explanatory documentation for its logic, and the multi-line method chaining for guard validation in 'noGuard' is visually complex. The code is not deeply nested, but it uses early returns effectively, which is good. Action granularity is mostly one action per line, but the 'noGuard' expression breaks this pattern with a long, multi-line boolean expression. The reading flow is somewhat natural, but the sudden switch from straightforward checks to the complex 'noGuard' expression creates a jarring transition. The class is relatively concise, but the absence of comments explaining the 'noGuard' logic and the scattered placement of the serialVersionUID field at the end detract from overall clarity.

Run 1

Code Structure: The class is logically organized into initialization, validation, and metadata methods. Nesting: Early returns keep control flow flat and easy to follow. Clarity of intent: The class name and documentation explain the rule, but abbreviated variables such as tr, t, g, sv, and k obscure meaning; noGuard also introduces a negated condition. Code length: Implementation is reasonably concise, though repeated facade calls and lengthy boilerplate add reading overhead. Action granularity: Most statements perform one action, but the guard check combines several chained calls and conditions into a dense expression. Reading flow: Validation progresses naturally from transition type to fork source to trigger and guard checks, although awkward line wrapping and repeated expression retrieval interrupt readability.

Run 2

Code Structure: Well-organized class with separate constructor, validation method, and material-selection method. Nesting: Early returns keep control flow flat and easy to follow. Clarity of intent: Class documentation and descriptive boolean names explain the validation purpose, but abbreviated variables such as tr, t, g, sv, and k obscure details; noGuard also introduces negative logic. Code length: Implementation is reasonably concise, though repeated facade calls and the extensive license header increase reading effort. Action granularity: Generally one operation per statement, but the guard check combines several chained calls and null checks into a dense expression. Reading flow: Validation progresses logically from transition type to source kind to trigger and guard checks, although awkward line wrapping and inconsistent indentation interrupt the flow.

Run 3

Code Structure: The class is logically organized into initialization, validation, and metadata methods. Nesting: Early returns keep control flow flat and easy to follow. Clarity of intent: The class name and documentation explain the UML rule, but abbreviated variables such as tr, t, g, sv, and k obscure details; the negative noGuard flag adds mental overhead. Code length: Implementation is reasonably concise, though repeated facade calls and the lengthy license header increase reading effort. Action granularity: Statements generally perform one action per line, but the guard condition combines several checks with repeated expression retrieval. Reading flow: Validation proceeds naturally from transition type to fork source to trigger and guard checks, although awkward method-chain wrapping and inconsistent indentation interrupt readability.