Sample

int-4f0782b381bd-I13

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

Matched original source

Lines31

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7520–1; higher is more readable
Dorn0.2210–1; higher is more readable
Mi0.1080–1; higher is more readable
LLOC11Logical lines; fewer is more readable
DeepSeek V4 Pro180–20; mean of three runs
GPT-6.1 Sol190–20; mean of three runs
BTTF0.6090–1; higher is more readable

Views

Source code

package org.apache.kafka.clients.consumer.internals.events; import org.apache.kafka.common.IsolationLevel; import org.apache.kafka.common.TopicPartition; import java.util.Objects; import java.util.OptionalLong; public class CurrentLagEvent extends CompletableApplicationEvent<OptionalLong> { private final TopicPartition partition; private final IsolationLevel isolationLevel; public CurrentLagEvent(final TopicPartition partition, final IsolationLevel isolationLevel, final long deadlineMs) { super(Type.CURRENT_LAG, deadlineMs); this.partition = Objects.requireNonNull(partition); this.isolationLevel = Objects.requireNonNull(isolationLevel); } public TopicPartition partition() { return partition; } public IsolationLevel isolationLevel() { return isolationLevel; } @Override public String toStringBase() { return super.toStringBase() + ", partition=" + partition + ", isolationLevel=" + isolationLevel; } }

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.909.583−30.016
Source linesThe number of non-empty source lines.31+12.4
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.68−7.02

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

Score0.752

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.119.969−1.416
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
Indentation frequencyHow rapidly indentation changes from line to line.31+0.335
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.077+0.197
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.31−0.061
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.30.769+0.02

Intercept 0.07 + feature contributions = -1.261 (log-odds).
Score = sigmoid(-1.261) = 0.221.

Score0.108
Score11
Run 1

The code is well-structured with clear separation of concerns: imports, field declarations, constructor, accessors, and toString override. It is flat with no nested logic. Purpose is unambiguous: a completion event carrying partition and isolation level data. The length is concise with no unnecessary code. Each action (assignment, null check, return) is on its own line. Reading flow is natural, progressing from fields to construction to access. Minor deduction for the long class declaration line and the chained `Objects.requireNonNull` calls reducing slightly the one-action-per-line granularity.

Run 2

The code is well-structured, with a clear class hierarchy and logical organization. Nesting is minimal, and the class is concise with clear intent. Each method performs a single action, aiding action granularity. The use of Objects.requireNonNull? improves null safety and clarity. The toStringBase method follows a natural reading flow. Minor deductions for lack of comments explaining domain-specific concepts like isolation levels, but overall highly readable.

Run 3

This code is highly readable. The class has a clear, single responsibility and follows a logical structure with fields, constructor, accessors, and a toString method. Nesting is nonexistent, and the flow is natural. Naming is descriptive and consistent with Java conventions. Using Objects.requireNonNull in the constructor clearly signals intent and enforces invariants. The code is concise—no unnecessary boilerplate or duplication. Each line performs a single action, and the toStringBase method cleanly composes the parent representation with subclass-specific fields. Overall, it's easy to understand at a glance, with minimal cognitive load.

Run 1

Code Structure: Logically organized into fields, constructor, accessors, and string representation. Nesting: Flat methods with no nested control flow. Clarity of intent: Descriptive class, field, and method names clearly communicate the event's purpose; explicit null checks clarify required inputs. Code length: Concise, with no unnecessary logic or repetition. Action granularity: Each assignment, validation, and return occupies its own line; constructor assignments naturally combine validation with initialization. Reading flow: Conventional Java ordering makes the class easy to follow. Minor formatting improvements, such as separating the package declaration from imports and wrapping the long constructor signature, would improve readability further.

Run 2

Code Structure: Fields, constructor, accessors, and string representation are logically organized. Nesting: The code is flat, with no nested control flow. Clarity of intent: Descriptive class and member names, explicit types, and null checks clearly communicate an event carrying partition and isolation-level information. Code length: The implementation is concise, without unnecessary logic or duplication. Action granularity: Each statement performs a single clear action; the string concatenation is straightforward. Reading flow: The class reads naturally from state definition through initialization to access and representation. Minor formatting issues, including the lack of separation between the package and imports and a long constructor signature, slightly reduce readability.

Run 3

Code Structure: Logically organized into fields, constructor, accessors, and string representation. Nesting: Flat, with no nested control flow. Clarity of intent: Descriptive class, field, and method names clearly convey an event for querying current lag; constructor null checks make requirements explicit. Code length: Concise, with minimal boilerplate and no unnecessary logic. Action granularity: Each statement performs a single clear action; the string concatenation is straightforward. Reading flow: Natural progression from initialization to access and representation. Minor formatting issues, including tightly grouped package/import declarations and a long constructor signature, slightly reduce readability.