Sample

int-258a9c8fed23-I13

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

Matched original source

Lines98

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6530–1; higher is more readable
Dorn0.3240–1; higher is more readable
Mi0.0340–1; higher is more readable
LLOC51Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.4280–1; higher is more readable

Views

Source code

package io.netty.handler.codec.socksx.v5; import io.netty.handler.codec.DecoderResult; import io.netty.util.NetUtil; import io.netty.util.internal.ObjectUtil; import io.netty.util.internal.StringUtil; import java.net.IDN; /** * The default {@link Socks5CommandResponse}. */ public final class DefaultSocks5CommandResponse extends AbstractSocks5Message implements Socks5CommandResponse { private final Socks5CommandStatus status; private final Socks5AddressType bndAddrType; private final String bndAddr; private final int bndPort; public DefaultSocks5CommandResponse(Socks5CommandStatus status, Socks5AddressType bndAddrType) { this(status, bndAddrType, null, 0); } public DefaultSocks5CommandResponse( Socks5CommandStatus status, Socks5AddressType bndAddrType, String bndAddr, int bndPort) { ObjectUtil.checkNotNull(status, "status"); ObjectUtil.checkNotNull(bndAddrType, "bndAddrType"); if (bndAddr != null) { if (bndAddrType == Socks5AddressType.IPv4) { if (!NetUtil.isValidIpV4Address(bndAddr)) { throw new IllegalArgumentException("bndAddr: " + bndAddr + " (expected: a valid IPv4 address)"); } } else if (bndAddrType == Socks5AddressType.DOMAIN) { bndAddr = IDN.toASCII(bndAddr); if (bndAddr.length() > 255) { throw new IllegalArgumentException("bndAddr: " + bndAddr + " (expected: less than 256 chars)"); } } else if (bndAddrType == Socks5AddressType.IPv6) { if (!NetUtil.isValidIpV6Address(bndAddr)) { throw new IllegalArgumentException("bndAddr: " + bndAddr + " (expected: a valid IPv6 address)"); } } } if (bndPort < 0 || bndPort > 65535) { throw new IllegalArgumentException("bndPort: " + bndPort + " (expected: 0~65535)"); } this.status = status; this.bndAddrType = bndAddrType; this.bndAddr = bndAddr; this.bndPort = bndPort; } @Override public Socks5CommandStatus status() { return status; } @Override public Socks5AddressType bndAddrType() { return bndAddrType; } @Override public String bndAddr() { return bndAddr; } @Override public int bndPort() { return bndPort; } @Override public String toString() { StringBuilder buf = new StringBuilder(128); buf.append(StringUtil.simpleClassName(this)); DecoderResult decoderResult = decoderResult(); if (!decoderResult.isSuccess()) { buf.append("(decoderResult: "); buf.append(decoderResult); buf.append(", status: "); } else { buf.append("(status: "); } buf.append(status()); buf.append(", bndAddrType: "); buf.append(bndAddrType()); buf.append(", bndAddr: "); buf.append(bndAddr()); buf.append(", bndPort: "); buf.append(bndPort()); buf.append(')'); return buf.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.3307.446−109.146
Source linesThe number of non-empty source lines.98+39.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.668−7.002

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

Score0.653

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.96+2.583
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.99−2.469
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.96−1.782
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.115.98−1.247
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.116+1.067
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.97.897+0.959
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.088+0.084

Intercept 0.07 + feature contributions = -0.735 (log-odds).
Score = sigmoid(-0.735) = 0.324.

Score0.034
Score51
Run 1

The code demonstrates good structure and clarity. The class has a clear single responsibility, and method organization follows a logical pattern (constructors, then getters, then toString). Validation is handled properly at construction time rather than being scattered. The nesting level in the constructor reaches three levels deep, but this is reasonable for address validation logic and remains readable. Method names are concise and self-documenting. The toString method flows well with a clear conditional branch for including decoder results. One minor readability concern is having multiple method calls on separate lines in the toString method, which slightly increases code length, but this actually improves readability by keeping each logical step distinct. The constructor parameter validation is appropriately placed with clear error messages. Overall, the code follows good Java conventions and is very maintainable.

Run 2

The code is generally well-structured, with clear separation of concerns, consistent formatting, and minimal nesting. The constructor uses validation logic with only two levels of nesting, which is acceptable. The intent of each method and validation branch is clear. The toString() method is explicitly built using a StringBuilder with natural reading flow. However, the code could benefit from extracting the address validation logic into a private helper method to reduce constructor length and improve reusability. Additionally, the lack of comments on non-obvious validation rules (e.g., IDN conversion for domain addresses) slightly affects clarity. Overall, the code is highly readable but not perfect due to the constructor's moderate length and validation logic complexity.

Run 3

The code is generally readable but has a few issues. The structure is logical with clear field definitions and getter methods. However, the constructor has deeply nested conditionals for address validation, making it harder to follow. Intent is mostly clear, but the mixed validation logic in the constructor could be extracted for better clarity. Code length is reasonable though the constructor is somewhat verbose. Action granularity is good—one action per line in most cases. Reading flow is natural but interrupted by the nested validation blocks.

Run 1

Code Structure: Fields, constructors, accessors, and string formatting are logically organized with clear responsibilities. Nesting: Address validation reaches three conditional levels, adding modest complexity, while other methods remain flat. Clarity of intent: Type names, validation helpers, and descriptive exception messages make the purpose clear; abbreviated bnd names require some protocol familiarity. Code length: Appropriate for the class, though repeated validation patterns and individual append calls add minor verbosity. Action granularity: Each statement generally performs one action, making validation and field initialization easy to inspect. Reading flow: Construction proceeds naturally from null checks through address and port validation to assignment, followed by simple accessors and diagnostic formatting. Overall, highly readable with small opportunities to simplify validation nesting and formatting.

Run 2

Code Structure: Well organized into immutable fields, delegating constructors, validation, accessors, and string formatting. Nesting: Address validation reaches three conditional levels, but branches are short and easy to follow. Clarity of intent: Descriptive types, straightforward checks, and specific error messages make the purpose clear; abbreviated bnd names require some SOCKS familiarity. Code length: Appropriate overall, though repeated validation patterns and verbose StringBuilder appends add minor bulk. Action granularity: Statements generally perform one action per line, making operations easy to inspect. Reading flow: Validation precedes field assignment, and methods follow a conventional order. Consistent formatting supports natural reading, with only minor friction from nested validation and repetitive formatting code.

Run 3

Code Structure: Well organized into immutable fields, constructors, validation, accessors, and string formatting. Nesting: Address validation reaches three conditional levels, but each branch remains short and understandable. Clarity of intent: Type-specific validation, explicit exception messages, and descriptive types make the purpose clear; abbreviated names such as bndAddr require some SOCKS familiarity. Code length: Appropriate overall, though repetitive validation branches and StringBuilder calls add modest verbosity. Action granularity: Statements generally perform one action per line, making operations easy to inspect. Reading flow: The constructor naturally progresses from null checks through address and port validation to field assignment; accessors and toString follow predictably. Minor drawbacks include tightly grouped imports and parameter reassignment during domain normalization.