Sample

int-cd5fe714f604-I13

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

Matched original source

Lines30

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8840–1; higher is more readable
Dorn0.5730–1; higher is more readable
Mi0.4960–1; higher is more readable
LLOC11Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol190–20; mean of three runs
BTTF0.6580–1; higher is more readable

Views

Source code

package org.apache.kafka.streams.internals; import org.apache.kafka.common.config.ConfigDef; import org.apache.kafka.common.config.ConfigException; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.streams.state.HostInfo; public class ApplicationServerConfigValidator implements ConfigDef.Validator { @Override public void ensureValid(final String name, final Object value) { if (!(value instanceof String)) { throw new ConfigException(name + " must be a string"); } final String endPoint = (String) value; if (Utils.isBlank(endPoint)) { return; } try { HostInfo.buildFromEndpoint(endPoint); } catch (final ConfigException e) { throw new ConfigException(name, value, e.getMessage()); } } @Override public String toString() { return "A host:port pair, protocol://host:port, or an empty string"; } }

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.990.93−32.701
Source linesThe number of non-empty source lines.30+12
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.617−6.926

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

Score0.884

Feature contributions

FeatureValueContribution
(log-odds)
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.1+0.398
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.78+0.361
Indentation frequencyHow rapidly indentation changes from line to line.29+0.266
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.31−0.061
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.091+0.058
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.29.924+0.008

Intercept 0.07 + feature contributions = 0.296 (log-odds).
Score = sigmoid(0.296) = 0.573.

Score0.496
Score11
Run 1

The code is highly readable. It follows a clear logical structure: type check, blank check, validation, and error wrapping. The method is flat with no deep nesting. Each action is on its own line, and the intent is straightforward. The toString method clearly documents acceptable formats. Minor improvements could include a more descriptive exception message, but overall the code is concise, well-organized, and easy to follow.

Run 2

The code is highly readable. It has a clear, logical structure with a single-purpose validator class. Nesting is minimal, with only a simple try-catch block and no deep indentation. Intent is clear from the method and parameter names. The method is concise and avoids unnecessary length. Each line performs one logical action, such as type checking, blank check, or endpoint parsing. Reading flow is natural: validate type, handle blank case, parse endpoint, and wrap exceptions. The only minor issue is the lack of a class-level Javadoc, but this does not significantly impact readability.

Run 3

The code demonstrates strong readability with a clear, logical structure. The class implements a focused validation responsibility, and each method has a singular purpose. Nesting is minimal, with only one level of indentation in the main validation method. Intent is evident: validate that the value is a String, allow blank values, and validate endpoint format. Code length is concise without unnecessary verbosity. Action granularity is mostly one action per line, following clean code principles. The reading flow follows a natural progression: type check, blank check, validation attempt, and error handling. Minor deductions: the catch block could be slightly clearer with a more explicit message, and the toString method concatenation could use a formatted string. Overall, this is well-structured, idiomatic Java code that would be immediately understandable to experienced developers.

Run 1

Code Structure: A focused validator class cleanly separates validation from its descriptive string. Nesting: Guard clauses and an early return keep nesting shallow; the try/catch is straightforward. Clarity of intent: Descriptive names and explicit type, blank-value, and endpoint checks make the purpose clear. Code length: Concise, with no unnecessary logic or repetition. Action granularity: Each statement performs a single action, making execution easy to follow. Reading flow: Validation proceeds naturally from type checking to blank handling to endpoint parsing and contextual error reporting. Minor formatting improvements, such as separating the package declaration from imports with a blank line, would improve presentation.

Run 2

Code Structure: The validator is logically organized, with validation and descriptive output in separate methods. Nesting: Guard clauses keep control flow flat, and the try-catch is shallow. Clarity of intent: Descriptive class and method names make the purpose clear; the blank-value allowance and endpoint validation are straightforward. Code length: The implementation is concise without unnecessary abstractions or repetition. Action granularity: Each statement performs one clear action. Reading flow: Type checking, blank handling, endpoint parsing, and exception wrapping follow a natural sequence. Minor formatting improvements, such as separating the package declaration from imports and adding space before the try block, would improve visual readability.

Run 3

Code Structure: The validator is logically organized, separating validation from its descriptive string. Nesting: Guard clauses keep control flow flat; the try/catch is simple. Clarity of intent: Descriptive names and straightforward checks clearly communicate endpoint validation, although acceptance of blank strings is implicit rather than explained. Code length: The implementation is concise without unnecessary logic. Action granularity: Each statement performs one clear action, with no compound or crowded lines. Reading flow: Validation proceeds naturally from type checking to blank handling, endpoint parsing, and contextual error reporting. A blank line between the package declaration and imports would slightly improve formatting.