Sample

int-04a84dd6046c-I08

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

Matched original source

Lines86

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5010–1; higher is more readable
Dorn0.1130–1; higher is more readable
Mi0.2810–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro12.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4210–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); { boolean featureEnabled = false; for (int toggleCount = 0; toggleCount < 3; toggleCount++) { featureEnabled = !featureEnabled; } } 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.2764.442−91.227
Source linesThe number of non-empty source lines.86+34.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.5.158−7.737

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

Score0.501

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.169.977−3.534
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.87−2.044
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.169.989+1.938
Indentation frequencyHow rapidly indentation changes from line to line.68+1.615
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.68−1.14
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.85.942+0.791
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.072+0.241

Intercept 0.07 + feature contributions = -2.063 (log-odds).
Score = sigmoid(-2.063) = 0.113.

Score0.281
Score18
Run 1

The code has a clear class structure with logical organization and good Javadoc documentation. Nested depth is generally low, and method granularity is mostly one action per line. However, clarity and readability are seriously undermined by a bizarre, injected block of no-op code in the constructor that appears intentional but serves no purpose—it toggles a boolean three times. This disrupts reading flow, creates confusion about intent, and adds dead code. Additionally, the custom constructor parameter 'mimeTypes' is unused beyond being passed to super, and the decode-to-Flux method throwing UnsupportedOperationException is documented but still a sharp edge. The try/finally resource release is clean, but the overall score is dragged down by the unexplained dead code fragment.

Run 2

The code has a clear class structure and Javadoc, making intent reasonably understandable. However, several issues hurt readability: a nonsensical dead-code block with a pointless loop and featureEnabled variable appears in the constructor, breaking flow and intent. The decode methods are mostly clear, but the method throwing UnsupportedOperationException is needlessly split across lines and could be more concise. Imports and field declarations are organized, but the stray block adds confusion. Nesting is mostly flat and action granularity is generally okay, but the inserted dead code and some verbose formatting reduce clarity. Overall, readable but marred by an apparent copy-paste artifact and minor verbosity.

Run 3

The code is generally readable but contains a confusing block of dead code in the constructor with misleading variable names (featureEnabled, toggleCount) that serves no purpose, reducing clarity and flow. The class structure is logical and the intent is mostly clear with good Javadocs. Nesting is minimal, and action granularity is appropriate. However, the dead code block adds unnecessary length and confuses readability. The decode methods are concise and clear, and exception handling with resource release is well-managed. The unused import and abrupt bracing also slightly detract from readability.

Run 1

Code Structure: The class is logically organized into constants, constructors, and decoder methods, but the unrelated feature-toggle block disrupts the constructor. Nesting: Most code is flat; the extra scoped block and loop introduce unnecessary nesting. Clarity of intent: Descriptive names, documentation, and explicit exceptions explain the decoder's purpose, while the unused featureEnabled variable creates confusion. Code length: Implementation methods are concise, but the toggle loop adds pointless length and several signatures are long. Action granularity: Statements generally perform one action per line. Reading flow: Conventional method ordering and try/finally resource cleanup support natural reading, but inconsistent indentation in the inserted block and tightly packed imports reduce readability.

Run 2

Code Structure: Fields, constructors, and decoding methods are logically organized, but the unrelated featureEnabled block disrupts the constructor. Nesting: Generally shallow; the unnecessary block and loop add avoidable nesting. Clarity of intent: Documentation, descriptive names, and straightforward Gson delegation clearly explain the decoder, while the unused toggle logic has no apparent purpose. Code length: Mostly concise, with redundant toggle code and long method signatures reducing readability. Action granularity: Statements generally perform one action per line, and buffer cleanup is explicitly separated in a finally block. Reading flow: The class follows a natural progression and consistent conventions overall, but the anomalous block's indentation and placement interrupt the flow.

Run 3

Code Structure: Fields, constructors, and decoding overrides are logically organized, but an unrelated toggle block interrupts the constructor. Nesting: Mostly shallow; the unnecessary block and loop add avoidable nesting. Clarity of intent: Documentation, descriptive names, and explicit unsupported-stream behavior clearly explain the decoder's purpose. The unused featureEnabled variable and repeated toggling have no apparent purpose. Code length: The implementation is concise overall, except for the extraneous constructor block. Action granularity: Statements generally perform one action per line; the compact decoding expression remains understandable. Reading flow: Method ordering and try/finally resource cleanup support natural reading, but inconsistent indentation in the toggle block and long method signatures disrupt scanning.