Sample

int-a8d7f48b893e-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines129

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5340–1; higher is more readable
Dorn0.7640–1; higher is more readable
Mi0.290–1; higher is more readable
LLOC50Logical lines; fewer is more readable
DeepSeek V4 Pro90–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.3590–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) { return canConvertKey(sourceType, targetType) && canConvertValue(sourceType, targetType); } @Override public @Nullable Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (!((source == null))) {} else { 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()))) {} else { 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))) {} else { copyRequired = true; } } if (!((!copyRequired))) {} else { 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))) {} else { 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))) {} else { 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.4941.324−163.064
Source linesThe number of non-empty source lines.129+51.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.984−7.475

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

Score0.534

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.130−3.567
Indentation frequencyHow rapidly indentation changes from line to line.116+3.275
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.977−1.586
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.128.904+1.392
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.123.985+1.196
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.097−0.002

Intercept 0.07 + feature contributions = 1.176 (log-odds).
Score = sigmoid(1.176) = 0.764.

Score0.29
Score50
Run 1

The code has a clear class purpose and documentation, but readability is severely hindered by bizarre inverted conditional patterns like 'if (!((source == null))) {} else { return null; }' and 'if (!((!copyRequired && sourceMap.isEmpty()))) {} else { return sourceMap; }'. These empty-if blocks with inverted logic are confusing, non-idiomatic Java, and add unnecessary nesting and mental overhead. The class does maintain good separation of concerns via helper methods and a small inner class, and line-level granularity is acceptable. However, the inverted conditions break natural reading flow and make intent hard to discern. Additionally, some duplicate logic and verbose null checks further reduce clarity. Overall, the structure is sound but the conditional style is a major readability flaw.

Run 2

The code has clear intent and logical structure but is marred by bizarre inverted conditionals like `if (!((source == null))) {} else { return null; }`. This pattern appears multiple times, severely hurting readability despite the code being otherwise well-organized. The nesting is flat, method granularity is one action per line, and naming is clear. However, the inverted empty-if blocks force the reader to mentally invert logic repeatedly, breaking reading flow and clarity. The class is appropriately concise for its purpose, and helper methods are well-separated. The Javadoc is helpful. Straightforward `if (source == null)` expressions would improve readability dramatically. The code shows good structure overall, but the unusual conditionals are a significant obstacle.

Run 3

The code has clear structure and methods are logically organized, but readability is severely compromised by bizarre conditional patterns like `if (!((source == null))) {} else { return null; }`. These empty-if blocks with negated conditions are unintuitive and obfuscate intent. Nesting is mostly flat, but the strange conditionals disrupt reading flow. Several methods are reasonably concise, but the conversion logic mixes concerns and performs multiple actions per iteration (converting key/value, checking for changes, adding entries). The class and method names are clear, and the Javadoc provides good context, but these strengths are outweighed by the confusing conditional style. The use of `MapEntry` as an intermediate structure adds clarity for batch processing, yet the overall execution path is hard to follow due to repeated inverted logic patterns. A reader must mentally invert each condition to understand when actions occur, which significantly hampers maintainability and quick comprehension.

Run 1

Code Structure: Logically organized into conversion, compatibility checks, and focused helpers, with a small entry class. Nesting: Generally shallow, though empty if branches followed by else blocks add needless complexity. Clarity of intent: Descriptive names and documentation explain map conversion well, but repeatedly negated, over-parenthesized conditions obscure straightforward checks. Code length: Mostly justified, although verbose conditional forms and boilerplate inflate the implementation. Action granularity: Most statements perform one action per line; compact empty-branch conditionals are a notable exception. Reading flow: The progression from validation through entry conversion to map construction is coherent, but inverted conditions repeatedly interrupt natural reading. Replacing these with direct guard clauses would substantially improve readability.

Run 2

Code Structure: Well-organized converter with separate key/value helpers and a small entry class. Nesting: Mostly shallow, with straightforward loops and early returns, although empty if branches followed by else blocks add needless complexity. Clarity of intent: Descriptive names and documentation explain map conversion, but repeated negations and redundant parentheses obscure simple conditions. Code length: Reasonably focused overall, though malformed-looking conditionals and some boilerplate make it longer than necessary. Action granularity: Most statements perform one action per line; compressed empty branches are the main exception. Reading flow: Conversion proceeds logically from validation through entry conversion to map creation, but readers must repeatedly decode inverted conditions, interrupting an otherwise natural flow.

Run 3

Code Structure: Well-organized converter with focused helper methods and an isolated entry class. Nesting: Generally shallow, with simple loops and early returns, but empty if branches followed by else blocks add needless complexity. Clarity of intent: Descriptive names and documentation explain map conversion well; repeatedly negated, over-parenthesized conditions obscure otherwise straightforward checks. Code length: Mostly reasonable, though verbose conditional forms and the intermediate entry wrapper add reading overhead. Action granularity: Most lines perform one clear action; compressed empty branches reduce visual clarity. Reading flow: Conversion proceeds logically from validation through entry conversion to map creation, but inverted conditions repeatedly interrupt that flow and require mental simplification.