Sample

Schnappinger/argoUML/org.argouml.util.PredicateStringMatch

Human rating uses the original dataset scale.

Human3.97
Lines108

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
50.5Δ 35.0
Scalabrino0.4760–1; higher is more readable
7.5Δ 77.9
Dorn0.5090–1; higher is more readable
61.4Δ 24.1
Mi0.5670–1; higher is more readable
49.8Δ 35.6
LLOC39Logical lines; fewer is more readable
43.9Δ 41.6
DeepSeek V4 Pro15.330–20; mean of three runs
41.3Δ 44.2
GPT-6.1 Sol15.330–20; mean of three runs
30.7Δ 54.8
BTTF0.5540–1; higher is more readable
51.2Δ 34.3
Human3.971–4; original rating
85.5

Views

Source code

/* $Id: PredicateStringMatch.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; import java.util.StringTokenizer; /** * Predicate to match strings/substrings. It only supports simple * wildcard processing, not full regex style matching. */ public class PredicateStringMatch implements Predicate { public static int MAX_PATS = 10; private String patterns[]; private int patternCount; protected PredicateStringMatch(String matchPatterns[], int count) { patterns = matchPatterns; patternCount = count; } public static Predicate create(String pattern) { pattern = pattern.trim(); if ("*".equals(pattern) || "".equals(pattern)) { return PredicateTrue.getInstance(); } String pats[] = new String[MAX_PATS]; int count = 0; if (pattern.startsWith("*")) { pats[count++] = ""; } StringTokenizer st = new StringTokenizer(pattern, "*"); while (st.hasMoreElements()) { String token = st.nextToken(); pats[count++] = token; } if (pattern.endsWith("*")) { pats[count++] = ""; } if (count == 0) { return PredicateTrue.getInstance(); } if (count == 1) { return new PredicateEquals(pats[0]); } return new PredicateStringMatch(pats, count); } public boolean evaluate(Object o) { if (o == null) { return false; } String target = o.toString(); if (!target.startsWith(patterns[0])) { return false; } if (!target.endsWith(patterns[patternCount - 1])) { return false; } for (String pattern : patterns) { int index = (target + "*").indexOf(pattern); if (index == -1) { return false; } target = target.substring(index + pattern.length()); } return true; } }

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.2224.262−73.401
Source linesThe number of non-empty source lines.108+43.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.01−7.514

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

Score0.476

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.109−2.823
Indentation frequencyHow rapidly indentation changes from line to line.70+1.684
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.70−1.185
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.107.797+1.097
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.05+0.456
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.018+0.374
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.972+0.363

Intercept 0.07 + feature contributions = 0.035 (log-odds).
Score = sigmoid(0.035) = 0.509.

Score0.567
Score39
Run 1

The code is generally well-structured and readable. The class has a clear purpose as a string-matching predicate, and methods are concise. The `create` factory method uses a flat, if-conditional style with low nesting, and the `evaluate` method has a clear flow: null check, prefix/suffix checks, then a loop. Action granularity is appropriate, mostly one action per line. However, readability is slightly reduced by the long copyright header (not core logic), the use of raw arrays and a separate count (where a collection would be clearer), and the somewhat cryptic `(target + "*").indexOf(pattern)` trick, which works but requires extra thought. Variable names like `pats`, `st`, and `o` are not as descriptive as they could be. Overall, the code is maintainable but could be more self-documenting.

Run 2

The code is logically structured with clear methods and reasonable naming, but readability suffers from several issues. The create() method is relatively flat and each line tends to perform one action, which is good. However, the evaluate() method uses a non-obvious algorithm—appending '*' to the target and repeatedly searching for patterns—making intent difficult to follow. The constructor is protected while create() is static, which may confuse readers about instantiation flow. Long license headers add bulk before the actual code. Pattern matching logic relies on implicit ordering and substring search rather than a straightforward wildcard parser, reducing clarity. Overall, the class is maintainable but requires domain knowledge to fully understand its matching behavior, keeping it from being highly readable.

Run 3

The code is generally well-structured and readable. The class has a clear purpose and follows a logical organization with a constructor, factory method, and evaluation method. Nesting is minimal, with only a single level in the evaluate method. Variable and method names clearly communicate intent. The code is reasonably concise, though the license header adds significant length. Each line performs a single action, contributing to clean granularity. Reading flow is natural, with the factory method handling edge cases before creating instances. Minor deductions: the evaluate method's loop logic is slightly subtle (e.g., appending '*' to target during indexOf), and the constructor is package-private while the factory method is public, which could confuse readers about instantiation intent. Overall, the code is maintainable and understandable.

Run 1

Code Structure: The class is logically organized into state, construction, a factory method, and evaluation. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: The class documentation and method names convey wildcard matching, but empty-string boundary markers, the appended '*' during evaluation, and iterating the entire array rather than patternCount obscure implementation intent. Code length: The implementation is concise; lengthy license notices add visual overhead but are separate from the logic. Action granularity: Most lines perform one action, although pats[count++] combines assignment and counter mutation. Reading flow: Formatting and sequential checks provide a natural progression, but abbreviated names such as pats and st, unexplained MAX_PATS, and the implicit array assumptions require extra interpretation.

Run 2

Code Structure: The class separates predicate creation from evaluation, with logically grouped checks. Nesting: Shallow loops and early returns keep control flow easy to follow. Clarity of intent: The class documentation and method names explain wildcard matching, but abbreviated names such as pats and st, empty-string boundary markers, and the unexplained target + "*" expression obscure details. Iterating over the entire patterns array rather than patternCount also makes the handling of unused entries confusing. Code length: The implementation is compact, although the extensive license header delays access to the relevant code. Action granularity: Most lines perform one action; assignments containing count++ combine storage and counter updates. Reading flow: Creation proceeds naturally from normalization through tokenization to predicate selection, and evaluation proceeds through boundary checks and sequential matching. Overall, readable organization is weakened by implicit matching conventions and unclear array assumptions.

Run 3

Code Structure: Clearly separates pattern construction from evaluation, with logically grouped checks. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Class documentation and method names explain wildcard matching, but abbreviated names such as pats and st, empty-string boundary markers, and the unexplained target + "*" expression obscure details. Evaluation iterates over the entire allocated array rather than patternCount, making unused entries confusing and potentially erroneous. Code length: Implementation is compact, although the extensive license header delays reaching the relevant logic. Action granularity: Most lines perform one action; count++ within array assignments slightly combines responsibilities. Reading flow: Formatting and sequential checks are natural, but understanding token handling and destructive target updates requires tracing the algorithm.