Sample

int-624f4807813a-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines114

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7710–1; higher is more readable
Dorn0.4040–1; higher is more readable
Mi0.6170–1; higher is more readable
LLOC28Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.5210–1; higher is more readable

Views

Source code

package org.apache.kafka.common.utils; import java.time.Duration; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Supplier; public interface Time { Time SYSTEM = SystemTime.getSystemTime(); long milliseconds(); default long hiResClockMs() { return TimeUnit.NANOSECONDS.toMillis(nanoseconds()); } long nanoseconds(); void sleep(long ms); default void waitObject(Object obj, Supplier<Boolean> condition, long deadlineMs) throws InterruptedException { synchronized (obj) { while (true) { if (condition.get()) return; long currentTimeMs = milliseconds(); if (currentTimeMs >= deadlineMs) throw new org.apache.kafka.common.errors.TimeoutException("Condition not satisfied before deadline"); obj.wait(deadlineMs - currentTimeMs); } } } default Timer timer(long timeoutMs) { return new Timer(this, timeoutMs); } default Timer timer(Duration timeout) { return timer(timeout.toMillis()); } default <T> T waitForFuture( Future<T> future, long deadlineNs ) throws TimeoutException, InterruptedException, ExecutionException { TimeoutException timeoutException = null; while (true) { long nowNs = nanoseconds(); if (deadlineNs <= nowNs) { throw (timeoutException == null) ? new TimeoutException() : timeoutException; } long deltaNs = deadlineNs - nowNs; try { return future.get(deltaNs, TimeUnit.NANOSECONDS); } catch (TimeoutException t) { timeoutException = t; } } } }

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.2107.815−69.558
Source linesThe number of non-empty source lines.114+45.6
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.402−6.603

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

Score0.771

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.114+3.206
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.115−3.035
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.120.991−1.46
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.113.861+1.182
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.091+0.056

Intercept 0.07 + feature contributions = -0.388 (log-odds).
Score = sigmoid(-0.388) = 0.404.

Score0.617
Score28
Run 1

The code is generally well-structured with clear method separation and logical organization. It uses a flat hierarchy with minimal nesting except for one level in waitObject and waitForFuture. Intent is clear for most methods, with descriptive names and appropriate parameter types. However, there are excessive blank lines and comment placeholders that detract from readability. The waitForFuture method has slightly convoluted logic with the timeoutException variable and doubled timeout handling, making it less immediately clear. Action granularity is mostly good—one action per line—though some lines combine checks and throws. Reading flow is natural, but the many empty comments and inconsistent spacing interrupt it. Overall, it's readable but could be tightened by removing placeholder comments and simplifying waitForFuture's exception handling.

Run 2

The code is highly readable. Structure is logical: interface constants, core methods (milliseconds, nanoseconds, sleep), then well-organized default helper methods. Nesting is minimal—only one synchronized block and one while loop with clear exit conditions. Intent is clear from descriptive method names like waitObject, timer, and waitForFuture. Code length is concise with no redundant logic. Action granularity is appropriate: most lines perform a single logical operation, such as checking conditions, calculating time deltas, or waiting. Reading flow is natural, with helper methods following core abstractions. Minor drawbacks include some unnecessary vertical whitespace and a fully qualified TimeoutException reference in waitObject, which slightly interrupt flow but do not significantly hurt clarity.

Run 3

The code is generally readable and well-structured, with clear method names and logical organization within the Time interface. The use of default methods and overloaded timer() is sensible. However, several factors reduce readability: excessive blank lines and scattered comment placeholders disrupt the reading flow. The waitForFuture method uses a loop with repeated timeout handling that is somewhat harder to follow than necessary. waitObject mixes a condition check, time comparison, and object.wait in a compact block. While nesting is shallow and actions are mostly one per line, the presence of many empty comment sections and inconsistent spacing harms overall clarity and conciseness.

Run 1

Code Structure: The interface logically groups clock access, sleeping, timers, and waiting utilities. Nesting: Most methods are flat; waitObject and waitForFuture introduce moderate, manageable nesting. Clarity of intent: Descriptive method names and explicit time-unit suffixes make the purpose clear, although the future timeout retry behavior is not explained. Code length: Implementations are concise, but excessive blank lines unnecessarily lengthen the file. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Method ordering is natural, but inconsistent formatting, omitted braces on some conditionals, and the fully qualified exception name interrupt an otherwise straightforward flow.

Run 2

Code Structure: The interface logically groups clock access, sleeping, timers, and waiting helpers into small methods. Nesting: Generally shallow, although waitObject combines synchronization, a loop, and conditional checks; early exits keep it manageable. Clarity of intent: Descriptive method names and explicit time-unit suffixes make most behavior clear, but the retry loop and retained timeout exception in waitForFuture would benefit from explanation. Code length: Implementations are concise, but excessive blank lines unnecessarily lengthen the file. Action granularity: Statements generally perform one action per line; the conditional throw expression is slightly denser. Reading flow: Methods follow a sensible progression, but inconsistent spacing, excessive whitespace, and unbraced conditionals interrupt an otherwise straightforward reading experience.

Run 3

Code Structure: The interface logically groups clock access, sleeping, timer creation, and waiting utilities into small methods. Nesting: Most methods are flat; waitObject and waitForFuture have moderate, manageable nesting. Clarity of intent: Descriptive method names and explicit time units clarify purpose, though the distinction between clock sources and the future timeout retry behavior lack explanation. Code length: Implementations are concise, but excessive blank lines unnecessarily inflate the listing. Action granularity: Statements generally perform one action per line; the conditional throw expression is slightly denser. Reading flow: Methods follow a sensible progression, but inconsistent spacing, the multiline parameter layout, and unbraced conditionals mildly disrupt readability.