Sample

int-dee122d9016e-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines93

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6380–1; higher is more readable
Dorn0.5280–1; higher is more readable
Mi0.3240–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5830–1; higher is more readable

Views

Source code

package org.apache.kafka.controller; import org.apache.kafka.common.errors.ThrottlingQuotaExceededException; import org.apache.kafka.common.message.RequestHeaderData; import org.apache.kafka.common.security.auth.KafkaPrincipal; import org.apache.kafka.common.utils.Time; import org.apache.kafka.server.authorizer.AuthorizableRequestContext; import java.util.OptionalLong; import java.util.function.Consumer; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.NANOSECONDS; public class ControllerRequestContext { public static OptionalLong requestTimeoutMsToDeadlineNs( Time time, int millisecondsOffset ) { return OptionalLong.of(time.nanoseconds() + NANOSECONDS.convert(millisecondsOffset, MILLISECONDS)); } private final KafkaPrincipal principal; private final OptionalLong deadlineNs; private final RequestHeaderData requestHeader; private final Consumer<Integer> partitionChangeQuotaApplier; public ControllerRequestContext( RequestHeaderData requestHeader, KafkaPrincipal principal, OptionalLong deadlineNs ) { this(requestHeader, principal, deadlineNs, __ -> { }); } public ControllerRequestContext( RequestHeaderData requestHeader, KafkaPrincipal principal, OptionalLong deadlineNs, Consumer<Integer> partitionChangeQuotaApplier ) { this.requestHeader = requestHeader; this.principal = principal; this.deadlineNs = deadlineNs; this.partitionChangeQuotaApplier = partitionChangeQuotaApplier; } public ControllerRequestContext( AuthorizableRequestContext requestContext, OptionalLong deadlineNs ) { this(requestContext, deadlineNs, __ -> { }); } public ControllerRequestContext( AuthorizableRequestContext requestContext, OptionalLong deadlineNs, Consumer<Integer> partitionChangeQuotaApplier ) { this( new RequestHeaderData() .setRequestApiKey((short) requestContext.requestType()) .setRequestApiVersion((short) requestContext.requestVersion()) .setCorrelationId(requestContext.correlationId()) .setClientId(requestContext.clientId()), requestContext.principal(), deadlineNs, partitionChangeQuotaApplier ); } public RequestHeaderData requestHeader() { return requestHeader; } public KafkaPrincipal principal() { return principal; } public OptionalLong deadlineNs() { return deadlineNs; } public void applyPartitionChangeQuota(int requestedPartitionCount) { partitionChangeQuotaApplier.accept(requestedPartitionCount); } }

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.2474.179−81.648
Source linesThe number of non-empty source lines.93+37.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.666−6.998

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

Score0.638

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.93+2.48
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.94−2.292
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.92.824+0.888
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.106.968−0.866
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
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.072+0.24

Intercept 0.07 + feature contributions = 0.113 (log-odds).
Score = sigmoid(0.113) = 0.528.

Score0.324
Score22
Run 1

The code is generally readable with clear class structure and logical organization. It uses constructor overloading effectively to provide default behavior, and method names clearly express intent. Nesting is minimal, and action granularity is mostly one action per line. The static helper method is concise and well-named. Minor issues include a large blank space before the final method, inconsistent indentation in one constructor parameter list, and the use of lambda `__ -> { }` which may be slightly unclear without knowledge of the Consumer interface. The chained builder pattern in the last constructor is readable but slightly dense. Overall, the code is maintainable and understandable, with only cosmetic improvements needed.

Run 2

The code is well-structured and readable. It has a clear purpose with a single class, logical constructor overloading, and consistent accessor methods. The nesting is minimal, and the reading flow is natural. The static factory method `requestTimeoutMsToDeadlineNs` is concise but could benefit from a more descriptive name. The chained builder call in the constructor is slightly dense but still readable. There is an unnecessary blank line before `applyPartitionChangeQuota`. Overall, the code demonstrates clean organization, clear intent, and appropriate granularity, with only minor style inconsistencies.

Run 3

The code is generally well-structured and readable. It uses a clean package declaration, imports each dependency separately, and defines a simple class with clear fields. Constructors are overloaded in a logical manner, with the no-op quota applier (__ -> { }) avoiding unnecessary null checks. Method names like requestTimeoutMsToDeadlineNs and applyPartitionChangeQuota clearly express intent. Nesting is minimal, and actions are mostly one per line. However, there are minor readability drawbacks: the static helper method has a slightly verbose parameter name (millisecondsOffset) and the requestTimeoutMsToDeadlineNs calculation could be more compact. The large blank gaps before applyPartitionChangeQuota look accidental and disrupt reading flow. Additionally, the use of __ as a lambda parameter, while conventional for unused variables, may be slightly unclear to some readers. These are minor issues overall.

Run 1

Code Structure: Fields, constructors, and accessors are logically organized, with constructor delegation avoiding duplicated initialization. Nesting: Almost entirely flat; the fluent header construction is easy to follow. Clarity of intent: Descriptive class, method, and field names convey purpose, although the '__' lambda parameter and undocumented no-op quota callback are less explicit. Code length: Concise overall, but excessive blank lines before the final method and an unused import introduce clutter. Action granularity: Assignments and fluent setter calls generally occupy separate lines; the timeout calculation combines related operations coherently. Reading flow: Constructor overloads lead naturally into accessors and quota application, though inconsistent whitespace and placing the static utility before fields slightly interrupt the flow.

Run 2

Code Structure: Fields, delegating constructors, accessors, and quota application are logically organized, though placing the static helper before fields slightly interrupts conventional ordering. Nesting: Very shallow, with no complex control flow. Clarity of intent: Descriptive names and explicit time units clearly communicate responsibilities; undocumented no-op callbacks and the '__' parameter are slightly less obvious. Code length: Concise overall, with reasonable constructor overloads, but excessive blank lines near the final method add clutter. Action granularity: Assignments and chained header setters are separated cleanly, making individual operations easy to follow. Reading flow: Constructor delegation and straightforward getters provide a natural progression; inconsistent whitespace and the unused ThrottlingQuotaExceededException import mildly distract.

Run 3

Code Structure: Fields, delegating constructors, and accessors are logically organized, though the static helper precedes the fields and one import is unused. Nesting: Very shallow, with no complex control flow. Clarity of intent: Descriptive names and explicit time units make the purpose clear; the no-op lambdas and quota callback could benefit from brief documentation. Code length: Concise overall, with constructor delegation avoiding duplication, but excessive blank lines near the final method add clutter. Action granularity: Assignments and builder calls generally occupy separate lines; the deadline calculation is a compact, understandable expression. Reading flow: Consistent formatting and straightforward accessors support natural reading, slightly disrupted by uneven whitespace and the lengthy constructor delegation expression.