Sample

int-7e940c6a519f-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines116

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6410–1; higher is more readable
Dorn0.690–1; higher is more readable
Mi0.1180–1; higher is more readable
LLOC44Logical lines; fewer is more readable
DeepSeek V4 Pro7.670–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.4060–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 type2, Schema sch, Serializer<T> ser, Deserializer<T> des) { this.typeName = type2; this.schema = sch; this.serializer = ser; this.deserializer = des; assert this.serializer != null; assert this.deserializer != null; assert this.typeName != null; assert this.schema != null; } @Override public String ver() { return AppInfoParser.getVersion(); } @Override public ConfigDef con() { return NumberConverterConfig.configDef(); } @Override public void con2(Map<String, ?> con) { NumberConverterConfig con2 = new NumberConverterConfig(con); boolean is = con2.type() == ConverterType.KEY; serializer.configure(con, is); deserializer.configure(con, is); } @Override public void con2(Map<String, ?> con3, boolean is2) { Map<String, Object> con4 = new HashMap<>(con3); con4.put(StringConverterConfig.TYPE_CONFIG, is2 ? ConverterType.KEY.getName() : ConverterType.VALUE.getName()); con2(con4); } @SuppressWarnings("unchecked") protected T cas(Object val) { return (T) val; } @Override public byte[] from(String top, Schema sch2, Object val2) { try { return serializer.serialize(top, val2 == null ? null : cas(val2)); } catch (ClassCastException e) { throw new DataException("Failed to serialize to " + typeName + " (was " + val2.getClass() + "): ", e); } catch (SerializationException e) { throw new DataException("Failed to serialize to " + typeName + ": ", e); } } @Override public SchemaAndValue to(String top2, byte[] val3) { try { return new SchemaAndValue(schema, deserializer.deserialize(top2, val3)); } catch (SerializationException e) { throw new DataException("Failed to deserialize " + typeName + ": ", e); } } @Override public byte[] from2(String top3, String header, Schema sch3, Object val4) { return from(top3, sch3, val4); } @Override public SchemaAndValue to2(String top4, String header2, byte[] val5) { return to(top4, val5); } @Override public void clo() { 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.5009.251−165.305
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.78−7.17

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

Score0.641

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.117−3.106
Indentation frequencyHow rapidly indentation changes from line to line.103+2.826
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.974−2.052
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.133.803+1.354
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.115.875+1.21
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.087+0.1

Intercept 0.07 + feature contributions = 0.8 (log-odds).
Score = sigmoid(0.8) = 0.69.

Score0.118
Score44
Run 1

The code has a reasonable class structure and follows a converter pattern, but readability is severely hampered by poor naming and inconsistent method signatures. Parameters like 'type2', 'sch', 'ser', 'des', 'top2', 'val3', 'con2', 'con3', 'is2', etc. obscure intent and force the reader to constantly backtrack. Method names such as 'ver()', 'con()', 'con2()', 'from2()', 'to2()', 'clo()' are cryptic abbreviations that break natural reading flow. There is some nesting but it is shallow; main issues are clarity and granularity. The try-catch blocks are acceptable but the multiple actions in some methods (e.g., creating config, checking type, configuring serializer and deserializer) reduce action granularity. The constructor uses assertions for validation which is not consistent with typical production code. Overall, while the logic is not deeply nested and the class is not overly long, the poor naming and unclear method contracts make it difficult to read and maintain.

Run 2

The code has a logical class structure and mostly flat nesting, but readability is severely undermined by vague, abbreviated identifiers (e.g., 'ver', 'con', 'con2', 'cas', 'from', 'to', 'from2', 'to2', 'clo') that obscure intent. Parameter names like 'type2', 'sch', 'ser', 'des', 'val2', 'val3' further reduce clarity. The class implements two interfaces but methods are renamed in a confusing way, making it hard to infer their purpose from names alone. Error handling is reasonable, and each line generally performs one action, but the overall reading flow is disrupted by the need to constantly decode abbreviations. The code is not deeply nested or excessively long, but the lack of descriptive naming prevents it from being considered readable.

Run 3

The code has clear structure and follows some conventions, but readability is severely undermined by poor naming. Methods like con(), con2(), to(), to2(), from2(), and parameter names like type2, sch, ser, des, top2, val3 make the intent ambiguous. While the logic itself is relatively flat and concise, the abbreviations obscure meaning and force the reader to infer behavior. Action granularity is generally good, and the flow is mostly logical. However, the obfuscated method and parameter names create a high cognitive load, making the code harder to read and maintain despite its otherwise clean organization and modest length.

Run 1

Code Structure: Fields, construction, configuration, conversion, and cleanup are logically separated into small methods. Nesting: Very shallow; simple try/catch blocks and ternary expressions keep complexity low. Clarity of intent: Descriptive class and field names help, but abbreviated methods such as con2, cas, and clo and numbered parameters such as val4 obscure meaning. Constructor documentation also uses parameter names that do not match the signature. Code length: Concise overall, with useful delegation avoiding duplicated conversion logic. Action granularity: Generally one statement per line, although some expressions combine several operations. Reading flow: Method ordering is natural, but inconsistent spacing, cryptic naming, and mismatched documentation interrupt comprehension.

Run 2

Code Structure: Fields, construction, configuration, conversion, and cleanup are logically organized into separate methods. Nesting: Shallow try/catch blocks and simple expressions keep nesting minimal. Clarity of intent: Descriptive field names and class documentation help, but abbreviated methods such as con2, cas, and clo, and numbered variables such as val4 and top3 obscure meaning. Constructor parameter names also mismatch the Javadoc tags. Code length: The implementation is compact, with little unnecessary code; delegation avoids duplication. Action granularity: Most lines perform a single action, although configuration and serialization expressions combine several operations. Reading flow: Method grouping and straightforward control flow are natural, but inconsistent spacing and cryptic naming repeatedly force readers to infer purpose.

Run 3

Code Structure: Logically organized into construction, configuration, conversion, and cleanup, with header conversion delegated to existing methods. Nesting: Shallow; simple methods and try/catch blocks are easy to follow. Clarity of intent: Descriptive fields and class documentation explain the purpose, but abbreviated method names such as con2, cas, and clo, plus numbered variables, obscure meaning. Constructor documentation also names parameters differently from the signature. Code length: Reasonably concise, with little unnecessary duplication. Action granularity: Most lines perform one action, although nested calls and ternary expressions compress some operations. Reading flow: The method sequence is natural, but inconsistent spacing and cryptic naming require extra mental translation.