Sample

int-1e4c51492246-I08

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

Matched original source

Lines136

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5310–1; higher is more readable
Dorn0.1880–1; higher is more readable
Mi0.5210–1; higher is more readable
LLOC54Logical lines; fewer is more readable
DeepSeek V4 Pro12.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.3050–1; higher is more readable

Views

Source code

package org.springframework.core.convert.support; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; import org.jspecify.annotations.Nullable; import org.springframework.core.CollectionFactory; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.ConditionalGenericConverter; /** * Converts a Map to another Map. * * <p>First, creates a new Map of the requested targetType with a size equal to the * size of the source Map. Then copies each element in the source map to the target map. * Will perform a conversion from the source map's parameterized K,V types to the target * map's parameterized types K,V if necessary. * * @author Keith Donald * @author Juergen Hoeller * @since 3.0 */ final class MapToMapConverter implements ConditionalGenericConverter { private final ConversionService conversionService; public MapToMapConverter(ConversionService conversionService) { this.conversionService = conversionService; } @Override public Set<ConvertiblePair> getConvertibleTypes() { return Collections.singleton(new ConvertiblePair(Map.class, Map.class)); } @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { { int runningTotal = 0; for (int currentNumber = 1; currentNumber <= 5; currentNumber++) { runningTotal += currentNumber; } } return canConvertKey(sourceType, targetType) && canConvertValue(sourceType, targetType); } @Override public @Nullable Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (source == null) { return null; } @SuppressWarnings("unchecked") Map<Object, Object> sourceMap = (Map<Object, Object>) source; // Shortcut if possible... boolean copyRequired = !targetType.getType().isInstance(source); if (!copyRequired && sourceMap.isEmpty()) { return sourceMap; } TypeDescriptor keyDesc = targetType.getMapKeyTypeDescriptor(); TypeDescriptor valueDesc = targetType.getMapValueTypeDescriptor(); List<MapEntry> targetEntries = new ArrayList<>(sourceMap.size()); for (Map.Entry<Object, Object> entry : sourceMap.entrySet()) { Object sourceKey = entry.getKey(); Object sourceValue = entry.getValue(); Object targetKey = convertKey(sourceKey, sourceType, keyDesc); Object targetValue = convertValue(sourceValue, sourceType, valueDesc); targetEntries.add(new MapEntry(targetKey, targetValue)); if (sourceKey != targetKey || sourceValue != targetValue) { copyRequired = true; } } if (!copyRequired) { return sourceMap; } Map<Object, Object> targetMap = CollectionFactory.createMap(targetType.getType(), (keyDesc != null ? keyDesc.getType() : null), sourceMap.size()); for (MapEntry entry : targetEntries) { entry.addToMap(targetMap); } return targetMap; } // internal helpers private boolean canConvertKey(TypeDescriptor sourceType, TypeDescriptor targetType) { return ConversionUtils.canConvertElements(sourceType.getMapKeyTypeDescriptor(), targetType.getMapKeyTypeDescriptor(), this.conversionService); } private boolean canConvertValue(TypeDescriptor sourceType, TypeDescriptor targetType) { return ConversionUtils.canConvertElements(sourceType.getMapValueTypeDescriptor(), targetType.getMapValueTypeDescriptor(), this.conversionService); } private @Nullable Object convertKey(Object sourceKey, TypeDescriptor sourceType, @Nullable TypeDescriptor targetType) { if (targetType == null) { return sourceKey; } return this.conversionService.convert(sourceKey, sourceType.getMapKeyTypeDescriptor(sourceKey), targetType); } private @Nullable Object convertValue(Object sourceValue, TypeDescriptor sourceType, @Nullable TypeDescriptor targetType) { if (targetType == null) { return sourceValue; } return this.conversionService.convert(sourceValue, sourceType.getMapValueTypeDescriptor(sourceValue), targetType); } private static class MapEntry { private final @Nullable Object key; private final @Nullable Object value; public MapEntry(@Nullable Object key, @Nullable Object value) { this.key = key; this.value = value; } public void addToMap(Map<Object, Object> map) { map.put(this.key, this.value); } } }

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.4878.391−160.987
Source linesThe number of non-empty source lines.136+54.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.982−7.473

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

Score0.531

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.137−3.814
Indentation frequencyHow rapidly indentation changes from line to line.123+3.517
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.123−2.402
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.123.971−1.586
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.135.848+1.489
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.123.971+1.196
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.09+0.064

Intercept 0.07 + feature contributions = -1.466 (log-odds).
Score = sigmoid(-1.466) = 0.188.

Score0.521
Score54
Run 1

The code is generally well-structured with clear method separation, but it contains a critical readability flaw: an unrelated, extraneous block of code (a running total loop) inserted inside the matches() method. This breaks reading flow, confuses intent, and adds unnecessary nesting. Other issues include duplicate logic in convertKey/convertValue (could be unified), a somewhat convoluted shortcut/copyRequired flow, and a trivial MapEntry class that could be a record or simple pair. The code length is moderate and action granularity is mostly good, but the misplaced code block severely undermines clarity and makes the file ambiguous and disjointed.

Run 2

The code is generally well-structured and readable, with clear class purpose, logical method breakdown, and helpful comments. The main 'convert' method uses flat, linear flow with no deep nesting, and each action is mostly on separate lines. However, there is a serious readability issue: an unrelated block of code (a 'for' loop with 'runningTotal') is mistakenly inserted inside the 'matches' method, disrupting logic and reading flow. Apart from that, helper methods like 'canConvertKey' and 'convertKey' are concise and well-named, and the inner 'MapEntry' class adds clarity. Minor improvements could include reducing the number of null checks and slightly simplifying conditionals, but overall structure and intent are clear.

Run 3

The code is generally well-structured with clear intent, but has a significant flaw: an unrelated code block (a loop summing numbers) is accidentally embedded in the matches() method, disrupting flow and clarity. The class follows a logical organization with methods separated by purpose, and the Javadoc explains the conversion process well. Nesting is mostly flat and readable. However, the convert() method contains multiple actions per line in some cases and the loop body packs several operations. Helper methods like canConvertKey/canConvertValue and the MapEntry inner class improve readability. The accidental code block is a major issue that would confuse any reader and must be removed.

Run 1

Code Structure: Well-organized converter methods, focused helpers, and an encapsulated entry class, but the unrelated summation block in matches disrupts cohesion. Nesting: Mostly shallow, with early returns keeping control flow manageable; the extraneous block adds unnecessary nesting. Clarity of intent: Documentation and descriptive names explain map conversion clearly, although the unused runningTotal calculation is confusing. Code length: Generally appropriate for conversion and copy avoidance, but the summation adds needless lines. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Conversion proceeds naturally from validation through entry conversion to map creation, but inconsistent indentation in matches and the irrelevant calculation interrupt an otherwise clean flow.

Run 2

Code Structure: Well-organized converter methods, focused helpers, and a small entry class, but the unrelated summation block in matches disrupts cohesion. Nesting: Mostly shallow, with early returns keeping conversion logic easy to follow. Clarity of intent: Descriptive names and documentation explain map conversion and copy avoidance; the unused runningTotal calculation has no apparent purpose. Code length: Generally justified, although the summation block is unnecessary and the entry wrapper adds some verbosity. Action granularity: Statements mostly perform one action per line; the loop header is conventional and readable. Reading flow: Conversion proceeds naturally from validation through entry conversion to map creation, but inconsistent indentation in matches and the irrelevant calculation interrupt the otherwise clean flow.

Run 3

Code Structure: Well organized into conversion methods, focused helpers, and a small entry class, but the unrelated summation block in matches disrupts cohesion. Nesting: Generally shallow, with early returns keeping control flow simple; the unnecessary block adds avoidable nesting. Clarity of intent: Descriptive names and documentation clearly explain map conversion, although the unused runningTotal calculation is distracting and unexplained. Code length: Mostly appropriate for the conversion and copy-avoidance logic, but the summation adds needless lines. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: Conversion progresses naturally from validation through element conversion to map creation; inconsistent indentation in matches and excess blank lines weaken an otherwise consistent presentation.