Sample

int-667f0ab6033e-I10

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

Matched original source

Lines37

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7710–1; higher is more readable
Dorn0.4650–1; higher is more readable
Mi0.0920–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro5.330–20; mean of three runs
GPT-6.1 Sol11.670–20; mean of three runs
BTTF0.3690–1; higher is more readable

Views

Source code

package com.google.common.base; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import org.jspecify.annotations.Nullable; /** * This class provides default values for all Java types, as defined by the JLS. * * @author Ben Yu * @since 1.0 */ @J2ktIncompatible @GwtIncompatible public final class Defaults { private Defaults() {} private static final Double DOUBLE_DEFAULT = 0d; private static final Float FLOAT_DEFAULT = 0f; /** * Returns the default value of {@code type} as defined by JLS --- {@code 0} for numbers, {@code * false} for {@code boolean} and {@code '\0'} for {@code char}. For non-primitive types and * {@code void}, {@code null} is returned. */ @SuppressWarnings({ "unchecked", "BooleanLiteral" // `(T) false` would produce an error }) public static <T> @Nullable T defaultValue(Class<T> type) { checkNotNull(type); if (type.isPrimitive()) { if (type == boolean.class) { return (T) Boolean.FALSE; } else if (type == char.class) { return (T) Character.valueOf('\0'); } else if (type == byte.class) { return (T) Byte.valueOf((byte) 0); } else if (type == short.class) { return (T) Short.valueOf((short) 0); } else if (type == int.class) { return (T) Integer.valueOf(0); } else if (type == long.class) { return (T) Long.valueOf(0L); } else if (type == float.class) { return (T) FLOAT_DEFAULT; } else if (type == double.class) { return (T) DOUBLE_DEFAULT; } } return null; } }

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.1795.802−59.261
Source linesThe number of non-empty source lines.37+14.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.4.955−7.432

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

Score0.771

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.108+0.938
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.107.947−0.907
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.38−0.309
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.27−0.199
Indentation frequencyHow rapidly indentation changes from line to line.27+0.197
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.36.844+0.105
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.101−0.036

Intercept 0.07 + feature contributions = -0.141 (log-odds).
Score = sigmoid(-0.141) = 0.465.

Score0.092
Score23
Run 1

The code is functionally simple but formatted extremely poorly, making it hard to read. Imports and field declarations are crammed onto single lines. The Javadoc for defaultValue is placed between the FLOAT_DEFAULT field and the method annotation, disrupting logical grouping. The if-else chain for primitive types is compressed into a single block with inconsistent line breaks, and some closing braces share lines with the next statement. This violates standard Java formatting conventions and reduces clarity of intent. Action granularity suffers because multiple statements or annotations appear on one line. The reading flow is disorganized. While the logic itself is straightforward, the lack of consistent structure, poor spacing, and unnatural line breaks make the code unnecessarily difficult to parse.

Run 2

The code is functionally correct but poorly formatted for readability. Multiple statements are crammed onto single lines, especially the imports, field declarations, and method signature. Deeply nested conditionals make the logic hard to follow, and the action granularity violates the one-action-per-line principle. The intent is clear — returning JLS default values — but the physical layout obscures it. There is also inconsistent brace placement and spacing. Reformatting with proper line breaks, one statement per line, and cleaner indentation would significantly improve readability.

Run 3

The code is functionally correct but poorly formatted, making it difficult to read. The package and import statements are compressed onto single lines, violating conventional structure. The class body contains multiple declarations and method comments crammed together without line breaks, obscuring the logical organization. While the if-else chain for checking primitive types is relatively flat, its spacing and indentation are inconsistent, harming readability. The intent of defaultValue is clear from the Javadoc, but the implementation is visually cluttered. The code length is acceptable, but action granularity suffers due to multiple statements sharing lines, disrupting the natural reading flow. Proper formatting, consistent indentation, and separating declarations would significantly improve readability.

Run 1

Code Structure: The class has a logical organization, with constants and a single lookup method, but compressed formatting obscures boundaries. Nesting: Only two conditional levels are used, though the long if/else chain and inconsistent brace placement make scanning harder. Clarity of intent: Descriptive names, explicit type comparisons, and helpful documentation clearly explain the purpose. Code length: The implementation is reasonably concise for handling primitive types, with little unnecessary code. Action granularity: Imports, declarations, checks, and returns frequently share lines, reducing readability. Reading flow: The underlying logic follows a natural sequence, but crowded annotations, inline comments, and irregular line breaks interrupt that flow.

Run 2

Code Structure: The utility class logically groups constants and a single method, but compressed formatting obscures those boundaries. Nesting: An outer primitive check contains an if/else chain; nesting is modest, though inconsistent brace placement complicates scanning. Clarity of intent: Descriptive names and Javadoc clearly explain default values and null behavior. Code length: The implementation is reasonably concise, with little unnecessary code. Action granularity: Multiple imports, declarations, and statements share lines, reducing readability and violating one-action-per-line presentation. Reading flow: Type checks follow a sensible sequence, but irregular indentation, inline returns, and comments attached to declarations interrupt natural reading.

Run 3

Code Structure: The utility class logically groups constants and a single method, but compressed declarations and inconsistent formatting obscure that organization. Nesting: An outer primitive check wraps a straightforward if/else chain; nesting is moderate rather than deep. Clarity of intent: Descriptive names, explicit type comparisons, and clear Javadoc make the purpose easy to understand. Code length: The implementation is reasonably concise, with little unnecessary code. Action granularity: Multiple imports, declarations, checks, and returns share lines, making individual actions harder to distinguish. Reading flow: The type checks follow a sensible sequence, but irregular indentation, inline braces, and comments attached to declarations interrupt scanning. Overall, the logic is readable, while presentation substantially reduces readability.