Sample

Schnappinger/argoUML/org.argouml.cognitive.ui.ToDoByType

Human rating uses the original dataset scale.

Human2.11
Lines178

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
34.8Δ 25.9
Scalabrino0.5880–1; higher is more readable
20.5Δ 11.6
Dorn0.1770–1; higher is more readable
39.3Δ 30.4
Mi0.5770–1; higher is more readable
53.8Δ 44.9
LLOC70Logical lines; fewer is more readable
29.7Δ 20.8
DeepSeek V4 Pro7.670–20; mean of three runs
5.4Δ 3.5
GPT-6.1 Sol130–20; mean of three runs
9.4Δ 0.5
BTTF0.5020–1; higher is more readable
44.9Δ 36.0
Human2.111–4; original rating
8.9

Views

Source code

/* $Id: ToDoByType.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.cognitive.ui; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.argouml.cognitive.Designer; import org.argouml.cognitive.ToDoItem; import org.argouml.cognitive.ToDoListEvent; import org.argouml.cognitive.ToDoListListener; /** * Represents a perspective for ToDo items: grouping by type. * */ public class ToDoByType extends ToDoPerspective implements ToDoListListener { private static final Logger LOG = Logger.getLogger(ToDoByType.class.getName()); /** * The constructor. * */ public ToDoByType() { super("combobox.todo-perspective-type"); addSubTreeModel(new GoListToTypeToItem()); } //////////////////////////////////////////////////////////////// // ToDoListListener implementation /* * @see org.argouml.cognitive.ToDoListListener#toDoItemsChanged(org.argouml.cognitive.ToDoListEvent) */ public void toDoItemsChanged(ToDoListEvent tde) { LOG.log(Level.FINE, "toDoItemsChanged"); List<ToDoItem> items = tde.getToDoItemList(); Object[] path = new Object[2]; path[0] = Designer.theDesigner().getToDoList(); for (KnowledgeTypeNode ktn : KnowledgeTypeNode.getTypeList()) { String kt = ktn.getName(); path[1] = ktn; int nMatchingItems = 0; for (ToDoItem item : items) { if (!item.containsKnowledgeType(kt)) { continue; } nMatchingItems++; } if (nMatchingItems == 0) { continue; } int[] childIndices = new int[nMatchingItems]; Object[] children = new Object[nMatchingItems]; nMatchingItems = 0; for (ToDoItem item : items) { if (!item.containsKnowledgeType(kt)) { continue; } childIndices[nMatchingItems] = getIndexOfChild(ktn, item); children[nMatchingItems] = item; nMatchingItems++; } fireTreeNodesChanged(this, path, childIndices, children); } } /* * @see org.argouml.cognitive.ToDoListListener#toDoItemsAdded(org.argouml.cognitive.ToDoListEvent) */ public void toDoItemsAdded(ToDoListEvent tde) { LOG.log(Level.FINE, "toDoItemAdded"); List<ToDoItem> items = tde.getToDoItemList(); Object[] path = new Object[2]; path[0] = Designer.theDesigner().getToDoList(); for (KnowledgeTypeNode ktn : KnowledgeTypeNode.getTypeList()) { String kt = ktn.getName(); path[1] = ktn; int nMatchingItems = 0; for (ToDoItem item : items) { if (!item.containsKnowledgeType(kt)) { continue; } nMatchingItems++; } if (nMatchingItems == 0) { continue; } int[] childIndices = new int[nMatchingItems]; Object[] children = new Object[nMatchingItems]; nMatchingItems = 0; for (ToDoItem item : items) { if (!item.containsKnowledgeType(kt)) { continue; } childIndices[nMatchingItems] = getIndexOfChild(ktn, item); children[nMatchingItems] = item; nMatchingItems++; } fireTreeNodesInserted(this, path, childIndices, children); } } /* * @see org.argouml.cognitive.ToDoListListener#toDoItemsRemoved(org.argouml.cognitive.ToDoListEvent) */ public void toDoItemsRemoved(ToDoListEvent tde) { LOG.log(Level.FINE, "toDoItemRemoved"); List<ToDoItem> items = tde.getToDoItemList(); Object[] path = new Object[2]; path[0] = Designer.theDesigner().getToDoList(); for (KnowledgeTypeNode ktn : KnowledgeTypeNode.getTypeList()) { boolean anyInKT = false; String kt = ktn.getName(); for (ToDoItem item : items) { if (item.containsKnowledgeType(kt)) { anyInKT = true; } } if (!anyInKT) { continue; } LOG.log(Level.FINE, "toDoItemRemoved updating PriorityNode"); path[1] = ktn; //fireTreeNodesChanged(this, path, childIndices, children); fireTreeStructureChanged(path); } } /* * @see org.argouml.cognitive.ToDoListListener#toDoListChanged(org.argouml.cognitive.ToDoListEvent) */ public void toDoListChanged(ToDoListEvent tde) { } }

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.4492.402−148.249
Source linesThe number of non-empty source lines.178+71.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 = -75.875 (log-odds).
Score = sigmoid(-75.875) = 0.

Score0.588

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.179−5.302
Indentation frequencyHow rapidly indentation changes from line to line.126+3.621
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.177.629+2.073
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.103.38+0.864
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.103.983−0.739
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.061+0.349

Intercept 0.07 + feature contributions = -1.534 (log-odds).
Score = sigmoid(-1.534) = 0.177.

Score0.577
Score70
Run 1

The code has some positive aspects like basic structure and method separation, but suffers from major readability issues. There is significant code duplication between toDoItemsChanged and toDoItemsAdded methods, both containing nearly identical nested loops to count and collect matching items. The mixed indentation (spaces vs tabs) disrupts reading flow. Methods like toDoItemsChanged have too many nested levels and multiple actions per loop iteration, making the logic hard to follow. The variable names (ktn, kt, tde) are cryptic. Comments are sparse and one commented-out line exists (fireTreeNodesChanged). The overall intent requires significant effort to understand due to intertwined counting and collection logic across two passes over the same data.

Run 2

The code structure is acceptable with clear methods, but there is significant code duplication between `toDoItemsChanged` and `toDoItemsAdded`. Nesting is moderate (3 levels), but the duplicated loops create unnecessary length. Indentation is inconsistent (tabs vs spaces), disrupting reading flow. The intent is mostly clear—handling ToDo list events by knowledge type—but the repeated filtering logic obscures it. Action granularity is reasonable (one primary action per line), though some logical blocks could be extracted. The overall clarity is undermined by copy-pasted code, inconsistent formatting, and a lack of helper methods to consolidate the matching/filtering logic.

Run 3

The code has clear class-level structure and method separation, but the readability is undermined by several issues. The method bodies contain duplicated logic across toDoItemsChanged and toDoItemsAdded, making it unnecessarily long. Indentation is inconsistent—mixing tabs and spaces—which disrupts reading flow. The methods use deep nesting (up to four levels) and multiple actions per block, making the logic harder to follow. Variable names like 'ktn' and 'kt' are terse and lack clarity. There is dead code (commented-out fireTreeNodesChanged) and logging statements with vague messages. The overall intent is discernible but requires effort due to repetition and inconsistent formatting. Refactoring the duplicate filtering logic into a helper method, improving variable names, and standardizing indentation would significantly enhance readability.

Run 1

Code Structure: Clearly organized into a constructor and listener callbacks, but the changed and added handlers duplicate nearly all their logic. Nesting: Moderate loop-within-loop nesting remains manageable, and continue statements reduce deeper conditional nesting. Clarity of intent: Class and callback names explain the purpose, but abbreviations such as ktn, kt, and anyInKT require interpretation; the PriorityNode log message is misleading. Code length: Repeated counting and collection passes, extensive boilerplate comments, and duplicated handlers make the file longer than necessary. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Each handler follows a predictable sequence, but inconsistent indentation, resetting and reusing nMatchingItems, a commented-out call, and an unexplained empty callback interrupt readability.

Run 2

Code Structure: Listener methods are logically separated, but added and changed handlers duplicate nearly all their logic. Nesting: Moderate loop-within-loop nesting is manageable, and continue statements avoid deeper conditional blocks. Clarity of intent: Class documentation and descriptive method names explain the purpose, but abbreviations such as kt, ktn, and anyInKT require interpretation; the PriorityNode log message is misleading. Code length: Repeated filtering passes, duplicated handlers, extensive boilerplate, and a commented-out call increase reading effort. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Each handler follows a recognizable sequence, but inconsistent tab/space indentation, mutable array bookkeeping, and resetting the matching counter interrupt smooth reading.

Run 3

Code Structure: Clearly organized into a constructor and listener callbacks, but added/changed handlers duplicate substantial logic. Nesting: Moderate loop-and-condition nesting; continue statements prevent deeper branching. Clarity of intent: Class documentation and callback names convey the purpose, while abbreviations such as ktn, kt, and anyInKT require interpretation. A misleading PriorityNode log message and commented-out call add confusion. Code length: Repeated two-pass filtering, extensive boilerplate, and redundant comments make the file longer than necessary. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Each handler follows a predictable sequence, but inconsistent indentation, repeated blocks, and mutable counter reuse interrupt otherwise straightforward reading.