Sample

int-eaa195440b88-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines53

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7030–1; higher is more readable
Dorn0.4120–1; higher is more readable
Mi0.5320–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro180–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.1160–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; @J2ktIncompatible @GwtIncompatible public final class Defaults { private Defaults() {} private static final Double DOUBLE_DEFAULT = 0d; private static final Float FLOAT_DEFAULT = 0f; @SuppressWarnings({ "unchecked", "BooleanLiteral" }) 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.53+21.2
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.823−7.235

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

Score0.703

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.53+1.096
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.63.981+0.955
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.54−0.876
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.53−0.795
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.131−0.33
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.52.892+0.329

Intercept 0.07 + feature contributions = -0.354 (log-odds).
Score = sigmoid(-0.354) = 0.412.

Score0.532
Score23
Run 1

The code is highly readable with excellent structure. It uses a flat, linear if-else-if chain for type checking, avoiding deep nesting. Each branch performs a single, clear action. The purpose is immediately apparent: return default values for primitive types. Naming is precise and self-documenting, and constants for float/double defaults reduce repetition nicely. Minor deductions include slight verbosity in the type-checking chain (could use a switch), and the redundant @SuppressWarnings('BooleanLiteral') annotation suggests leftover legacy code. The empty line clusters feel slightly inconsistent, but overall the code flows naturally and requires minimal effort to understand.

Run 2

The code is highly readable. It has clear structure with a private constructor preventing instantiation, flat if-else branching (no deep nesting beyond two levels), and obvious intent for each primitive type. Each return statement occupies a single line, making actions granular. The reading flow is natural and follows a logical type order. Minor deductions: the long if-else chain could be slightly more concise with a switch or map, and the partial blank lines amid annotations are unnecessary. Suppression annotations slightly disrupt flow but are justified for clarity.

Run 3

The code demonstrates excellent readability with clear logical organization and natural flow. The class structure is clean, with a private constructor preventing instantiation and well-named constants at the top. The main method follows a straightforward pattern: validate input, check primitive types, return appropriate default values. Despite having multiple if-else branches, the nesting is shallow (only 2 levels deep) and each branch handles one specific case, maintaining good action granularity. The code's intent is immediately clear - returning default values for primitive types. Variable naming is descriptive, and the comment explaining BooleanLiteral suppression adds helpful context. The method is concise with no unnecessary complexity, and each return statement occupies its own line for readability. The early null return at the end provides a clean exit for non-primitive types. Minor improvements could include extracting the type-checking logic into a helper method, but the current implementation is already highly readable and maintainable.

Run 1

Code Structure: A focused utility class with constants and one logically organized method; excessive blank lines weaken formatting. Nesting: Shallow, with a primitive check enclosing a straightforward conditional chain. Clarity of intent: The class, method, and constant names clearly convey default-value lookup, though the null result for reference types and void is implicit. Code length: Concise overall, with some repetitive primitive branches and unnecessary whitespace. Action granularity: Each statement performs one clear action. Reading flow: Validation followed by type checks and a final null fallback is natural and easy to follow.

Run 2

Code Structure: The utility class is logically organized, with constants and a single focused method. Nesting: Only two conditional levels are used, although the outer primitive check adds some nesting. Clarity of intent: Names and explicit type comparisons make the purpose clear; unchecked casts and null handling for reference types and void could benefit from documentation. Code length: The method is reasonably concise, but excessive blank lines and repetitive branches add visual length. Action granularity: Each statement performs one clear action, with no compressed multi-action lines. Reading flow: Validation followed by type checks and a final null fallback provides a natural sequence, slightly disrupted by irregular whitespace.

Run 3

Code Structure: A focused utility class with logically placed constants and one method; excessive blank lines weaken organization. Nesting: Shallow overall, though the primitive check adds a nesting level around the conditional chain. Clarity of intent: Class, method, and constant names clearly communicate returning default values; unchecked generic casts and the null fallback require some interpretation. Code length: Compact and appropriately scoped, but whitespace and repetitive branches add length. Action granularity: Each check and return is clearly separated, with one action per line. Reading flow: The consistent type-by-type sequence is easy to follow, although stray whitespace and the long else-if chain slightly interrupt the flow.