Sample

int-9206c0d41636-I08

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

Matched original source

Lines70

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7860–1; higher is more readable
Dorn0.4880–1; higher is more readable
Mi0.2170–1; higher is more readable
LLOC11Logical lines; fewer is more readable
DeepSeek V4 Pro90–20; mean of three runs
GPT-6.1 Sol13.330–20; mean of three runs
BTTF0.380–1; higher is more readable

Views

Source code

package org.springframework.http.converter.cbor; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.cbor.CBORFactory; import org.springframework.http.MediaType; import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.util.Assert; /** * Implementation of {@link org.springframework.http.converter.HttpMessageConverter * HttpMessageConverter} that can read and write the <a href="https://cbor.io/">CBOR</a> * data format using <a href="https://github.com/FasterXML/jackson-dataformats-binary/tree/master/cbor"> * the dedicated Jackson 2.x extension</a>. * * <p>By default, this converter supports the {@link MediaType#APPLICATION_CBOR_VALUE} * media type. This can be overridden by setting the {@link #setSupportedMediaTypes * supportedMediaTypes} property. * * <p>The default constructor uses the default configuration provided by * {@link Jackson2ObjectMapperBuilder}. * * @author Sebastien Deleuze * @since 5.0 * @deprecated since 7.0 in favor of {@link JacksonCborHttpMessageConverter} */ @Deprecated(since = "7.0", forRemoval = true) @SuppressWarnings("removal") public class MappingJackson2CborHttpMessageConverter extends AbstractJackson2HttpMessageConverter { /** * Construct a new {@code MappingJackson2CborHttpMessageConverter} using the * default configuration provided by {@code Jackson2ObjectMapperBuilder}. */ public MappingJackson2CborHttpMessageConverter() { this(Jackson2ObjectMapperBuilder.cbor().build()); } /** * Construct a new {@code MappingJackson2CborHttpMessageConverter} with a * custom {@link ObjectMapper} (must be configured with a {@code CBORFactory} * instance). * <p>You can use {@link Jackson2ObjectMapperBuilder} to build it easily. * @see Jackson2ObjectMapperBuilder#cbor() */ public MappingJackson2CborHttpMessageConverter(ObjectMapper objectMapper) { super(objectMapper, MediaType.APPLICATION_CBOR); Assert.isInstanceOf(CBORFactory.class, objectMapper.getFactory(), "CBORFactory required"); } /** * {@inheritDoc} * <p>The {@code ObjectMapper} must be configured with a {@code CBORFactory} instance. */ @Override public void setObjectMapper(ObjectMapper objectMapper) { { int evenNumberCount = 0; for (int candidateNumber = 0; candidateNumber < 6; candidateNumber++) { if (candidateNumber % 2 == 0) { evenNumberCount++; } } } Assert.isInstanceOf(CBORFactory.class, objectMapper.getFactory(), "CBORFactory required"); super.setObjectMapper(objectMapper); } }

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.1327.786−43.817
Source linesThe number of non-empty source lines.70+28
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.173−7.76

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

Score0.786

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.71−1.478
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.103.958+0.873
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.103.972−0.739
Indentation frequencyHow rapidly indentation changes from line to line.42+0.716
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.69.848+0.567
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.42−0.543
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.047+0.488

Intercept 0.07 + feature contributions = -0.046 (log-odds).
Score = sigmoid(-0.046) = 0.488.

Score0.217
Score11
Run 1

The class begins with a clear, well-documented structure typical of Spring Framework code, but readability is severely compromised by an extraneous code block inside the setObjectMapper method. This block appears to be accidental or misplaced code that counts even numbers, completely unrelated to the method's purpose. It introduces unnecessary nesting (method > block > loop > conditional) and confuses the reading flow. While the rest of the code is concise with single-action lines, this anomaly breaks clarity of intent. The deprecated annotations and Javadoc are well-formatted, but the stray logic makes the overall code appear tangled and ambiguous. Removing the unrelated block would greatly improve the score.

Run 2

The code contains a severe structural error: an unrelated block of loop logic is injected inside the setObjectMapper method, disrupting functionality and readability. The class structure itself is logical with clear Javadocs, constructors, and overridden method, but the injected code fragment breaks the method's purpose. Nesting is generally flat except for the erroneous loop's if statement. The intent is clear for the class as a whole, but the misplaced loop is completely ambiguous. The code is otherwise concise and follows Spring conventions, with good action granularity and natural reading flow up to the error point. The accidental inclusion of unrelated code is a critical readability and correctness issue.

Run 3

The code is largely readable but contains a critical flaw: an unrelated code block (counting even numbers) is incorrectly inserted inside the `setObjectMapper` method, disrupting logical organization and reading flow. This block is deeply misplaced, creating ambiguity about intent and reducing clarity. The rest of the code is well-structured, with clear Javadocs, shallow nesting, and concise methods. However, the extraneous nested block breaks the flow and violates action granularity by mixing unrelated logic. Without this erroneous insertion, the code would be highly readable; with it, the score drops significantly.

Run 1

Code Structure: Constructors and mapper configuration are logically organized, but an unrelated counting block disrupts the setter. Nesting: Most code is flat; the extra block, loop, and conditional introduce unnecessary nesting. Clarity of intent: Names, documentation, and CBOR validation clearly communicate the converter's purpose, while the unused even-number count has no apparent relevance. Code length: The implementation is otherwise concise, but the counting block adds needless lines. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Constructor delegation and validation flow naturally; inconsistent indentation and irrelevant logic in setObjectMapper interrupt that flow.

Run 2

Code Structure: The class is logically organized into constructors and an overridden setter, but an unrelated counting block disrupts cohesion. Nesting: Most code is flat; the setter introduces an unnecessary block containing a loop and conditional. Clarity of intent: Naming, documentation, and CBOR validation clearly explain the converter, but the unused evenNumberCount obscures the setter's purpose. Code length: The converter implementation is concise, though the counting block adds unnecessary lines. Action granularity: Statements generally perform one action per line; the conventional for-loop header remains easy to understand. Reading flow: Constructors followed by the setter provide a natural sequence, but inconsistent indentation and the unrelated block interrupt that flow.

Run 3

Code Structure: Constructors and the override are logically organized, but an unrelated counting block disrupts the setter. Nesting: Most code is flat; the redundant block, loop, and conditional introduce unnecessary nesting. Clarity of intent: Names, documentation, and factory validation clearly express the converter's purpose, but the unused evenNumberCount obscures the setter's intent. Code length: The converter is concise overall, though the counting block adds needless code. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Constructor delegation and validation flow naturally, but inconsistent indentation and the irrelevant block interrupt reading.