Sample

int-95b0f53eac54-I13

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

Matched original source

Lines63

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.4460–1; higher is more readable
Dorn0.1310–1; higher is more readable
Mi0.1820–1; higher is more readable
LLOC28Logical lines; fewer is more readable
DeepSeek V4 Pro12.670–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.430–1; higher is more readable

Views

Source code

package io.netty.example.http.snoop; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.HttpContent; import io.netty.handler.codec.http.HttpUtil; import io.netty.handler.codec.http.HttpObject; import io.netty.handler.codec.http.HttpResponse; import io.netty.handler.codec.http.LastHttpContent; import io.netty.util.CharsetUtil; public class HttpSnoopClientHandler extends SimpleChannelInboundHandler<HttpObject> { @Override public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) { if (msg instanceof HttpResponse) { HttpResponse response = (HttpResponse) msg; System.err.println("STATUS: " + response.status()); System.err.println("VERSION: " + response.protocolVersion()); System.err.println(); if (!response.headers().isEmpty()) { { java.util.Iterator<?> loopIteratorA = (response.headers().names()).iterator(); while (loopIteratorA.hasNext()) { CharSequence name = (CharSequence) loopIteratorA.next(); { java.util.Iterator<?> loopIterator = (response.headers().getAll(name)).iterator(); while (loopIterator.hasNext()) { CharSequence value = (CharSequence) loopIterator.next(); System.err.println("HEADER: " + name + " = " + value); } } } } System.err.println(); } if (HttpUtil.isTransferEncodingChunked(response)) { System.err.println("CHUNKED CONTENT {"); } else { System.err.println("CONTENT {"); } } if (msg instanceof HttpContent) { HttpContent content = (HttpContent) msg; System.err.print(content.content().toString(CharsetUtil.UTF_8)); System.err.flush(); if (content instanceof LastHttpContent) { System.err.println("} END OF CONTENT"); ctx.close(); } } } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { cause.printStackTrace(); ctx.close(); } }

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.2824.142−93.197
Source linesThe number of non-empty source lines.63+25.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.398−6.597

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

Score0.446

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.63+1.442
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.63−1.194
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.63−1.025
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
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.953−0.738
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.62.848+0.469
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.108−0.112

Intercept 0.07 + feature contributions = -1.892 (log-odds).
Score = sigmoid(-1.892) = 0.131.

Score0.182
Score28
Run 1

The code has clear purpose and logical structure, handling HTTP response headers and content. The main readability issues are in the header iteration section: unnecessary nested blocks, verbose iterator loops that could be replaced with enhanced for-loops, and awkward variable naming like 'loopIteratorA'. The nested if-block with an inner block before the loop adds unnecessary depth. Mixed concerns: the handler wraps content in braces but the logic is split across nested if statements. Reading flow is natural for the most part. Action granularity is generally good - one action per line. Code length is acceptable but the header iteration part is unnecessarily long. Nesting is moderate but could be flatter. Clarity of intent is good for the HTTP handling logic but weakened by the iterator boilerplate.

Run 2

The code has clear intent and follows a straightforward structure, but suffers from readability issues. The main problems are overly verbose and manually-written iteration loops, which could be replaced with enhanced for-loops. This creates unnecessary nesting and reduces clarity. The code also has inconsistent block usage (redundant braces around loops) and lacks separation between logical sections, making the reading flow somewhat disorganized. Additionally, multiple statements per line are rare but present in the imports. The action granularity is generally good, with one action per line for the most part, but the loop structure reduces overall clarity. The class is concise for its purpose, but the manual iterator code makes it longer than needed and harder to follow.

Run 3

The code is generally clear in purpose and follows standard Netty handler patterns, but has several readability issues. The structure is mostly logical (HTTP response handling followed by content handling), but the header iteration block is awkwardly formatted with unnecessary extra braces and fully-qualified iterator types that increase visual noise. Nesting is moderate—the nested while loops for headers/values add complexity. Action granularity is mixed: most lines perform one action, but the header printing combines string concatenation and output. Reading flow is interrupted by the verbose iterator syntax and redundant block braces. Code length is slightly inflated due to manual iterator usage instead of enhanced-for loops. The intent is clear overall: log HTTP response metadata and content, then close on completion. Score reflects decent logic flow but poor stylistic choices in looping and formatting that reduce clarity.

Run 1

Code Structure: Response metadata, content handling, and exception handling are logically separated, but header iteration is cluttered. Nesting: Header processing has unnecessarily deep nesting due to redundant blocks and explicit iterator loops. Clarity of intent: Class, method, and HTTP-related names clearly communicate the logging purpose; generic iterator names and casts reduce clarity locally. Code length: Mostly concise, though enhanced for-loops would substantially shorten header processing. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Processing progresses naturally from status and headers to body content and connection closure, but inconsistent indentation and excessive braces interrupt the flow.

Run 2

Code Structure: Response handling, content handling, and exception handling are logically separated, though header iteration adds unnecessary blocks. Nesting: Most logic is shallow, but the header section becomes deeply nested through redundant braces and explicit iterator loops. Clarity of intent: Descriptive class, method, and variable names, along with labeled output, make the purpose clear; generic iterator names and casts add noise. Code length: Reasonably compact overall, but enhanced for-loops could substantially shorten header processing. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Processing moves naturally from response metadata to headers and content, then cleanup; inconsistent indentation and fully qualified iterator declarations interrupt that flow.

Run 3

Code Structure: Response handling, content handling, and exception handling are logically separated, although header iteration clutters the main method. Nesting: The header traversal is unnecessarily deep due to redundant blocks and nested while loops. Clarity of intent: Descriptive class and method names and explicit output labels clearly communicate HTTP response logging; generic iterator names and casts reduce clarity. Code length: Mostly compact, but enhanced for-loops could substantially shorten the header traversal. Action granularity: Each statement generally performs one action, making individual operations easy to follow. Reading flow: Processing naturally proceeds from status and headers to content and cleanup, but inconsistent indentation and verbose iterator mechanics interrupt the flow.