Sample

int-5a155803b265-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines79

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.4640–1; higher is more readable
Dorn0.0470–1; higher is more readable
Mi0.5620–1; higher is more readable
LLOC14Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5650–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; 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; public GsonDecoder() { this(new Gson(), DEFAULT_JSON_MIME_TYPES); } 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.79+31.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.5.162−7.742

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

Score0.464

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.988−3.535
Indentation frequencyHow rapidly indentation changes from line to line.79+1.995
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.80−1.796
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.78.924+0.693
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.029

Intercept 0.07 + feature contributions = -3.008 (log-odds).
Score = sigmoid(-3.008) = 0.047.

Score0.562
Score14
Run 1

The code is generally well-structured and readable. It follows a clean class layout with fields, constructors, and overridden methods, and each method is concise with a single clear responsibility. Nesting is minimal, and intent is mostly clear. However, readability is slightly reduced by a long decode method chain, long parameter lists on decode methods, and a mildly convoluted canDecode condition. Overall, it is a short, focused class with only minor style issues.

Run 2

The code is generally well-structured and readable. It follows Spring framework conventions, with clear class and method organization. Imports are ordered and the class has a single responsibility. The constructor delegation is clean and the `canDecode` method is concise with clear intent. However, there are minor readability issues: several blank lines of irregular length between members (e.g., 5–10 empty lines) disrupt reading flow, and the `decode` method combining `fromJson` with `InputStreamReader` on one line slightly reduces action granularity. Nesting is minimal (only one try-finally), and naming is clear. The unsupported stream decode method explicitly throws an exception, which is good for clarity. Overall, the code is readable but could be improved by consistent spacing and splitting the Gson parsing expression into a separate line for clarity.

Run 3

The code is generally well-structured and readable. It has clear class organization, minimal nesting, and explicit method intents. Imports are grouped, fields are logically placed, and constructors are straightforward. However, readability is slightly reduced by the overly long method signatures in decode() and canDecode(), which exceed comfortable line lengths and contain multiple parameters. The unsupported stream decoding method throws an exception but its purpose is clear. Action granularity is mostly one-per-line, though the gson.fromJson call combines multiple nested operations. Overall, the code is concise and maintainable but could benefit from line wrapping on long signatures.

Run 1

Code Structure: Constants, state, constructors, and overridden methods are logically organized. Nesting: Minimal nesting, with only a straightforward try/finally block. Clarity of intent: Descriptive names and familiar decoder methods make the purpose clear; the unsupported streaming operation is explicitly identified. Code length: Implementation is concise, but excessive blank lines add unnecessary visual length, and long method signatures reduce scanability. Action granularity: Each statement performs a single clear action; the inline reader construction remains easy to understand. Reading flow: Initialization, capability checking, and decoding follow a natural sequence, with buffer cleanup clearly separated. Inconsistent whitespace and unwrapped signatures slightly disrupt an otherwise readable implementation.

Run 2

Code Structure: Constants, state, constructors, and decoding methods are logically organized. Nesting: Minimal nesting, with a straightforward try/finally block. Clarity of intent: Descriptive names and standard overrides make the decoder's purpose clear; the exception explicitly identifies unsupported streaming. Code length: Implementation is concise, but excessive blank lines add unnecessary visual length. Action granularity: Most lines perform one action, though the JSON parsing expression combines stream access, reader construction, type resolution, and deserialization. Reading flow: Method order is natural and resource release is easy to follow, but long signatures, ungrouped imports, and irregular whitespace interrupt scanning.

Run 3

Code Structure: Logically organized into configuration, constructors, capability checking, and decoding methods. Nesting: Minimal; only a straightforward try/finally block. Clarity of intent: Descriptive names and explicit exceptions make behavior clear, though the distinction between unsupported stream decoding and supported buffer decoding could benefit from documentation. Code length: Implementation is concise, but excessive blank lines add unnecessary visual length. Action granularity: Generally one action per line; the nested reader construction and deserialization expression remain understandable. Reading flow: Method ordering is natural, but long signatures, sparse import grouping, and irregular whitespace interrupt scanning.