Sample

int-64567172989a-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines75

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7810–1; higher is more readable
Dorn0.7310–1; higher is more readable
Mi0.5160–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol17.330–20; mean of three runs
BTTF0.6060–1; higher is more readable

Views

Source code

package org.apache.kafka.common.requests; import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.message.VoteRequestData; import org.apache.kafka.common.message.VoteResponseData; import org.apache.kafka.common.protocol.ApiKeys; import org.apache.kafka.common.protocol.Errors; import org.apache.kafka.common.protocol.Readable; import java.util.List; public class VoteRequest extends AbstractRequest { public static class Builder extends AbstractRequest.Builder<VoteRequest> { private final VoteRequestData data; public Builder(VoteRequestData data) { super(ApiKeys.VOTE); this.data = data; } @Override public VoteRequest build(short version) { return new VoteRequest(data, version); } @Override public String toString() { return data.toString(); } } private final VoteRequestData data; private VoteRequest(VoteRequestData data, short version) { super(ApiKeys.VOTE, version); this.data = data; } @Override public VoteRequestData data() { return data; } @Override public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) { return new VoteResponse(new VoteResponseData() .setErrorCode(Errors.forException(e).code())); } public static VoteRequest parse(Readable readable, short version) { return new VoteRequest(new VoteRequestData(readable, version), version); } public static VoteRequestData singletonRequest(TopicPartition topicPartition, String clusterId, int replicaEpoch, int replicaId, int lastEpoch, long lastEpochEndOffset, boolean preVote) { return new VoteRequestData() .setClusterId(clusterId) .setTopics(List.of( new VoteRequestData.TopicData() .setTopicName(topicPartition.topic()) .setPartitions(List.of( new VoteRequestData.PartitionData() .setPartitionIndex(topicPartition.partition()) .setReplicaEpoch(replicaEpoch) .setReplicaId(replicaId) .setLastOffsetEpoch(lastEpoch) .setLastOffset(lastEpochEndOffset) .setPreVote(preVote)) ))); } }

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.2525.522−83.342
Source linesThe number of non-empty source lines.75+30
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.021−6.032

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

Score0.781

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.75+1.857
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.76−1.655
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.74.902+0.637
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.07+0.261
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.81+0.234

Intercept 0.07 + feature contributions = 0.999 (log-odds).
Score = sigmoid(0.999) = 0.731.

Score0.516
Score18
Run 1

The code is well-structured and highly readable. It follows clear organizational patterns with a builder pattern implementation, simple constructor delegation, and straightforward method overrides. Nesting is minimal except in the singletonRequest method where the chained List.of calls create some depth, but this is a common pattern that remains clear. Intent is explicit through descriptive method and variable names. Code length is concise without sacrificing clarity. Action granularity is excellent in most places, with each method performing a single logical operation. The singletonRequest method chains multiple setters but maintains readability through consistent indentation. Reading flow is natural, following a logical progression from class declaration through builder, constructor, and utility methods. Minor deductions for the multi-line chained call in singletonRequest which could be extracted, but overall this code represents production-quality readability.

Run 2

The code is well-structured and follows a clear builder pattern for request construction. The class has a logical organization with nested Builder and static factory methods. Nesting is controlled, with only a slightly deep but acceptable chain in singletonRequest. Intent is generally clear, especially in the builder and parse methods. Most operations are concise and each method has a single responsibility. However, the singletonRequest method is quite long and chains many method calls in a single statement, which reduces readability slightly. The import section could be better organized (e.g., grouping by origin), and the use of List.of with nested builders is compact but may be harder to follow for less experienced readers. Overall, the code is readable but could benefit from breaking the singletonRequest into smaller, named helper methods.

Run 3

The code is well-structured and readable. The Builder pattern is cleanly implemented, with a clear separation of concerns between the builder, request, and data classes. Line breaks and indentation are consistent, contributing to a natural reading flow. The `singletonRequest` method's fluent API chain is slightly nested but remains comprehensible due to its logical grouping. However, the `getErrorResponse` method is on one line and could be broken apart for improved readability, and the `singletonRequest` method's chained calls make it slightly dense. Overall, the code clearly expresses its intent, is concise, and follows established Kafka patterns, resulting in high readability.

Run 1

Code Structure: The request wrapper, nested builder, parsing method, and convenience factory are logically organized with clear responsibilities. Nesting: Most methods are flat, but singletonRequest nests fluent construction inside two List.of calls, making parentheses and object boundaries harder to follow. Clarity of intent: Descriptive method names and explicit setters communicate purpose well; the seven-parameter factory requires some attention to argument ordering. Code length: The implementation is concise, with little unnecessary code. Action granularity: Most statements and setters occupy separate lines, although nested object creation combines several construction steps into one expression. Reading flow: The class follows a natural progression from builder to core methods to factory, but inconsistent indentation and tightly grouped closing parentheses interrupt the factory's readability.

Run 2

Code Structure: Logically organized into a builder, request state, and focused factory/response methods. Nesting: Most methods are flat; singletonRequest has moderately nested object construction that requires careful tracking. Clarity of intent: Descriptive method names, parameter names, and setters clearly express request construction, parsing, and error handling. Code length: Concise, with little unnecessary code; the seven-parameter factory slightly increases cognitive load. Action granularity: Most lines perform one clear action, and chained setters are separated by line, although nested constructors and List.of calls combine several operations. Reading flow: Conventional Java organization supports natural reading, but inconsistent indentation and clustered closing parentheses in singletonRequest slightly disrupt the flow.

Run 3

Code Structure: Logically organized into a builder, request state, and focused methods. Nesting: Most methods are flat, but singletonRequest uses nested object construction and List.of calls that require careful tracking. Clarity of intent: Descriptive names and explicit setters make the request contents clear; the seven-parameter factory adds some cognitive load. Code length: Concise overall, with little unnecessary code beyond standard builder boilerplate. Action granularity: Most statements and setter calls occupy separate lines, although the chained factory expression combines several construction steps. Reading flow: Methods follow a natural progression, but inconsistent indentation and clustered closing parentheses in singletonRequest slightly interrupt scanning.