Sample

int-cd0a87fb1d85-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines116

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6220–1; higher is more readable
Dorn0.3930–1; higher is more readable
Mi0.2150–1; higher is more readable
LLOC44Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.4340–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; 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; 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) { 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.4869.167−160.682
Source linesThe number of non-empty source lines.116+46.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.776−7.164

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

Score0.622

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.116+3.275
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.117−3.106
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.974−1.459
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.115.918+1.21
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.099−0.018

Intercept 0.07 + feature contributions = -0.434 (log-odds).
Score = sigmoid(-0.434) = 0.393.

Score0.215
Score44
Run 1

The code demonstrates good structure with clear class hierarchy and well-defined methods. It follows a natural reading flow with methods organized logically. The nesting is minimal, with try-catch blocks being the only notable indentation. Intent is clear throughout; method names accurately describe their purposes and the class is appropriately abstract for number conversion. Code length is reasonable for the functionality provided. Action granularity is good, with most lines containing single operations. The constructor's assert statements are somewhat redundant but don't significantly impact readability. Some minor improvements could include better exception handling structure and more consistent method spacing, but overall the code is highly readable with clear separation of concerns and minimal complexity.

Run 2

The code is generally readable and well-organized. Structure is logical, with a clear class hierarchy and standard converter methods. Nesting is mostly flat; try-catch blocks introduce only one level. Intent is clear from method names and the typeName field. However, there are issues: excessive blank lines (e.g., multiple consecutive empty lines) disrupt visual flow. The constructor uses multiple assert statements for null checks, which is unconventional and less clear than explicit validation. The cast() method with unchecked suppression is somewhat ambiguous. Error handling in fromConnectData has a potential NPE in 'value.getClass()' when value is null. Import section is slightly cluttered. Overall, the code follows a clear pattern but could benefit from cleaner formatting and more idiomatic null handling.

Run 3

The code is generally well-structured with clear class organization, a concise constructor, and straightforward method delegation. Methods are short, focused, and follow a consistent pattern. Nesting is minimal, and exception handling is localized. However, readability is slightly reduced by placeholder methods like `cast()` that rely on unchecked casts, and the `fromConnectData` method has a minor ambiguity due to unchecked cast and exception flow. Overall, the intent is clear, and line granularity is appropriate, but the unchecked cast and redundant wrapper methods slightly lower clarity.

Run 1

Code Structure: Well-organized fields, constructor, configuration, conversion, and cleanup methods; header conversion sensibly delegates to existing methods. Nesting: Shallow, with straightforward try/catch blocks and no complex branching. Clarity of intent: Descriptive names and conventional interfaces make the numeric conversion purpose clear, although the unchecked cast and StringConverterConfig constant require some contextual knowledge. Code length: Methods are concise, but excessive blank lines unnecessarily stretch the class. Action granularity: Each statement performs a focused action; inline conditional expressions remain readable. Reading flow: Mostly natural and consistent, with formatting noise and uneven spacing between methods slightly interrupting scanning.

Run 2

Code Structure: Fields, initialization, configuration, conversion, and cleanup are logically organized into focused methods. Nesting: Control flow is shallow, with simple try/catch blocks and no deeply nested branches. Clarity of intent: Descriptive method and field names make the converter's purpose clear, although the unchecked generic cast and reference to StringConverterConfig in a numeric converter require extra interpretation. Code length: Methods are concise, and header conversion delegates appropriately, but excessive blank lines add unnecessary visual length. Action granularity: Statements generally perform one action per line; compact serialization expressions remain understandable. Reading flow: The lifecycle and conversion methods follow a natural sequence, but inconsistent spacing around imports, fields, and method boundaries interrupts otherwise clean presentation.

Run 3

Code Structure: Fields, construction, configuration, conversion, and cleanup are logically organized into focused methods. Nesting: Minimal nesting, with straightforward try/catch blocks and no complex control flow. Clarity of intent: Descriptive method and field names make the converter's purpose clear; the unchecked generic cast and similarly named configuration variables require some attention. Code length: Implementation is concise, though excessive blank lines add unnecessary visual length. Action granularity: Statements generally perform one action per line; inline serialization and conditional expressions remain manageable. Reading flow: Method ordering and header-method delegation support natural reading, but inconsistent spacing, tightly grouped imports, and a few long lines reduce polish.