Sample

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

Human rating uses the original dataset scale.

Human3.05
Lines129

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
45.2Δ 13.8
Scalabrino0.6010–1; higher is more readable
23.3Δ 8.1
Dorn0.3320–1; higher is more readable
50.5Δ 19.1
Mi0.5570–1; higher is more readable
43.9Δ 12.5
LLOC35Logical lines; fewer is more readable
47.0Δ 15.7
DeepSeek V4 Pro120–20; mean of three runs
15.5Δ 15.8
GPT-6.1 Sol150–20; mean of three runs
25.7Δ 5.6
BTTF0.4690–1; higher is more readable
41.9Δ 10.6
Human3.051–4; original rating
31.4

Views

Source code

/* $Id: CrMissingOperName.java 19614 2011-07-20 12:10:13Z 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) 1996-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.Critic; import org.argouml.cognitive.Designer; import org.argouml.cognitive.ToDoItem; import org.argouml.cognitive.critics.Wizard; import org.argouml.model.Model; import org.argouml.uml.cognitive.UMLDecision; /** * A critic to detect whether an operation has a name. */ public class CrMissingOperName extends CrUML { /** * The constructor. */ public CrMissingOperName() { setupHeadAndDesc(); addSupportedDecision(UMLDecision.NAMING); setKnowledgeTypes(Critic.KT_SYNTAX); addTrigger("name"); } /* * @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().isAOperation(dm))) { return NO_PROBLEM; } Object oper = dm; String myName = Model.getFacade().getName(oper); if (myName == null || myName.equals("")) { return PROBLEM_FOUND; } if (myName.length() == 0) { return PROBLEM_FOUND; } return NO_PROBLEM; } /* * @see org.argouml.cognitive.critics.Critic#initWizard( * org.argouml.cognitive.ui.Wizard) */ @Override public void initWizard(Wizard w) { if (w instanceof WizMEName) { ToDoItem item = (ToDoItem) w.getToDoItem(); Object me = item.getOffenders().get(0); String ins = super.getInstructions(); String sug = super.getDefaultSuggestion(); if (Model.getFacade().isAOperation(me)) { Object a = me; int count = 1; if (Model.getFacade().getOwner(a) != null) { count = Model.getFacade().getFeatures( Model.getFacade().getOwner(a)).size(); } sug = "oper" + (count + 1); } ((WizMEName) w).setInstructions(ins); ((WizMEName) w).setSuggestion(sug); } } /* * @see org.argouml.cognitive.critics.Critic#getWizardClass(org.argouml.cognitive.ToDoItem) */ @Override public Class getWizardClass(ToDoItem item) { return WizMEName.class; } /* * @see org.argouml.uml.cognitive.critics.CrUML#getCriticizedDesignMaterials() */ @Override public Set<Object> getCriticizedDesignMaterials() { Set<Object> ret = new HashSet<Object>(); ret.add(Model.getMetaTypes().getOperation()); return ret; } }

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.2850.623−94.071
Source linesThe number of non-empty source lines.129+51.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.5.268−7.903

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

Score0.601

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.130−3.567
Indentation frequencyHow rapidly indentation changes from line to line.80+2.03
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.80−1.415
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.128.885+1.392
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.94.969+0.728
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.422
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.94.992−0.358

Intercept 0.07 + feature contributions = -0.698 (log-odds).
Score = sigmoid(-0.698) = 0.332.

Score0.557
Score35
Run 1

The code has a mostly logical structure and clear purpose: it defines a critic to flag operations missing names. The class is short and method lengths are reasonable. However, readability is hurt by inconsistent indentation and brace style, especially in predicate2 and initWizard, where mixed tabs and spaces create visual clutter. Nesting is moderate, with two-level ifs in initWizard making the flow slightly tangled. Magical numbers or magic strings like "oper" add minor ambiguity, but they are limited. Action granularity is generally fine, one logical action per line, but some lines like Model.getFacade().getFeatures(...).size() chain multiple calls which could be split for clarity. Reading flow is interrupted by inconsistent formatting and redundant checks (e.g., myName == null and length == 0). Overall, the code is understandable for a developer familiar with the framework but needs polish for consistency.

Run 2

The code structure is logical, with a clear class definition and overridden methods, but readability is significantly hampered by several issues. The licensing header is excessively long and disrupts the reading flow before reaching the actual code. Nesting is mostly flat, which is good, but the predicate2 method contains redundant checks (myName == null || myName.equals("") and myName.length() == 0) that obscure intent. Action granularity is inconsistent: some lines combine multiple actions, while others are well-separated. The clarity of intent suffers from generic variable names like 'a', 'me', and 'dm', and the initWizard method mixes logic with type casting without clear separation. Code length is reasonable, but the redundant conditionals and verbose setup make it unnecessarily longer than needed. The reading flow is natural in method order but is disrupted by outdated comments and inconsistent indentation style.

Run 3

The code is generally readable but has some issues. The structure is logical, with clear separation of methods and overrides, and the class has a single responsibility. Nesting is mostly flat, though initWizard has a few levels. The intent is fairly clear from method names and comments. However, there are readability problems: inconsistent indentation (tabs vs spaces), redundant checks in predicate2 (myName == null, myName.equals(""), and myName.length() == 0 all test the same condition), and some unnecessary local variable assignments (e.g., Object oper = dm; Object a = me;). Action granularity is acceptable but could be improved. The long license header consumes significant space before the actual code. Overall, the code is understandable but would benefit from cleaner formatting, simpler naming, and elimination of redundant logic for better clarity.

Run 1

Code Structure: Methods logically separate configuration, validation, wizard initialization, and metadata. Nesting: Validation uses clear early returns, but wizard initialization has three nested conditionals. Clarity of intent: The class documentation and API calls convey its purpose; abbreviated variables such as dm, me, ins, and sug obscure details. Code length: Methods are short, but duplicate empty-name checks, unnecessary aliases, and extensive boilerplate add clutter. Action granularity: Statements generally perform one action per line, although chained facade calls require extra parsing. Reading flow: Execution is straightforward, but inconsistent tab/space indentation and verbose framework comments interrupt visual consistency.

Run 2

Code Structure: Methods separate initialization, validation, wizard setup, and supported model types logically. Nesting: Validation uses clear early returns, but wizard setup has three levels of conditional nesting. Clarity of intent: The class documentation and method calls convey the purpose, while abbreviated names such as dm, me, ins, sug, and a obscure details. Code length: The implementation is reasonably short, but duplicate empty-name checks, unnecessary object aliases, and a redundant cast add clutter; the lengthy license header delays reaching the implementation. Action granularity: Statements generally perform one action per line, although chained facade calls require extra parsing. Reading flow: Method ordering is natural and control flow is straightforward, but inconsistent indentation and repetitive boilerplate comments interrupt scanning.

Run 3

Code Structure: Methods are logically separated into initialization, name validation, wizard configuration, and metadata retrieval. Nesting: Validation uses clear early returns, but wizard initialization reaches three conditional levels. Clarity of intent: The class documentation and API calls establish the purpose, while abbreviated variables such as dm, me, a, ins, and sug obscure details. Code length: Methods are reasonably short, but redundant empty-name checks, unnecessary object aliases, and extensive boilerplate comments add reading overhead. Action granularity: Statements generally perform one action per line, although chained facade calls require extra parsing. Reading flow: Method ordering and straightforward control flow are easy to follow; inconsistent tab/space indentation and repeated casts mildly disrupt readability.