Sample

int-f0f7f29fe579-I10

Remove about 40% of line-break groups while retaining structure

Matched original source

Lines57

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.480–1; higher is more readable
Dorn0.0520–1; higher is more readable
Mi0.0010–1; higher is more readable
LLOC14Logical lines; fewer is more readable
DeepSeek V4 Pro6.330–20; mean of three runs
GPT-6.1 Sol12.330–20; mean of three runs
BTTF0.4930–1; higher is more readable

Views

Source code

package org.springframework.http.codec.json; import java.io.InputStreamReader; import java.util.Map; import com.google.gson.Gson; import org.jspecify.annotations.Nullable; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; import org.springframework.core.codec.AbstractDataBufferDecoder; import org.springframework.core.codec.Decoder; import org.springframework.core.codec.DecodingException; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.util.MimeType; /** * {@link Decoder} that reads a byte stream into JSON and converts it to Objects with * <a href="https://google.github.io/gson/">Google Gson</a>. * <p>{@code Flux<*>} target types are not available because non-blocking parsing is not supported, * so this decoder targets only {@code Mono<*>} types. Attempting to decode to a {@code Flux<*>} will * result in a {@link UnsupportedOperationException} being thrown at runtime. * * @author Brian Clozel * @since 7.0 */ public class GsonDecoder extends AbstractDataBufferDecoder<Object> { private static final MimeType[] DEFAULT_JSON_MIME_TYPES = new MimeType[] { MediaType.APPLICATION_JSON, new MediaType("application", "*+json"), }; private final Gson gson; /** * Construct a new decoder using a default {@link Gson} instance * and the {@code "application/json"} and {@code "application/*+json"} * MIME types. */ public GsonDecoder() { this(new Gson(), DEFAULT_JSON_MIME_TYPES); } /** * Construct a new decoder using the given {@link Gson} instance * and the provided MIME types. * @param gson the gson instance to use * @param mimeTypes the mime types the decoder should support */ public GsonDecoder(Gson gson, MimeType... mimeTypes) { super(mimeTypes); Assert.notNull(gson, "A Gson instance is required"); this.gson = gson; } @Override public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType) { return super.canDecode(elementType, mimeType) && !CharSequence.class.isAssignableFrom(elementType.toClass()); } @Override public Flux<Object> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) { throw new UnsupportedOperationException("Stream decoding is currently not supported"); } @Override public @Nullable Object decode(DataBuffer buffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingException { try { return this.gson.fromJson(new InputStreamReader(buffer.asInputStream()), targetType.getType()); } finally { DataBufferUtils.release(buffer); } } }

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.2531.532−83.541
Source linesThe number of non-empty source lines.57+22.8
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.5.141−7.712

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

Score0.48

Feature contributions

FeatureValueContribution
(log-odds)
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.246.966−6.795
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.246.983+3.18
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.58−1.017
Indentation frequencyHow rapidly indentation changes from line to line.39+0.612
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.56.79+0.384
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.069+0.267

Intercept 0.07 + feature contributions = -2.902 (log-odds).
Score = sigmoid(-2.902) = 0.052.

Score0.001
Score14
Run 1

The code has reasonable logical organization with clear class/method boundaries and Javadoc, but suffers from severe formatting issues that hurt readability. Multiple imports and statements are compressed onto single lines, method signatures and bodies are crammed together without line breaks, and some comments are misplaced. This violates the 'one action per line' and 'natural reading flow' criteria. The nesting depth is low (good), and intent is mostly clear from method names and comments, but the dense formatting makes it difficult to scan quickly. Code length is acceptable but formatting inflates perceived complexity. Overall, the logic is sound but presentation is poor, dragging the score down significantly.

Run 2

The code suffers from severe readability problems. Multiple imports are crammed onto single lines, making the header difficult to scan. Method declarations and bodies are placed on the same line in several places, violating the 'one action per line' principle and disrupting reading flow. The class structure is unclear due to these compressed layouts, and nesting in the finally block is poorly formatted. While the intent (a Gson-based JSON decoder) is understandable from the Javadoc and method names, the physical layout obscures the logic. Code length is not excessive, but formatting makes it appear tangled. Action granularity is inconsistent — some methods are properly spaced while others are compressed. Reading flow is disorganized, forcing readers to parse dense lines rather than naturally following the code structure.

Run 3

The code has several readability issues. Multiple import statements are on one line, class declarations and methods are crammed together without proper spacing, and there's inconsistent indentation. The constructor logic is compressed into single lines, mixing multiple actions. While the class has a clear purpose and follows Spring patterns, the formatting makes it difficult to follow. Method boundaries are unclear, comments are poorly positioned, and the overall structure feels disorganized despite being logically coherent. The code would benefit from proper line breaks, consistent indentation, and separation of concerns.

Run 1

Code Structure: The class is logically organized into constants, a dependency field, constructors, capability checks, and decoding methods, but compressed formatting weakens separation. Nesting: Minimal nesting and a simple try/finally make control flow easy to follow. Clarity of intent: Descriptive names, documentation, and an explicit unsupported-operation exception clearly explain the decoder's purpose and limitations. Code length: The implementation is concise without substantial redundancy; long signatures are harder to scan. Action granularity: Multiple imports, constructor statements, annotations, and method declarations share lines, obscuring individual actions and boundaries. Reading flow: The overall sequence is natural, but comments attached to closing braces, inline method bodies, and inconsistent line breaks repeatedly interrupt reading.

Run 2

Code Structure: The class is logically organized into constants, a dependency, constructors, and decoding methods, but compressed formatting obscures these boundaries. Nesting: Minimal nesting, with only a straightforward try/finally block. Clarity of intent: Descriptive names and useful documentation clearly explain Gson decoding and unsupported streaming. Code length: The implementation is concise without substantial unnecessary code, although long signatures and compressed lines hinder scanning. Action granularity: Several lines combine imports, declarations, constructor actions, or method bodies, weakening the one-action-per-line convention. Reading flow: The conceptual sequence is natural, but comments attached to closing braces, inline annotations, crowded imports, and inconsistent brace placement frequently interrupt reading.

Run 3

Code Structure: The class is logically organized into constants, a dependency, constructors, and decoding methods, but compressed formatting blurs these boundaries. Nesting: Minimal nesting, with only a straightforward try/finally block. Clarity of intent: Descriptive names and useful Javadoc clearly explain Gson decoding and the lack of streaming support. Code length: The implementation is concise without substantial redundancy, although long signatures reduce scanability. Action granularity: Several imports, constructor operations, annotations, and method bodies share lines, violating the one-action-per-line convention. Reading flow: The conceptual progression is natural, but comments attached to closing braces, inconsistent line breaks, and crowded declarations repeatedly interrupt reading. Overall, the design is understandable, but formatting significantly weakens readability.