Sample

int-38b18616f8a6-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines129

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5090–1; higher is more readable
Dorn0.40–1; higher is more readable
Mi0.2780–1; higher is more readable
LLOC50Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.3540–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; 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) { return null; } @SuppressWarnings("unchecked") Map<Object, Object> sourceMap = (Map<Object, Object>) source; 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; } 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.4610.646−152.151
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.955−7.432

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

Score0.509

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.129+3.725
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.130−3.567
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.864+1.391
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.1−0.032

Intercept 0.07 + feature contributions = -0.405 (log-odds).
Score = sigmoid(-0.405) = 0.4.

Score0.278
Score50
Run 1

The code is well-structured with clear separation of concerns: conversion logic is split into helper methods (canConvertKey, convertKey, etc.) and a private MapEntry class. Nesting is minimal, with only one loop and a few conditional checks. The intent is clear—converting Map types while preserving efficiency when no conversion is needed. Action granularity is mostly one operation per line, aiding readability. The reading flow is natural, moving from type checking to key/value conversion, then target map population. Minor deductions: the `copyRequired` logic could be slightly simplified, and the large blank line blocks or comments (like the stray ' '# space) are minor style issues. Overall, highly readable and maintainable.

Run 2

The code is well-structured with clear separation of concerns and consistent naming conventions. The class implements ConditionalGenericConverter with focused helper methods (canConvertKey/Value, convertKey/Value) that maintain a flat, readable hierarchy. Nesting is minimal: the main convert method has only one level of loop nesting. Each line performs a single logical action, contributing to clear intent. The code is concise without unnecessary comments or boilerplate. Minor deductions: the `copyRequired` logic and the double-pass approach (building entries list, then populating target map) could be slightly streamlined, and the mysterious blank comment lines add no value. The overall flow is natural and the method decomposition makes the conversion process easy to follow.

Run 3

The code is well-structured with clear separation of concerns. Methods are logically organized and have single responsibilities. Nesting is minimal, mostly limited to a single for-loop with one conditional inside. Intent is generally clear through descriptive method names like canConvertKey, convertKey, and MapEntry. Code length is appropriate for the task—not overly verbose. Action granularity follows the 'one action per line' principle well, especially in the conversion loop. Reading flow is natural: types, constructor, converter interface methods, then private helpers. Minor deductions for the stray whitespace/comments on lines, the long getConvertibleTypes method call wrapped across lines, and the slightly complex convert method which could benefit from extraction. Overall, this is highly readable production-quality code.

Run 1

Code Structure: Well-organized converter with focused helper methods and a small entry class. Nesting: Shallow conditionals and loops, with early returns keeping control flow straightforward. Clarity of intent: Descriptive names make key/value conversion clear, although identity comparisons and deferred map creation require some thought without explanatory comments. Code length: Mostly concise, but excessive blank lines, parallel helper methods, and the entry wrapper add visual and structural overhead. Action granularity: Statements generally perform one action per line, making individual steps easy to follow. Reading flow: Conversion proceeds naturally from validation through entry conversion to map creation; buffering entries and traversing them again slightly complicates the flow.

Run 2

Code Structure: Well organized into conversion logic, focused helper methods, and a small entry class. Nesting: Shallow loops and conditionals, with early returns keeping control flow simple. Clarity of intent: Descriptive method and variable names communicate map conversion clearly; identity comparisons and deferred map creation could benefit from a brief explanation. Code length: Mostly concise, though excessive blank lines, similar key/value helpers, and the entry wrapper add some bulk. Action granularity: Statements generally perform one action per line, making transformations easy to follow. Reading flow: The main method progresses naturally from validation through conversion to result creation, but irregular whitespace and the intermediate entry list slightly interrupt readability.

Run 3

Code Structure: Well organized into conversion, compatibility checks, and focused helpers, with a small entry-holder class. Nesting: Shallow loops and conditionals; early returns avoid deep nesting. Clarity of intent: Descriptive names make map conversion clear, though identity comparisons and deferred copying would benefit from a brief explanation. Code length: Mostly concise, but excessive blank lines, parallel key/value helpers, and the entry-holder class add some overhead. Action granularity: Each statement generally performs one action, making operations easy to follow. Reading flow: The progression from null handling through entry conversion to conditional map creation is natural, although large whitespace gaps interrupt scanning. Overall, readable and maintainable with minor formatting and explanatory improvements.