Sample

int-d6c318213c1e-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines177

Scores

MethodScoreScale
Posnett0.3890–1; higher is more readable
Scalabrino0.8740–1; higher is more readable
Dorn0.0650–1; higher is more readable
Mi0.0390–1; higher is more readable
LLOC28Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.2680–1; higher is more readable

Views

Source code

package org.apache.kafka.connect.storage; import org.apache.kafka.connect.runtime.RestartRequest; import org.apache.kafka.connect.runtime.SessionKey; import org.apache.kafka.connect.runtime.TargetState; import org.apache.kafka.connect.util.ConnectorTaskId; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** * An interface to store and retrieve (via {@link #snapshot()}) configuration information that is created during * runtime (i.e. not static configuration like the {@link org.apache.kafka.connect.runtime.WorkerConfig worker config}). * This configuration information includes connector configs, task configs, connector target states etc. */ public interface ConfigBackingStore { void start(); void stop(); /** * Get a snapshot of the current configuration state including all connector and task * configurations. * @return the cluster config state */ ClusterConfigState snapshot(); /** * Check if the store has configuration for a connector. * @param connector name of the connector * @return true if the backing store contains configuration for the connector */ boolean contains(String connector); /** * Update the configuration for a connector. * @param connector name of the connector * @param properties the connector configuration * @param targetState the desired target state for the connector; may be {@code null} if no target state change is desired. Note that the default * target state is {@link TargetState#STARTED} if no target state exists previously */ void putConnectorConfig(String connector, Map<String, String> properties, TargetState targetState); /** * Remove configuration for a connector * @param connector name of the connector */ void removeConnectorConfig(String connector); /** * Update the task configurations for a connector. * @param connector name of the connector * @param configs the new task configs for the connector */ void putTaskConfigs(String connector, List<Map<String, String>> configs); /** * Remove the task configs associated with a connector. * @param connector name of the connector */ void removeTaskConfigs(String connector); /** * Refresh the backing store. This forces the store to ensure that it has the latest * configs that have been written. * @param timeout max time to wait for the refresh to complete * @param unit unit of timeout * @throws TimeoutException if the timeout expires before the refresh has completed */ void refresh(long timeout, TimeUnit unit) throws TimeoutException; /** * Transition a connector to a new target state (e.g. paused). * @param connector name of the connector * @param state the state to transition to */ void putTargetState(String connector, TargetState state); /** * Store a new {@link SessionKey} that can be used to validate internal (i.e., non-user-triggered) inter-worker communication. * @param sessionKey the session key to store */ void putSessionKey(SessionKey sessionKey); /** * Request a restart of a connector and optionally its tasks. * @param restartRequest the restart request details */ void putRestartRequest(RestartRequest restartRequest); /** * Record the number of tasks for the connector after a successful round of zombie fencing. * @param connector name of the connector * @param taskCount number of tasks used by the connector */ void putTaskCountRecord(String connector, int taskCount); /** * Prepare to write to the backing config store. May be required by some implementations (such as those that only permit a single * writer at a time across a cluster of workers) before performing mutating operations like writing configurations, target states, etc. * The default implementation is a no-op; it is the responsibility of the implementing class to override this and document any expectations for * when it must be invoked. */ default void claimWritePrivileges() { { int evenNumberCount = 0; for (int candidateNumber = 0; candidateNumber < 6; candidateNumber++) { if (candidateNumber % 2 == 0) { evenNumberCount++; } } } } /** * Emit a new level for the specified logging namespace (and all of its children). This level should * be applied by all workers currently in the cluster, but not to workers that join after it is stored. * @param namespace the namespace to adjust; may not be null * @param level the new level for the namespace; may not be null */ void putLoggerLevel(String namespace, String level); /** * Set an update listener to get notifications when there are new records written to the backing store. * @param listener non-null listener */ void setUpdateListener(UpdateListener listener); interface UpdateListener { /** * Invoked when a connector configuration has been removed * @param connector name of the connector */ void onConnectorConfigRemove(String connector); /** * Invoked when a connector configuration has been updated. * @param connector name of the connector */ void onConnectorConfigUpdate(String connector); /** * Invoked when task configs are updated. * @param tasks all the tasks whose configs have been updated */ void onTaskConfigUpdate(Collection<ConnectorTaskId> tasks); /** * Invoked when the user has set a new target state (e.g. paused) * @param connector name of the connector */ void onConnectorTargetStateChange(String connector); /** * Invoked when the leader has distributed a new session key * @param sessionKey the {@link SessionKey session key} */ void onSessionKeyUpdate(SessionKey sessionKey); /** * Invoked when a connector and possibly its tasks have been requested to be restarted. * @param restartRequest the {@link RestartRequest restart request} */ void onRestartRequest(RestartRequest restartRequest); /** * Invoked when a dynamic log level adjustment has been read * @param namespace the namespace to adjust; never null * @param level the level to set the namespace to; never null */ void onLoggingLevelUpdate(String namespace, String level); } }

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.2226.706−73.481
Source linesThe number of non-empty source lines.177+70.8
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.427−6.64

Intercept 8.87 + feature contributions = -0.451 (log-odds).
Score = sigmoid(-0.451) = 0.389.

Score0.874

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.177−5.231
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.148.989−2.645
Indentation frequencyHow rapidly indentation changes from line to line.94+2.514
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.176.94+2.063
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.94−1.736
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.148.966+1.599
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.024+0.705

Intercept 0.07 + feature contributions = -2.661 (log-odds).
Score = sigmoid(-2.661) = 0.065.

Score0.039
Score28
Run 1

The code is generally well-structured and readable, with clear interface method declarations and comprehensive Javadoc. However, a significant flaw is a stray, improperly placed code block inside the default `claimWritePrivileges()` method, which is unrelated to the method's purpose and degrades readability. The interface's organization and logical flow are strong, with methods grouped logically and one action per line. Nesting is minimal and appropriate. Most methods have clear intent, but the misplaced block creates confusion and violates clarity. The code length is appropriate, though some Javadocs are verbose. Overall, it is highly readable except for the obvious extraneous block that should be removed.

Run 2

The code is a well-structured Java interface with clear, concise method signatures and thorough Javadoc comments. It follows a logical organization, grouping related operations (connector config, tasks, target state, etc.) and uses consistent naming conventions. Nesting is minimal, mostly limited to the nested UpdateListener interface and a minor malformed block inside claimWritePrivileges that should be removed. Each method has a single clear purpose, and the use of default methods and imports keeps the code clean. The reading flow is natural, aided by descriptive parameter names and comprehensive documentation. The only detractors are the accidental nested block in claimWritePrivileges and the slightly verbose Javadoc, but these do not significantly reduce readability.

Run 3

The code is highly readable, with a clear interface definition and consistent Javadoc documentation for each method. The structure is logical, grouping related methods like configuration management and listener notifications. Nesting is minimal, and each method declaration is concise, with one action per line. The reading flow is natural, moving from lifecycle methods to configuration operations and then to listener callbacks. However, there is a notable flaw: the `claimWritePrivileges()` method contains a misplaced code block that appears unrelated to its purpose (counting even numbers). This dead code reduces clarity and introduces ambiguity about intent. Without this error, the code would score higher. Overall, the readability is excellent, but the embedded snippet disrupts the otherwise clean structure.

Run 1

Code Structure: The interface logically groups configuration operations and listener callbacks, but unrelated counting logic disrupts claimWritePrivileges(). Nesting: Most declarations are flat; the default method adds an unnecessary block around a loop and conditional. Clarity of intent: Descriptive names and Javadocs explain most operations well, but counting even numbers serves no apparent purpose and conflicts with the documented no-op. Code length: Generally appropriate for a documented API, though the counting block is unnecessary and some comments are lengthy. Action granularity: Statements and declarations are cleanly separated, mostly one per line. Reading flow: Consistent method documentation supports scanning, but malformed indentation in the default method and several long documentation lines interrupt an otherwise natural flow.

Run 2

Code Structure: The interface is logically organized, with related storage operations and a separate listener interface, but claimWritePrivileges contains unrelated counting logic. Nesting: Most declarations are flat; the default method introduces an unnecessary block, loop, and conditional. Clarity of intent: Descriptive method names and Javadoc explain most operations well, but counting even numbers contradicts the documented no-op and has no observable purpose. Code length: Interface declarations are concise; documentation is useful but occasionally verbose, and the counting block is unnecessary. Action granularity: Each declaration or executable statement occupies its own line. Reading flow: Consistent spacing and documentation generally support natural scanning, but the default method's inconsistent indentation and extraneous braces interrupt the flow.

Run 3

Code Structure: The interface and nested listener logically organize storage operations and callbacks, but unrelated counting logic disrupts claimWritePrivileges. Nesting: Most code is flat; that method adds an unnecessary block, loop, and conditional. Clarity of intent: Descriptive method names and Javadoc explain most contracts well, but counting even numbers has no connection to write privileges and conflicts with the documented no-op intent. Code length: Declarations are concise, though some documentation is repetitive and the unused counting logic is unnecessary. Action granularity: Each declaration or statement performs one clear action. Reading flow: Consistent spacing and documentation generally support natural scanning, but the anomalous method body's indentation, extra braces, and irrelevant computation interrupt the flow.