Sample

Schnappinger/junit4/junit.framework.ComparisonCompactor

Human rating uses the original dataset scale.

Human3
Lines77

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
37.8Δ 8.4
Scalabrino0.4880–1; higher is more readable
8.6Δ 20.8
Dorn0.010–1; higher is more readable
19.8Δ 9.6
Mi0.0780–1; higher is more readable
9.2Δ 20.1
LLOC47Logical lines; fewer is more readable
40.3Δ 10.9
DeepSeek V4 Pro140–20; mean of three runs
29.9Δ 0.5
GPT-6.1 Sol160–20; mean of three runs
38.9Δ 9.6
BTTF0.2620–1; higher is more readable
17.8Δ 11.6
Human31–4; original rating
29.4

Views

Source code

package junit.framework; public class ComparisonCompactor { private static final String ELLIPSIS = "..."; private static final String DELTA_END = "]"; private static final String DELTA_START = "["; private int fContextLength; private String fExpected; private String fActual; private int fPrefix; private int fSuffix; public ComparisonCompactor(int contextLength, String expected, String actual) { fContextLength = contextLength; fExpected = expected; fActual = actual; } public String compact(String message) { if (fExpected == null || fActual == null || areStringsEqual()) { return Assert.format(message, fExpected, fActual); } findCommonPrefix(); findCommonSuffix(); String expected = compactString(fExpected); String actual = compactString(fActual); return Assert.format(message, expected, actual); } private String compactString(String source) { String result = DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END; if (fPrefix > 0) { result = computeCommonPrefix() + result; } if (fSuffix > 0) { result = result + computeCommonSuffix(); } return result; } private void findCommonPrefix() { fPrefix = 0; int end = Math.min(fExpected.length(), fActual.length()); for (; fPrefix < end; fPrefix++) { if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix)) { break; } } } private void findCommonSuffix() { int expectedSuffix = fExpected.length() - 1; int actualSuffix = fActual.length() - 1; for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) { if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix)) { break; } } fSuffix = fExpected.length() - expectedSuffix; } private String computeCommonPrefix() { return (fPrefix > fContextLength ? ELLIPSIS : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix); } private String computeCommonSuffix() { int end = Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length()); return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : ""); } private boolean areStringsEqual() { return fExpected.equals(fActual); } }

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.3067.276−101.22
Source linesThe number of non-empty source lines.77+30.8
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.61−6.915

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

Score0.488

Feature contributions

FeatureValueContribution
(log-odds)
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.164.949−3.321
Indentation frequencyHow rapidly indentation changes from line to line.77+1.926
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.78−1.725
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.77−1.346
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.76.687+0.662
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.107−0.095

Intercept 0.07 + feature contributions = -4.634 (log-odds).
Score = sigmoid(-4.634) = 0.01.

Score0.078
Score47
Run 1

The code is generally readable with clear method names and logical separation of concerns. Methods have single responsibilities, and the structure follows a natural top-down flow. Nesting is minimal, which is positive. However, several issues reduce clarity: field names use the 'f' prefix (Hungarian-like notation), which is outdated and harms readability. Some expressions are dense, especially in computeCommonSuffix and compactString, where string concatenation and conditional logic are combined on single lines. The findCommonSuffix loop condition is non-intuitive, making the logic harder to follow. The code is concise but some expressions are overly compact, requiring careful mental parsing. Overall, the code is maintainable but would benefit from clearer variable names and breaking up complex expressions.

Run 2

The code demonstrates reasonable organization with clear method separation and a single responsibility per method. The fields use a consistent naming convention but the 'f' prefix is unfamiliar and reduces readability. Nesting is minimal, which is good. However, the intent of some methods, particularly computeCommonSuffix and compactString, is difficult to grasp due to complex string manipulation expressions. The code is relatively concise but sometimes at the cost of clarity—several lines pack multiple operations (e.g., the for-loop conditions). Action granularity is mostly one action per line, but some lines combine multiple responsibilities. Reading flow is somewhat natural but interrupted by mental effort to parse index arithmetic and the non-standard field naming. Overall, it is readable for experienced Java developers, but not immediately clear to a broader audience.

Run 3

The code has a logical structure and clear naming conventions (fExpected, fActual, fPrefix, fSuffix) but suffers from dated 'f' field prefixes which slightly hurt readability for modern Java developers. The methods are reasonably sized and separation of concerns is adequate, with distinct steps for finding prefix/suffix and building the compacted string. Nesting is minimal, with only two levels (method -> if). The main readability problems are the confusing index arithmetic in findCommonSuffix() and computeCommonSuffix() — expressions like 'fExpected.length() - fSuffix + 1' appear repeatedly with no explanation, requiring careful mental tracking. The action granularity is good, mostly one operation per line. Reading flow is natural in compact() but becomes fragmented due to the obscure offset computations. Overall structure is sound but mathematical complexity drags clarity down.

Run 1

Code Structure: Well organized into small, focused methods, although shared mutable prefix/suffix state creates implicit dependencies. Nesting: Shallow loops and conditionals, with an early return simplifying the main path. Clarity of intent: Descriptive method names and named delimiters explain the purpose, but f-prefixed fields and the unconventional suffix offset require interpretation. Code length: Concise overall; long substring and ternary expressions make boundary calculations harder to understand. Action granularity: Most lines perform one action, though the suffix loop updates two indices and some expressions combine several calculations. Reading flow: compact() presents a natural sequence from validation to comparison and formatting; helper methods support that flow, but repeated suffix arithmetic and state-dependent calls interrupt effortless reading.

Run 2

Code Structure: Well organized into small, focused methods, although shared mutable fields create implicit dependencies between calls. Nesting: Shallow, with an early return and simple loop conditions. Clarity of intent: Descriptive method names and constants convey the purpose, but f-prefixed fields and the unconventional suffix offset require careful interpretation. Code length: Generally concise, though long substring expressions and repeated suffix arithmetic reduce readability. Action granularity: Most statements perform one action; the suffix loop updates two indices, and some expressions combine several calculations. Reading flow: compact() presents a natural sequence from validation through comparison to formatting, but understanding the boundary calculations requires tracing state across helper methods.

Run 3

Code Structure: Well-organized into small, focused methods, although shared mutable prefix/suffix state creates implicit dependencies. Nesting: Shallow, with an early return and simple loop conditions. Clarity of intent: Method names and constants clearly communicate string comparison and compaction; however, f-prefixed fields and the unconventional suffix offset require extra interpretation. Code length: Generally concise, though repeated suffix arithmetic could be extracted into a named variable. Action granularity: Most lines perform one action, but the suffix loop updates two indices and some expressions combine several calculations. Reading flow: compact() presents a natural sequence from validation through comparison to formatting. Long substring expressions and inline ternaries in the context helpers interrupt otherwise smooth reading.