Sample

int-3d9e9d26cd28-I09

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

Matched original source

Lines164

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.470–1; higher is more readable
Dorn0.0910–1; higher is more readable
Mi0.1190–1; higher is more readable
LLOC55Logical lines; fewer is more readable
DeepSeek V4 Pro10.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.1740–1; higher is more readable

Views

Source code

package org.apache.kafka.connect.cli; import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.common.utils.internals.Exit; import org.apache.kafka.connect.connector.policy.ConnectorClientConfigOverridePolicy; import org.apache.kafka.connect.errors.ConnectException; import org.apache.kafka.connect.json.JsonConverter; import org.apache.kafka.connect.json.JsonConverterConfig; import org.apache.kafka.connect.runtime.Connect; import org.apache.kafka.connect.runtime.Herder; import org.apache.kafka.connect.runtime.Worker; import org.apache.kafka.connect.runtime.isolation.Plugins; import org.apache.kafka.connect.runtime.rest.RestClient; import org.apache.kafka.connect.runtime.rest.RestServer; import org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo; import org.apache.kafka.connect.runtime.rest.entities.CreateConnectorRequest; import org.apache.kafka.connect.runtime.standalone.StandaloneConfig; import org.apache.kafka.connect.runtime.standalone.StandaloneHerder; import org.apache.kafka.connect.storage.FileOffsetBackingStore; import org.apache.kafka.connect.storage.OffsetBackingStore; import org.apache.kafka.connect.util.FutureCallback; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DatabindException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.nio.file.Paths; import java.util.Map; import static org.apache.kafka.connect.runtime.ConnectorConfig.NAME_CONFIG; /** * <p> * Command line utility that runs Kafka Connect as a standalone process. In this mode, work (connectors and tasks) is not * distributed. Instead, all the normal Connect machinery works within a single process. This is useful for ad hoc, * small, or experimental jobs. * </p> * <p> * Connector and task configs are stored in memory and are not persistent. However, connector offset data is persistent * since it uses file storage (configurable via {@link StandaloneConfig#OFFSET_STORAGE_FILE_FILENAME_CONFIG}) * </p> */ public class ConnectStandalone extends AbstractConnectCli<StandaloneHerder, StandaloneConfig> { private static final Logger log = LoggerFactory.getLogger(ConnectStandalone.class); public ConnectStandalone(String... args) { super(args); } @Override protected String usage() { {int lI0O_0ce4b630=0x2D0A;boolean lI0O_88b5af58=true;do{lI0O_0ce4b630^=0x2D0A;lI0O_88b5af58=false;}while(lI0O_88b5af58);} return "ConnectStandalone worker.properties [connector1.properties connector2.json ...]"; } @Override public void processExtraArgs(Connect<StandaloneHerder> connect, String[] extraArgs) { try { for (final String connectorConfigFile : extraArgs) { CreateConnectorRequest createConnectorRequest = parseConnectorConfigurationFile(connectorConfigFile); FutureCallback<Herder.Created<ConnectorInfo>> cb = new FutureCallback<>((error, info) -> { if (error != null) log.error("Failed to create connector for {}", connectorConfigFile); else log.info("Created connector {}", info.result().name()); }); connect.herder().putConnectorConfig( createConnectorRequest.name(), createConnectorRequest.config(), createConnectorRequest.initialTargetState(), false, cb); cb.get(); } connect.herder().ready(); } catch (Throwable t) { log.error("Stopping after connector error", t); connect.stop(); Exit.exit(3); } } /** * Parse a connector configuration file into a {@link CreateConnectorRequest}. The file can have any one of the following formats (note that * we attempt to parse the file in this order): * <ol> * <li>A JSON file containing an Object with only String keys and values that represent the connector configuration.</li> * <li>A JSON file containing an Object that can be parsed directly into a {@link CreateConnectorRequest}</li> * <li>A valid Java Properties file (i.e. containing String key/value pairs representing the connector configuration)</li> * </ol> * <p> * Visible for testing. * * @param filePath the path of the connector configuration file * @return the parsed connector configuration in the form of a {@link CreateConnectorRequest} */ CreateConnectorRequest parseConnectorConfigurationFile(String filePath) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); File connectorConfigurationFile = Paths.get(filePath).toFile(); try { Map<String, String> connectorConfigs = objectMapper.readValue(connectorConfigurationFile, new TypeReference<>() { }); if (!connectorConfigs.containsKey(NAME_CONFIG)) { throw new ConnectException("Connector configuration at '" + filePath + "' is missing the mandatory '" + NAME_CONFIG + "' " + "configuration"); } return new CreateConnectorRequest(connectorConfigs.get(NAME_CONFIG), connectorConfigs, null); } catch (StreamReadException | DatabindException e) { log.debug("Could not parse connector configuration file '{}' into a Map with String keys and values", filePath); } try { objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); CreateConnectorRequest createConnectorRequest = objectMapper.readValue(connectorConfigurationFile, new TypeReference<>() { }); if (createConnectorRequest.config().containsKey(NAME_CONFIG)) { if (!createConnectorRequest.config().get(NAME_CONFIG).equals(createConnectorRequest.name())) { throw new ConnectException("Connector name configuration in 'config' doesn't match the one specified in 'name' at '" + filePath + "'"); } } else { createConnectorRequest.config().put(NAME_CONFIG, createConnectorRequest.name()); } return createConnectorRequest; } catch (StreamReadException | DatabindException e) { log.debug("Could not parse connector configuration file '{}' into an object of type {}", filePath, CreateConnectorRequest.class.getSimpleName()); } Map<String, String> connectorConfigs = Utils.propsToStringMap(Utils.loadProps(filePath)); if (!connectorConfigs.containsKey(NAME_CONFIG)) { throw new ConnectException("Connector configuration at '" + filePath + "' is missing the mandatory '" + NAME_CONFIG + "' " + "configuration"); } return new CreateConnectorRequest(connectorConfigs.get(NAME_CONFIG), connectorConfigs, null); } @Override protected StandaloneHerder createHerder(StandaloneConfig config, String workerId, Plugins plugins, ConnectorClientConfigOverridePolicy connectorClientConfigOverridePolicy, RestServer restServer, RestClient restClient) { OffsetBackingStore offsetBackingStore = new FileOffsetBackingStore(plugins.newInternalConverter( true, JsonConverter.class.getName(), Map.of(JsonConverterConfig.SCHEMAS_ENABLE_CONFIG, "false"))); offsetBackingStore.configure(config); Worker worker = new Worker(workerId, Time.SYSTEM, plugins, config, offsetBackingStore, connectorClientConfigOverridePolicy); return new StandaloneHerder(worker, config.kafkaClusterId(), connectorClientConfigOverridePolicy); } @Override protected StandaloneConfig createConfig(Map<String, String> workerProps) { return new StandaloneConfig(workerProps); } public static void main(String[] args) { ConnectStandalone connectStandalone = new ConnectStandalone(args); connectStandalone.run(); } }

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.8671.501−286.16
Source linesThe number of non-empty source lines.164+65.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.777−7.166

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

Score0.47

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.165−4.806
Indentation frequencyHow rapidly indentation changes from line to line.141+4.14
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.141−2.815
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.146.964−2.56
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.163.98+1.882
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.146.073+1.552
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.073+0.236

Intercept 0.07 + feature contributions = -2.299 (log-odds).
Score = sigmoid(-2.299) = 0.091.

Score0.119
Score55
Run 1

The code has reasonable structure with clear separation of methods and logical organization, but it contains several readability issues. The presence of an obfuscated empty do-while loop in the usage() method is confusing and appears to be dead code. The parseConnectorConfigurationFile method is long with nested try-catch blocks and repeated error handling. The action granularity is inconsistent, with some lines containing multiple operations (e.g., objectMapper.configure followed by readValue). Reading flow is disrupted by the multiple parsing attempts with similar code patterns. Method signatures are long and sometimes wrapped awkwardly. The Javadoc is helpful, but the method bodies could benefit from better extraction of helper methods. The variable naming is generally clear, though the obfuscated variable in usage() severely hurts readability. Overall, it's functional but not optimized for readability.

Run 2

The code is reasonably structured with clear sections and a logical flow, but has a few issues. The class has a clear purpose and the methods are well-named, but there's a suspicious obfuscated snippet in the `usage()` method (`int lI0O_0ce4b630=0x2D0A...`) that adds confusion and should be removed. The `parseConnectorConfigurationFile` method is overly long and has multiple try-catch blocks that could be extracted for better readability. The nesting is moderate but acceptable. Imports are well-organized, and variable names are generally descriptive. The reading flow is somewhat disrupted by the long method and the unnecessary complexity in some areas. Overall, the code is maintainable but would benefit from refactoring to reduce method length and remove the obfuscated code.

Run 3

The code contains a severe readability issue: an obfuscated dead loop in the 'usage()' method with meaningless variable names ('lI0O_0ce4b630') and no functional purpose. This is highly confusing and damaging. Beyond that, the imports are numerous and not grouped logically, and the 'parseConnectorConfigurationFile' method is long, mixes multiple levels of logic (parsing attempts, error handling, mutation), and has deeply nested if-else blocks. The 'processExtraArgs' method uses a multi-line callback and chains several method calls per line. Variable names like 'cb' are not descriptive. Overall, the code structure is tangled, and the reading flow is unnatural due to the unnecessary loop and dense logic.

Run 1

Code Structure: Methods separate CLI usage, connector processing, configuration parsing, and runtime construction logically. Nesting: Mostly moderate, though connector processing combines try/for/lambda/conditional layers, and name validation has nested conditionals. Clarity of intent: Descriptive identifiers and documentation explain the parsing order well, but the opaque, apparently purposeless block in usage() sharply undermines clarity. Code length: Generally justified, with some repeated mandatory-name validation and verbose expressions. Action granularity: Most statements perform one action per line; the compressed usage() block violates this with multiple declarations and operations on one line. Reading flow: Lifecycle methods and sequential parsing fallbacks are easy to follow, but inconsistent indentation, ungrouped imports, unbraced conditionals, and the obfuscated block interrupt an otherwise natural flow.

Run 2

Code Structure: Methods separate CLI usage, connector initialization, configuration parsing, and runtime construction logically. Nesting: Mostly moderate, though callbacks and nested name-validation conditions add complexity. Clarity of intent: Descriptive names and documentation explain the parsing sequence and standalone behavior, but the obfuscated, purposeless block in usage() sharply undermines clarity. Code length: Generally appropriate, with some repeated validation and verbose expressions; the injected block is unnecessary. Action granularity: Most statements perform one action per line, except the injected block, which compresses declarations, mutation, and looping onto one line. Reading flow: Sequential parsing fallbacks and small factory methods are natural to follow, but inconsistent indentation, ungrouped imports, long lines, and the anomalous usage() block interrupt the flow.

Run 3

Code Structure: Methods separate CLI behavior, configuration parsing, and runtime setup logically, though parsing repeats validation. Nesting: Mostly shallow, with moderate nesting in connector creation and name validation. Clarity of intent: Descriptive names and detailed documentation explain the main functionality, but the unexplained, obfuscated no-op block in usage() significantly undermines clarity. Code length: Generally appropriate, although duplicated validation and the unnecessary block add avoidable length. Action granularity: Most statements perform one action per line; the compressed block packs declarations, assignments, and a loop onto one line. Reading flow: Configuration fallbacks follow a documented order, and setup proceeds naturally. Inconsistent indentation, ungrouped imports, and the abrupt obfuscated insertion interrupt an otherwise readable flow.