Sample

int-d04329992a89-I13

Lower every eligible classic and enhanced for loop to a while loop

Matched original source

Lines53

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7790–1; higher is more readable
Dorn0.3930–1; higher is more readable
Mi0.530–1; higher is more readable
LLOC24Logical lines; fewer is more readable
DeepSeek V4 Pro11.670–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.6320–1; higher is more readable

Views

Source code

package org.springframework.cglib.transform; import org.springframework.asm.ClassVisitor; import org.springframework.asm.MethodVisitor; import org.springframework.cglib.core.ClassTransformer; public class ClassTransformerChain extends AbstractClassTransformer { private ClassTransformer[] chain; public ClassTransformerChain(ClassTransformer[] chain) { this.chain = chain.clone(); } @Override public void setTarget(ClassVisitor v) { super.setTarget(chain[0]); ClassVisitor next = v; { int i = chain.length - 1; while (i >= 0) { chain[i].setTarget(next); next = chain[i]; i--; } } } @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { return cv.visitMethod(access, name, desc, signature, exceptions); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ClassTransformerChain{"); { int i = 0; while (i < chain.length) { if (i > 0) { sb.append(", "); } sb.append(chain[i].toString()); i++; } } sb.append("}"); return sb.toString(); } }

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.1577.587−52.06
Source linesThe number of non-empty source lines.53+21.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.4.202−6.303

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

Score0.779

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.53+1.096
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.54−0.876
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.53−0.795
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.72.944+0.576
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.52.811+0.328
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.1−0.03

Intercept 0.07 + feature contributions = -0.435 (log-odds).
Score = sigmoid(-0.435) = 0.393.

Score0.53
Score24
Run 1

The code has significant readability issues. The setTarget method uses an unnecessary block scope and reverses the chain in a way that makes the logic difficult to follow. The visitMethod override is redundant, simply delegating to the parent without adding value. The toString method suffers from similar problems with unnecessary block scoping, manual loop control, and inefficient string concatenation. Formatting is inconsistent with mixed indentation (tabs vs spaces). While the class structure is recognizable and the intent is somewhat clear, the implementation obscures the logic rather than illuminating it. Better approaches would include using enhanced for loops, StringBuilder consistently, removing unnecessary scoping blocks, and eliminating redundant method overrides. The code is functional but requires careful analysis to understand what should be straightforward transformer chaining and string building operations.

Run 2

The code has a clear class purpose and method separation, but readability suffers from several issues. The setTarget method contains an unnecessary block scope around the loop, and its logic for chaining transformers is convoluted—it positions chain[0] strangely and then iterates backward, making intent unclear. The while loops in setTarget and toString could be simpler for-each or forward loops; the manual index management reduces clarity. Indentation is inconsistent (mixed tabs/spaces, misaligned braces), harming reading flow. The visitMethod is straightforward but almost trivial. toString's block scope and manual comma handling add noise. Overall, the code is readable but not highly polished; it works but requires effort to understand the transformer chain setup. A cleaner forward loop or explanation would improve clarity.

Run 3

The code is fairly readable but has several inconsistencies. The class has a clear purpose (chaining class transformers) and actions are mostly one per line. However, the structure has confusing elements: unnecessary standalone blocks with while loops break natural reading flow, and indentation is inconsistent (tabs/spaces mixed). The setTarget method's logic, while not deeply nested, is non-intuitive with its reverse iteration. The visitMethod override simply delegates and could be omitted. The toString method is straightforward but uses a manual loop instead of simpler alternatives. Overall, the intent is understandable but the formatting inconsistencies and redundant constructs reduce readability.

Run 1

Code Structure: The constructor, target wiring, method delegation, and string representation are logically separated. Nesting: Depth is modest, but redundant scope blocks around the loops add unnecessary nesting. Clarity of intent: Class and method names communicate their roles, though reverse-order chain wiring requires some thought and terse names such as v and cv reduce clarity. Code length: Generally concise, but conventional for loops would simplify manual index initialization and updates. Action granularity: Each statement performs a single action, making individual operations easy to follow. Reading flow: Method order is natural, but inconsistent tabs, spaces, and indentation disrupt visual consistency.

Run 2

Code Structure: Methods are logically separated into construction, chain configuration, delegation, and string formatting. Nesting: Generally shallow, but unnecessary block scopes around loops add indentation, and toString includes a nested conditional. Clarity of intent: Class and method names communicate purpose; reverse traversal in setTarget is understandable but requires tracing how transformers connect. Code length: Compact overall, though conventional for loops would reduce loop-control boilerplate. Action granularity: Each statement performs one action, making individual operations easy to follow. Reading flow: Method order is natural, but inconsistent tabs, spaces, and alignment interrupt scanning. Short names such as v and sb slightly reduce clarity.

Run 3

Code Structure: Methods are logically separated into initialization, chain wiring, method delegation, and string formatting. Nesting: Mostly shallow, but unnecessary standalone blocks around loops add indentation; toString also contains a nested conditional. Clarity of intent: Class and method names communicate purpose, though short names such as v, cv, and sb and unexplained reverse wiring require some interpretation. Code length: Reasonably concise, but conventional for loops would eliminate extra blocks and separate index updates. Action granularity: Each statement performs one clear action, making operations easy to follow. Reading flow: Method ordering is natural, but inconsistent tabs, spaces, and alignment interrupt visual consistency. Overall, the code is understandable with modest formatting and loop simplification opportunities.