Sample

int-17ee30a9ee18-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines39

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8220–1; higher is more readable
Dorn0.40–1; higher is more readable
Mi0.5280–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro12.330–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.30–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) { { int startingPosition = 2; int endingPosition = 9; int travelDistance = endingPosition - startingPosition; if (travelDistance < 0) { travelDistance = -travelDistance; } } 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.1220.61−40.28
Source linesThe number of non-empty source lines.39+15.6
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.633−6.95

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

Score0.822

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Indentation frequencyHow rapidly indentation changes from line to line.38+0.577
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.38−0.451
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.77.975+0.363
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.39−0.345
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.38.835+0.133
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.092+0.051

Intercept 0.07 + feature contributions = -0.407 (log-odds).
Score = sigmoid(-0.407) = 0.4.

Score0.528
Score16
Run 1

The code has a clear overall structure with a single validation method and a toString override, but it contains a confusing dead code block at the top of ensureValid that computes travelDistance and then discards it. This severely hurts clarity of intent. Nesting is generally flat and action granularity is reasonable, but the dead code forces the reader to question its purpose. The validation logic itself is straightforward, though the try/catch could be more concise. The method name and parameter handling are clear, and the reading flow is mostly natural until the dead code interrupts it. Overall, it is readable but marred by the irrelevant block, preventing a higher score.

Run 2

The code is generally readable with clear purpose and structure, but the presence of an unrelated dead code block (the startingPosition/endingPosition/travelDistance calculation) significantly harms clarity. This block is confusing and appears to be a copy-paste error. Otherwise, the validator logic is straightforward: it checks the value is a string, returns early if blank, and attempts to parse it using HostInfo.buildFromEndpoint. Naming is clear, and the control flow is flat with low nesting. However, the unrelated block and its unnecessary braces increase cognitive load. Removing that block would improve readability to 18-19. The code is concise for its purpose, but the stray block makes it unnecessarily longer and disrupts natural reading flow.

Run 3

The code is mostly readable and follows standard Java conventions, but it contains a stray dead-code block (the startingPosition/endingPosition/travelDistance calculation) that serves no purpose and disrupts reading flow. The class structure is logical, nesting is minimal, and each action is generally on its own line, which helps clarity. The intent of the validator is clear: ensure the value is a string, allow blank strings, and validate the endpoint format. However, the dead code confuses the reader and makes the file appear unfinished or accidentally edited. The try-catch block is concise and appropriate. Overall readability is moderate; removing the dead block would improve the score significantly.

Run 1

Code Structure: The class and validation method are logically organized, but an unrelated distance-calculation block disrupts cohesion. Nesting: Mostly shallow, with straightforward conditionals and a try/catch; the extra block adds unnecessary nesting. Clarity of intent: Type checking, blank-value handling, and endpoint validation are clear, while the unused travelDistance calculation has no apparent purpose. Code length: The validator is concise apart from the redundant calculation block. Action granularity: Each statement performs a single action, making individual lines easy to follow. Reading flow: Early return and sequential validation support natural reading, but inconsistent indentation and irrelevant code at the method's start interrupt the flow.

Run 2

Code Structure: The validator is logically organized, but an unrelated distance-calculation block disrupts cohesion and has inconsistent indentation. Nesting: Mostly shallow, with straightforward conditionals and a try/catch; the extra standalone block adds unnecessary nesting. Clarity of intent: Type checking, blank-value handling, and endpoint validation are clear, while the unused distance calculation has no apparent purpose. Code length: The meaningful validation logic is concise, but the irrelevant block unnecessarily increases length. Action granularity: Each statement performs one action, making individual lines easy to follow. Reading flow: Validation proceeds naturally from type checking to endpoint parsing and error handling, but the unrelated opening block interrupts that flow.

Run 3

Code Structure: The validator is logically organized, but an unrelated distance-calculation block disrupts cohesion and uses inconsistent indentation. Nesting: Validation is mostly flat with an early return; the unnecessary scoped block and inner conditional add avoidable nesting. Clarity of intent: Type checking, blank handling, endpoint validation, and exception reporting are clear, but the unused travelDistance calculation has no apparent purpose. Code length: The validator is concise apart from the extraneous calculation block. Action granularity: Each statement performs one action, making individual operations easy to follow. Reading flow: The main validation sequence is natural, but the irrelevant opening block interrupts it, and missing spacing after the package declaration slightly reduces readability.