Sample

int-3803b9b0d510-SRC

Unmodified source class

Lines93

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6710–1; higher is more readable
Dorn0.8430–1; higher is more readable
Mi0.3240–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.5930–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; } /** * Apply the partition change quota. * * @param requestedPartitionCount The value to apply. * @throws ThrottlingQuotaExceededException If recording this value moves a metric beyond its configured * maximum or minimum bound */ 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.638−6.958

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

Score0.671

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.94−2.292
Indentation frequencyHow rapidly indentation changes from line to line.87+2.272
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.107.926+0.937
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.107.968−0.908
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.92.844+0.888
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.065+0.312

Intercept 0.07 + feature contributions = 1.677 (log-odds).
Score = sigmoid(1.677) = 0.843.

Score0.324
Score22
Run 1

The code is well-structured and highly readable. It uses clear class organization with related methods grouped logically. Constructors are overloaded cleanly, delegating to a primary constructor, which reduces duplication. Nesting is minimal and the code remains flat. The intent is explicit: the class encapsulates controller request context and quota application. Method and parameter names are descriptive (e.g., 'requestTimeoutMsToDeadlineNs', 'partitionChangeQuotaApplier'). Static imports improve conciseness. One minor ambiguity is the use of '__' as an unused parameter, which assumes Java 9+ and may be unfamiliar to some readers. The Javadoc for 'applyPartitionChangeQuota' clarifies behavior and exceptions. Overall, the code follows convention, keeps actions granular, and reads naturally.

Run 2

The code is well-structured and readable. It uses clear naming conventions, has a logical organization with constructors delegating to a primary constructor, and maintains flat nesting with minimal indentation. The purpose of each method is clear, and the code is concise without unnecessary verbosity. The static helper method for timeout conversion is simple and well-defined. Constructors are overloaded in a way that avoids duplication, improving maintainability. Action granularity is appropriate, with one action per line in most cases. The reading flow is natural, moving from static utilities to fields, constructors, and then methods. Minor deductions: the use of the lambda parameter '__' is slightly unconventional and could be more descriptive, but it does not significantly hinder readability in this context.

Run 3

The code is well-structured with clear separation of concerns and logical organization. It uses constructor overloading effectively to provide flexible initialization while delegating to a primary constructor, avoiding duplication. Nesting is minimal, and the code flows naturally with clear method names that express intent. Action granularity is appropriate—each method performs a single, well-defined action. The static utility method is concise and readable. The only minor readability concerns are the use of lambda parameter placeholder '__' (which may be slightly unclear to some readers) and the chained builder pattern in one constructor, though both are acceptable Java idioms. Overall, the code is highly readable, maintainable, and follows good object-oriented practices.

Run 1

Code Structure: The class is logically organized into a helper, fields, constructors, accessors, and quota application, though placing the helper before fields slightly interrupts conventional ordering. Nesting: Methods are flat, with no nested control flow. Clarity of intent: Descriptive names, explicit time units, and quota documentation make responsibilities clear; the '__' lambda parameter and implicit no-op behavior are slightly less expressive. Code length: The implementation is concise, with constructor delegation avoiding duplicated initialization; overloads and simple accessors add reasonable boilerplate. Action granularity: Assignments and chained header setters are individually presented, making operations easy to distinguish. Reading flow: Consistent formatting and constructor delegation support natural reading, although tightly grouped imports and the multiline header construction require minor extra attention.

Run 2

Code Structure: Well-organized context class with immutable fields, delegating constructors, simple accessors, and a focused quota method; placing the static helper before fields slightly interrupts conventional organization. Nesting: Minimal nesting, with straightforward constructor delegation and a readable fluent call chain. Clarity of intent: Descriptive names, explicit time units, and quota documentation make the purpose clear, though the no-op lambdas could be more self-explanatory. Code length: Concise overall; constructor overloads add length but avoid duplicated initialization. Action granularity: Assignments and chained setter calls occupy separate lines, making individual operations easy to follow. Reading flow: Consistent formatting and grouping support natural reading, although import grouping and the long deadline-conversion expression could be improved.

Run 3

Code Structure: Logically organized around immutable fields, delegating constructors, accessors, and quota application, though placing the static helper before fields slightly interrupts conventional ordering. Nesting: Minimal nesting; constructor delegation and a readable fluent chain keep complexity low. Clarity of intent: Descriptive names, explicit time units, and quota documentation make purpose clear; the anonymous no-op callbacks are slightly less expressive. Code length: Concise overall, with constructor overloads providing useful convenience rather than unnecessary duplication. Action granularity: Assignments and fluent setter calls are separated cleanly, with mostly one action per line. Reading flow: Consistent formatting and straightforward delegation support natural reading; tightly grouped imports and the long deadline-conversion expression are minor readability drawbacks.