Sample

int-761bf08344b0-I13

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

Matched original source

Lines38

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.660–1; higher is more readable
Dorn0.7180–1; higher is more readable
Mi0.0760–1; higher is more readable
LLOC5Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6390–1; higher is more readable

Views

Source code

package io.netty.resolver.dns; import io.netty.channel.AddressedEnvelope; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.handler.codec.dns.DefaultDnsQuery; import io.netty.handler.codec.dns.DnsQuery; import io.netty.handler.codec.dns.DnsQuestion; import io.netty.handler.codec.dns.DnsRecord; import io.netty.handler.codec.dns.DnsResponse; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.Promise; import java.net.InetSocketAddress; final class TcpDnsQueryContext extends DnsQueryContext { TcpDnsQueryContext(Channel channel, InetSocketAddress nameServerAddr, DnsQueryContextManager queryContextManager, DnsQueryLifecycleObserver lifecycleObserver, int maxPayLoadSize, boolean recursionDesired, long queryTimeoutMillis, DnsQuestion question, DnsRecord[] additionals, Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> promise) { super(channel, nameServerAddr, queryContextManager, lifecycleObserver, maxPayLoadSize, recursionDesired, // No retry via TCP. queryTimeoutMillis, question, additionals, promise, null, false); } @Override protected DnsQuery newQuery(int id, InetSocketAddress nameServerAddr) { return new DefaultDnsQuery(id); } @Override protected String protocol() { return "TCP"; } }

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.1438.566−47.473
Source linesThe number of non-empty source lines.38+15.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.553−6.83

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

Score0.66

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.111.974−1.078
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.112+1.003
Indentation frequencyHow rapidly indentation changes from line to line.37+0.543
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.39−0.345
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.074+0.222
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.37.92+0.12

Intercept 0.07 + feature contributions = 0.933 (log-odds).
Score = sigmoid(0.933) = 0.718.

Score0.076
Score5
Run 1

The code is well-structured and readable. It has a clear class hierarchy with a single inheritance from DnsQueryContext. The constructor is straightforward, with parameters clearly named and a concise super() call that uses a helpful comment to explain the null and false arguments. Methods are short and focused, each performing a single action. There is minimal nesting, with no conditional logic or loops. The code is concise and follows standard Java conventions. Minor deductions: the long constructor parameter list could be wrapped differently, and the 'protocol()' method is trivially simple. Overall, this code is easy to understand and maintain.

Run 2

The code is highly readable with a clear, focused purpose. Structure is logical with a single class extending DnsQueryContext, and methods are concise with minimal nesting. Intent is evident from the class name and method names (newQuery, protocol). The constructor uses aligned parameters, though it is somewhat long, but this is justified by the number of required arguments. Action granularity is appropriate—each line performs one logical operation. Reading flow is natural, starting with constructor setup, then query creation, then protocol identification. The only minor drawback is the constructor's length, which could slightly impact readability, but the comment 'No retry via TCP.' clarifies a non-obvious parameter choice. Overall, this is clean, maintainable code.

Run 3

The code is generally well-structured and easy to read. It's a short, focused class with a clear, single responsibility: handling TCP-specific DNS query context. The class has minimal nesting, with only one method override and constructor, making the control flow straightforward. The constructor parameters are clearly named and logically ordered, with a helpful comment explaining why retry is disabled. The protocol() method is self-documenting. The code is concise and free from unnecessary complexity. Action granularity is appropriate—each line serves a clear purpose. The reading flow is natural, moving from constructor to query creation to protocol specification. Minor deductions: the long parameter list could benefit from a builder pattern or Parameter Object for better readability, and there's a slight inconsistency in naming ('maxPayLoadSize' vs 'maxPayloadSize'). Overall, it's readable code that follows standard Java and Netty conventions.

Run 1

Code Structure: A small, focused subclass with a constructor and two clearly separated overrides. Nesting: No nested control flow, making it easy to scan. Clarity of intent: Descriptive class and method names clearly convey TCP DNS query behavior; the retry comment helps explain configuration, though positional null and false arguments require superclass knowledge. Code length: Concise overall, with minor clutter from unused ChannelFuture and Future imports. Action granularity: Each method performs a single action, and statements are cleanly separated. Reading flow: Constructor followed by query creation and protocol identification is natural; the long constructor signature and superclass argument list slightly interrupt readability.

Run 2

Code Structure: A small, logically organized subclass separates construction, query creation, and protocol identification. Nesting: No nested control flow, making the code easy to scan. Clarity of intent: Descriptive class and method names, overrides, and the TCP retry comment communicate purpose; however, the long superclass argument list and literal null/false arguments require superclass knowledge. Code length: Concise implementation with little unnecessary code, although ChannelFuture and Future imports are unused. Action granularity: Each statement performs a single action; grouping constructor parameters slightly reduces scanability. Reading flow: The constructor followed by two straightforward overrides creates a natural flow, with consistent indentation and spacing.

Run 3

Code Structure: The class is logically organized into a constructor and two focused overrides. Nesting: There are no nested control structures, making the code easy to scan. Clarity of intent: Descriptive class and method names clearly identify a TCP DNS query context, and the comment explains the no-retry behavior. However, the long constructor signature and positional null/false arguments require superclass knowledge. Code length: The implementation is concise, although unused ChannelFuture and Future imports add clutter. Action granularity: Each statement performs one clear action; grouping some constructor parameters on the same line slightly reduces scanability. Reading flow: Constructor-to-overrides ordering is natural, with consistent formatting, though the dense superclass call modestly interrupts the flow.