Sample

Schnappinger/argoUML/org.argouml.util.PredicateType

Human rating uses the original dataset scale.

Human3.96
Lines119

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
50.2Δ 26.9
Scalabrino0.7760–1; higher is more readable
57.2Δ 19.9
Dorn0.4890–1; higher is more readable
59.7Δ 17.3
Mi0.5750–1; higher is more readable
52.5Δ 24.6
LLOC48Logical lines; fewer is more readable
39.9Δ 37.1
DeepSeek V4 Pro150–20; mean of three runs
38.0Δ 39.1
GPT-6.1 Sol170–20; mean of three runs
55.3Δ 21.8
BTTF0.6310–1; higher is more readable
63.4Δ 13.7
Human3.961–4; original rating
77.1

Views

Source code

/* $Id: PredicateType.java 17887 2010-01-12 21:17:18Z 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: * tfmorris ***************************************************************************** * * Some portions of this file was previously release using the BSD License: */ // Copyright (c) 1996-2008 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.util; /** * A predicate which matches UML element types. */ public class PredicateType implements Predicate { private Class patterns[]; private int patternCount; private String printString = null; protected PredicateType(Class pats[]) { this(pats, pats.length); } protected PredicateType(Class pats[], int numPats) { patterns = pats; patternCount = numPats; } public static PredicateType create() { return new PredicateType(null, 0); } public static PredicateType create(Class c0) { Class classes[] = new Class[1]; classes[0] = c0; return new PredicateType(classes); } public static PredicateType create(Class c0, Class c1) { Class classes[] = new Class[2]; classes[0] = c0; classes[1] = c1; return new PredicateType(classes); } public static PredicateType create(Class c0, Class c1, Class c2) { Class classes[] = new Class[3]; classes[0] = c0; classes[1] = c1; classes[2] = c2; return new PredicateType(classes); } public boolean evaluate(Object o) { if (patternCount == 0) { return true; } for (int i = 0; i < patternCount; i++) { if (patterns[i].isInstance(o)) { return true; } } return false; } @Override public String toString() { if (printString != null) { return printString; } if (patternCount == 0) { return "Any Type"; } String res = ""; for (int i = 0; i < patternCount; i++) { String clsName = patterns[i].getName(); int lastDot = clsName.lastIndexOf("."); clsName = clsName.substring(lastDot + 1); res += clsName; if (i < patternCount - 1) { res += ", "; } } printString = res; return res; } }

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.2395.462−79.05
Source linesThe number of non-empty source lines.119+47.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.965−7.448

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

Score0.776

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.120−3.212
Indentation frequencyHow rapidly indentation changes from line to line.82+2.099
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.82−1.461
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.118.937+1.253
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.049+0.461
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.542+0.382
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.77.967+0.363

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

Score0.575
Score48
Run 1

The code is generally readable with clear structure, flat methods, and one action per line. Class purpose is well-documented and method names clearly convey intent. The constructors and factory methods are logically organized. However, there are minor readability issues: the generic `Class patterns[]` uses raw types instead of `Class<?>[]`, and naming is slightly inconsistent (`pats` in constructors vs `classes` in factory methods). The `toString()` method caches its result but modifies `printString` through side effects, which slightly obscures the flow. Overloaded `create()` methods with 0-3 parameters are repetitive but acceptable for the era and degree of simplicity. Overall, the structure is clean, nesting is minimal, and the logic is easy to follow.

Run 2

The code is generally well-structured, with clear separation of constructors, factory methods, and the evaluate/toString logic. It uses minimal nesting—only a couple of one-level loops and conditionals—so it is fairly flat and easy to follow. Intent is clear: the class models a type predicate that can match multiple classes. The factory method overloads (create with 0 to 3 Class arguments) are repetitive but straightforward. Action granularity is mostly good, though array filling in the factory methods could be compressed. Reading flow is natural, but the long license header adds unnecessary noise before the actual code and slightly hurts readability. Additionally, the toString method builds a string with concatenation instead of using a StringBuilder, which is not a readability issue per se but could be improved. Overall, the code is concise, with no deep nesting or ambiguous logic, though minor repetition and the verbose header keep it from being exemplary.

Run 3

The code is reasonably readable but has several issues. The class structure is logical, with clear static factory methods and a single evaluate method. Nesting is minimal and the flow is natural. However, the code uses raw Class types instead of generics (Class<?>[]), which reduces type safety and clarity. The toString() method is unnecessarily long and does multiple actions per line: string manipulation, substring, concatenation, and caching. The repeated factory methods create(), create(c0), create(c1), create(c2) are verbose and could be replaced with varargs, reducing code length significantly. The printString caching works but makes the toString flow harder to follow. The copyright header is excessively long relative to the actual code, though this is not fault of the class itself. Action granularity in toString is poor, with multiple operations crammed into single lines. Overall, the intent is clear and structure is flat, but verbosity and lack of modern Java features reduce readability.

Run 1

Code Structure: Fields, constructors, factory methods, evaluation, and string formatting are logically organized into focused methods. Nesting: Shallow loops and conditionals, supported by early returns, keep control flow easy to follow. Clarity of intent: The class documentation and isInstance check explain its purpose, but abbreviated names such as pats, c0, o, and res reduce clarity; the match-any behavior for zero patterns is not documented. Code length: Methods are short, though repeated factory overloads and explicit array assignments add avoidable verbosity. Action granularity: Statements generally perform one action per line, making operations easy to track. Reading flow: Consistent formatting and straightforward method ordering support natural reading, while the lengthy license header, older array declaration syntax, and string-building details introduce minor friction.

Run 2

Code Structure: Fields, constructors, factory methods, evaluation, and string formatting are logically grouped. Nesting: Shallow loops and conditionals, with early returns, keep complexity low. Clarity of intent: The class documentation and isInstance check clearly convey type matching, though abbreviated names such as pats, c0, o, and res reduce clarity; the match-any behavior for zero patterns is not explicitly documented. Code length: Methods are short, but repeated factory implementations and verbose array initialization add unnecessary length. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Consistent formatting and straightforward control flow support natural reading, although the lengthy license header delays reaching the implementation and legacy array declaration syntax is less conventional.

Run 3

Code Structure: Fields, constructors, factory methods, evaluation, and string formatting are logically grouped. Nesting: Shallow loops and conditionals, with early returns keeping control flow simple. Clarity of intent: The class documentation and method names explain the predicate's purpose, although abbreviated names such as pats, c0, and res reduce clarity; the match-any behavior for zero patterns is not documented. Code length: Methods are short, but repeated factory overloads and array assignments add avoidable verbosity. The extensive license header delays reaching the implementation. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Consistent formatting and straightforward method ordering support natural reading, though legacy array syntax and raw Class types make the code feel dated.