Sample

int-a71e82a7b7c1-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines53

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8490–1; higher is more readable
Dorn0.4880–1; higher is more readable
Mi0.5840–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro100–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4660–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()))) {} else { 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.1850.883−61.079
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.899−7.348

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

Score0.849

Feature contributions

FeatureValueContribution
(log-odds)
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.97.981+0.776
Indentation frequencyHow rapidly indentation changes from line to line.43+0.75
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.43−0.566
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.97.981−0.485
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.52.828+0.329
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.102−0.046

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

Score0.584
Score23
Run 1

The code is almost impossible to read due to a single, critical flaw: a nonsensical empty if statement followed by an else block. This completely obscures the logic of the program. While the code is well-structured at the class and method level and the Javadoc is excellent, this primary logic flaw overrides these strengths. The condition `if (!((type.isPrimitive()))) {} else { ... }` is unnatural and disorients the reader, leading to very poor readability. Nesting is flat, intent is clear initially but then shattered by this pattern, action granularity is one action per line, and reading flow is severely disrupted.

Run 2

The code is moderately readable but has several structural issues. The method `defaultValue` uses an awkward empty `if` block with a negated condition instead of a simple `if (type.isPrimitive())`, which hurts clarity. The `else` block adds unnecessary nesting, and the `if-else if` chain is overly verbose for what could be a switch statement or a map lookup. The empty block with only a comment is confusing. On the positive side, the class has a clear purpose, good Javadoc, and each return statement is on its own line. The constant extraction for default float/double values is reasonable. The `@SuppressWarnings` annotation is justified. Overall, the logic flow is inverted from natural reading order, making it harder to follow than necessary. A flat, early-return structure would improve readability significantly.

Run 3

The code is generally clear and well-structured, with a logical class layout, meaningful constants, and helpful Javadoc. The method's purpose is evident. However, readability is significantly hurt by the bizarre `if (!((type.isPrimitive()))) {} else { ... }` construct, which is awkward, non-idiomatic, and interrupts the natural reading flow. The long chain of `else if` statements is acceptable but contributes to moderate nesting. Most lines perform one action, and the use of `valueOf` for boxed primitives is consistent. The method length is reasonable, but the empty if-block and unnecessary parentheses make the logic harder to follow than it should be. Overall, the code is readable but would be greatly improved by replacing the odd condition with a simple early return: `if (!type.isPrimitive()) return null;`.

Run 1

Code Structure: The utility class is logically organized, with constants and one focused method, but the empty if branch is awkward. Nesting: Depth is modest, though the negated primitive check and else block add avoidable nesting. Clarity of intent: Documentation, names, and explicit type comparisons clearly explain the behavior; redundant parentheses and the empty branch obscure the main condition. Code length: Reasonably concise, with some necessary repetition for primitive types. Action granularity: Statements generally perform one action per line, making individual checks and returns easy to follow. Reading flow: The type-to-default mapping reads predictably, but the inverted opening condition interrupts an otherwise natural flow.

Run 2

Code Structure: The utility class is logically organized, with constants and a single focused method, but the empty non-primitive branch is awkward. Nesting: Generally shallow, though the outer conditional unnecessarily nests the primitive checks. Clarity of intent: Descriptive names, documentation, and explicit type comparisons clearly explain the defaults; the negated condition and redundant parentheses obscure otherwise straightforward logic. Code length: Reasonably concise, with some unavoidable repetition across primitive types. Action granularity: Most lines perform one clear action, but the empty if and else on one line reduce readability. Reading flow: The type-by-type sequence is natural and consistent, interrupted mainly by the unusual outer conditional. An early return for non-primitive types would improve flow.

Run 3

Code Structure: The small utility class is logically organized, with constants and a single focused method. Nesting: The type checks are only moderately nested, but the empty negated if branch introduces unnecessary complexity. Clarity of intent: Descriptive names and Javadoc clearly explain the default-value behavior; redundant parentheses and the empty branch obscure the primitive check. Code length: Generally concise, though the repetitive type dispatch and unnecessary outer conditional add verbosity. Action granularity: Most lines perform a single clear action, except the compressed empty if/else statement. Reading flow: The sequential primitive checks are easy to follow, but the inverted condition interrupts the otherwise natural flow. A straightforward positive primitive check would improve readability.