Sample

int-901a4c999de0-I10

Remove about 40% of line-break groups while retaining structure

Matched original source

Lines60

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6010–1; higher is more readable
Dorn0.2810–1; higher is more readable
Mi0.050–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro7.330–20; mean of three runs
GPT-6.1 Sol12.670–20; mean of three runs
BTTF0.450–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.60+24
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.741−7.111

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

Score0.601

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.190−4.383
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.190+2.261
Indentation frequencyHow rapidly indentation changes from line to line.54+1.131
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.61−1.123
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.59.859+0.427
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.068+0.28

Intercept 0.07 + feature contributions = -0.939 (log-odds).
Score = sigmoid(-0.939) = 0.281.

Score0.05
Score22
Run 1

The code suffers from severe readability issues. The structure is extremely tangled, with multiple statements crammed onto single lines and method declarations and constructors sharing lines. This creates a disorganized appearance and disrupts natural reading flow. While the code itself is not deeply nested, the lack of proper line breaks and spacing makes it appear more complex than necessary. The intent is partially clear from method names, but the poor formatting obscures the overall purpose. Action granularity is violated with multiple actions on single lines, and the reading flow is completely broken by the inconsistent and condensed layout. The code would be significantly more readable with standard Java formatting conventions, including one statement per line, proper indentation, and consistent spacing.

Run 2

The code has poor readability due to inconsistent formatting, cramped one-line declarations, and multiple statements on single lines. Imports are compressed unnecessarily (e.g., multiple imports on one line), and method signatures/constructors are squeezed together, disrupting natural reading flow. The nesting is flat overall, but the lack of vertical spacing and inconsistent brace placement make it feel tangled. Some intent is clear (e.g., deadline conversion, quota applier), but the compressed layout obscures it. Code length is reasonable, but formatting increases cognitive load. Action granularity is violated frequently—multiple fields, method calls, or statements share lines, hurting scanability. Finally, reading flow is disorganized; standard Java conventions would place braces on new lines and separate members with blank lines.

Run 3

The code has several readability problems. Multiple statements are compressed onto single lines (e.g., imports, method declarations, simple getters), violating the one-action-per-line principle and making the code feel cluttered. Opening braces sometimes appear on the same line as the declaration and sometimes on the next line, indicating inconsistent formatting. Some constructor overloads are reduced to a single dense line, which hurts clarity. The logic itself is fairly straightforward, but the inconsistent spacing, inline method bodies, and lack of visual separation between members make the code harder to scan. The Javadoc on the quota method is good, and naming is generally clear, but overall the formatting significantly undermines readability. A consistent style and proper line breaks would likely raise this to a much higher score.

Run 1

Code Structure: Fields, constructors, accessors, and quota handling are logically organized, but compressed formatting obscures their boundaries. Nesting: Minimal nesting and straightforward constructor delegation make the logic easy to follow. Clarity of intent: Descriptive names, explicit types, and quota documentation communicate purpose clearly; the no-op lambdas are less immediately explanatory. Code length: Concise overall, with constructor overloads serving reasonable purposes rather than adding unnecessary verbosity. Action granularity: Multiple imports, field declarations, accessor methods, and chained calls share lines, reducing scanability. Reading flow: Inconsistent indentation, inline braces, and uneven line breaks interrupt otherwise natural progression through the class.

Run 2

Code Structure: Fields, constructors, and accessors are logically organized, with constructor delegation avoiding duplication, but cramped formatting obscures boundaries. Nesting: Very shallow; there are no complex branches or loops. Clarity of intent: Descriptive names and the quota method documentation make the class's purpose clear, though the empty lambdas require some interpretation. Code length: Concise and largely free of unnecessary logic. Action granularity: Multiple imports, fields, accessors, and chained calls share lines, reducing scanability. Reading flow: Inconsistent indentation, inline braces, and crowded constructor arguments interrupt otherwise straightforward progression. The code is understandable but would benefit significantly from consistent formatting and one declaration or method per line.

Run 3

Code Structure: The class logically groups fields, constructor overloads, accessors, and quota application, but compressed formatting obscures these boundaries. Nesting: Minimal nesting makes the logic easy to follow. Clarity of intent: Descriptive names, constructor delegation, and quota documentation communicate purpose well; the empty callback is less immediately obvious. Code length: The implementation is concise without substantial unnecessary code, although excessive visual compression reduces readability. Action granularity: Multiple imports, field declarations, accessor methods, and chained calls share lines, making individual operations harder to scan. Reading flow: The overall sequence is natural, but inconsistent indentation, brace placement, spacing, and line breaks repeatedly interrupt reading.