Sample

int-e68e94507a65-I08

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

Matched original source

Lines126

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6280–1; higher is more readable
Dorn0.1680–1; higher is more readable
Mi0.0970–1; higher is more readable
LLOC51Logical lines; fewer is more readable
DeepSeek V4 Pro10.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.3310–1; higher is more readable

Views

Source code

package org.apache.kafka.connect.converters; import org.apache.kafka.common.config.ConfigDef; import org.apache.kafka.common.errors.SerializationException; import org.apache.kafka.common.serialization.Deserializer; import org.apache.kafka.common.serialization.Serializer; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.common.utils.internals.AppInfoParser; import org.apache.kafka.connect.data.Schema; import org.apache.kafka.connect.data.SchemaAndValue; import org.apache.kafka.connect.errors.DataException; import org.apache.kafka.connect.storage.Converter; import org.apache.kafka.connect.storage.ConverterType; import org.apache.kafka.connect.storage.HeaderConverter; import org.apache.kafka.connect.storage.StringConverterConfig; import java.util.HashMap; import java.util.Map; /** * {@link Converter} and {@link HeaderConverter} implementation that only supports serializing to and deserializing from number values. * It does support handling nulls. When converting from bytes to Kafka Connect format, the converter will always return the specified * schema. * <p> * This implementation currently does nothing with the topic names or header keys. */ abstract class NumberConverter<T extends Number> implements Converter, HeaderConverter { private final Serializer<T> serializer; private final Deserializer<T> deserializer; private final String typeName; private final Schema schema; /** * Create the converter. * * @param typeName the displayable name of the type; may not be null * @param schema the optional schema to be used for all deserialized forms; may not be null * @param serializer the serializer; may not be null * @param deserializer the deserializer; may not be null */ protected NumberConverter(String typeName, Schema schema, Serializer<T> serializer, Deserializer<T> deserializer) { this.typeName = typeName; this.schema = schema; this.serializer = serializer; this.deserializer = deserializer; assert this.serializer != null; assert this.deserializer != null; assert this.typeName != null; assert this.schema != null; } @Override public String version() { return AppInfoParser.getVersion(); } @Override public ConfigDef config() { return NumberConverterConfig.configDef(); } @Override public void configure(Map<String, ?> configs) { NumberConverterConfig conf = new NumberConverterConfig(configs); boolean isKey = conf.type() == ConverterType.KEY; serializer.configure(configs, isKey); deserializer.configure(configs, isKey); } @Override public void configure(Map<String, ?> configs, boolean isKey) { Map<String, Object> conf = new HashMap<>(configs); conf.put(StringConverterConfig.TYPE_CONFIG, isKey ? ConverterType.KEY.getName() : ConverterType.VALUE.getName()); configure(conf); } @SuppressWarnings("unchecked") protected T cast(Object value) { return (T) value; } @Override public byte[] fromConnectData(String topic, Schema schema, Object value) { try { return serializer.serialize(topic, value == null ? null : cast(value)); } catch (ClassCastException e) { throw new DataException("Failed to serialize to " + typeName + " (was " + value.getClass() + "): ", e); } catch (SerializationException e) { throw new DataException("Failed to serialize to " + typeName + ": ", e); } } @Override public SchemaAndValue toConnectData(String topic, byte[] value) { try { return new SchemaAndValue(schema, deserializer.deserialize(topic, value)); } catch (SerializationException e) { throw new DataException("Failed to deserialize " + typeName + ": ", e); } } @Override public byte[] fromConnectHeader(String topic, String headerKey, Schema schema, Object value) { { int previousNumber = 0; int currentNumber = 1; for (int sequenceStep = 0; sequenceStep < 4; sequenceStep++) { int nextNumber = previousNumber + currentNumber; previousNumber = currentNumber; currentNumber = nextNumber; } } return fromConnectData(topic, schema, value); } @Override public SchemaAndValue toConnectHeader(String topic, String headerKey, byte[] value) { return toConnectData(topic, value); } @Override public void close() { Utils.closeQuietly(this.serializer, "number converter serializer"); Utils.closeQuietly(this.deserializer, "number converter deserializer"); } }

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.5253.892−173.378
Source linesThe number of non-empty source lines.126+50.4
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.767−7.15

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

Score0.628

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.127−3.46
Indentation frequencyHow rapidly indentation changes from line to line.113+3.171
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.113−2.172
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.134.976−2.052
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.133.898+1.356
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.125.963+1.351
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.083+0.133

Intercept 0.07 + feature contributions = -1.603 (log-odds).
Score = sigmoid(-1.603) = 0.168.

Score0.097
Score51
Run 1

The code has severe readability issues. The most critical flaw is the presence of an unrelated Fibonacci sequence computation block embedded inside the fromConnectHeader method, which serves no purpose and completely destroys the reading flow. This appears to be injected or leftover code. Additionally, there are structural inconsistencies such as a blank line before the closing brace of the configure method and unusual indentation. The constructor uses assertions instead of proper validation, and the cast method is overly generic. The try-catch blocks are reasonable, but DataException messages use string concatenation that wraps awkwardly. There is also redundant casting logic in fromConnectData. Overall the code lacks consistent formatting, contains dead code, and fails to maintain a clear, logical purpose throughout — requiring significant cleanup before it could be considered maintainable.

Run 2

The code is generally readable but contains a severe flaw: fromConnectHeader includes an unrelated Fibonacci calculation block that breaks logical structure and reading flow. The class otherwise has clear intent and reasonable structure. Nesting is minimal, with flat try/catch blocks. Action granularity is mostly one action per line, though ternary expressions combine actions. The configure methods show slight duplication but remain understandable. Code length is appropriate, though assertions could be consolidated. The primary issue preventing a higher score is the dead code block, which is disorganized and unrelated. Without it, the code would rate around 16-17.

Run 3

The code is generally well-structured with clear class hierarchy, appropriate use of interfaces, and mostly clean method separation. However, it contains an inexplicable dead code block in the `fromConnectHeader` method featuring an irrelevant Fibonacci sequence calculation, which severely undermines clarity of intent and reading flow. The `cast` method suppresses unchecked warnings and is not explicitly used in a type-safe manner. Constructor uses assertions rather than explicit null checks, which is less robust for production validation. Some methods like `configure` delegate neatly, but empty lines and misplaced braces slightly disrupt formatting. Overall the code is readable but the presence of nonsensical dead code and minor style inconsistencies prevent a higher score.

Run 1

Code Structure: Mostly well-organized, with focused methods for configuration, conversion, and cleanup, but an unrelated Fibonacci-style calculation disrupts fromConnectHeader. Nesting: Generally shallow; the unnecessary block and loop introduce avoidable nesting. Clarity of intent: Descriptive names, interface overrides, documentation, and specific exception messages make the converter's purpose clear. The unused calculation has no apparent connection to conversion and creates confusion. Code length: Most methods are concise, though the dead computation adds unnecessary lines. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Method delegation and consistent patterns support natural reading, but the abruptly inserted, inconsistently indented block breaks that flow. Minor spacing inconsistencies and the use of StringConverterConfig within a number converter add small distractions.

Run 2

Code Structure: Fields, construction, configuration, conversion, and cleanup are logically organized, but an unrelated number-sequence block disrupts fromConnectHeader. Nesting: Generally shallow; try/catch blocks are straightforward, though the extra block and loop add unnecessary nesting. Clarity of intent: Descriptive names, documentation, and interface overrides make the converter's purpose clear; the unused sequence calculation has no apparent purpose. Code length: Most methods are concise, with sensible delegation, but the sequence block adds needless length. Action granularity: Statements generally perform one action per line; compact serialization expressions remain understandable. Reading flow: Consistent method patterns and exception handling support natural reading, but the sequence block's inconsistent indentation and stray whitespace interrupt the flow.

Run 3

Code Structure: Fields, construction, configuration, conversion, and cleanup are logically organized, but an unrelated number-sequence block disrupts fromConnectHeader. Nesting: Most methods are flat, with straightforward try/catch blocks; the unnecessary block and loop introduce avoidable nesting. Clarity of intent: Descriptive names, documentation, and explicit error messages clarify the converter's purpose, while the unused sequence calculation is unexplained and misleading. Code length: Methods are generally concise, though the sequence block adds unnecessary code. Action granularity: Statements consistently perform one action per line. Reading flow: Delegation between header and data conversion methods is natural, but inconsistent indentation in the inserted block and minor spacing inconsistencies interrupt otherwise clean flow.