Sample

int-613b51616edc-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines77

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8530–1; higher is more readable
Dorn0.450–1; higher is more readable
Mi0.2790–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.480–1; higher is more readable

Views

Source code

package com.google.common.reflect; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; /** * Static utilities relating to Java reflection. * * @since 12.0 */ public final class Reflection { /** * Returns the package name of {@code clazz} according to the Java Language Specification (section * 6.7). Unlike {@link Class#getPackage}, this method only parses the class name, without * attempting to define the {@link Package} and hence load files. */ public static String getPackageName(Class<?> clazz) { return getPackageName(clazz.getName()); } /** * Returns the package name of {@code classFullName} according to the Java Language Specification * (section 6.7). Unlike {@link Class#getPackage}, this method only parses the class name, without * attempting to define the {@link Package} and hence load files. */ public static String getPackageName(String classFullName) { int lastDot = classFullName.lastIndexOf('.'); final int a = 1; final int b = -1; final int c = 1; final int d = -1; return (lastDot < (a + b)) ? "" : classFullName.substring((c + d), lastDot); } /** * Ensures that the given classes are initialized, as described in <a * href="http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.4.2">JLS Section * 12.4.2</a>. * * <p>WARNING: Normally it's a smell if a class needs to be explicitly initialized, because static * state hurts system maintainability and testability. In cases when you have no choice while * interoperating with a legacy framework, this method helps to keep the code less ugly. * * @throws ExceptionInInitializerError if an exception is thrown during initialization of a class */ public static void initialize(Class<?>... classes) { for (Class<?> clazz : classes) { try { Class.forName(clazz.getName(), true, clazz.getClassLoader()); } catch (ClassNotFoundException e) { throw new AssertionError(e); } } } /** * Returns a proxy instance that implements {@code interfaceType} by dispatching method * invocations to {@code handler}. The class loader of {@code interfaceType} will be used to * define the proxy class. To implement multiple interfaces or specify a class loader, use {@link * Proxy#newProxyInstance}. * * @throws IllegalArgumentException if {@code interfaceType} does not specify the type of a Java * interface */ public static <T> T newProxy(Class<T> interfaceType, InvocationHandler handler) { checkNotNull(handler); checkArgument(interfaceType.isInterface(), "%s is not an interface", interfaceType); Object object = Proxy.newProxyInstance( interfaceType.getClassLoader(), new Class<?>[] {interfaceType}, handler); return interfaceType.cast(object); } private Reflection() {} }

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.1873.05−61.811
Source linesThe number of non-empty source lines.77+30.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.841−7.262

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

Score0.853

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.77−1.69
Indentation frequencyHow rapidly indentation changes from line to line.47+0.889
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.91.128+0.666
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.76.871+0.665
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.47−0.658
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.99.936−0.568
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.427

Intercept 0.07 + feature contributions = -0.2 (log-odds).
Score = sigmoid(-0.2) = 0.45.

Score0.279
Score20
Run 1

The code is generally well-structured, with clear method separation, Javadoc, and single-action lines, but it has serious readability problems. The class follows a logical layout and methods like `initialize` and `newProxy` are clear and straightforward. However, the `getPackageName(String)` method is unnecessarily obfuscated: it introduces meaningless constants `a`, `b`, `c`, `d`, and uses arithmetic like `(a + b)` and `(c + d)` where a direct check for `lastDot < 0` and a simple substring would be far clearer. This injects ambiguity and hurts clarity of intent. Nesting is flat and method length is mostly concise, but the gratuitous complexity in one method drags down the score. Action granularity is adequate overall, but the weird constant dance violates the principle of clear intent. Reading flow is mostly natural, but the affected method makes the reader stop and puzzle over trivial logic.

Run 2

The code is generally well-structured and readable, with a clear class purpose, concise methods, and helpful Javadoc on public APIs. However, the `getPackageName(String)` method introduces unnecessary local variables (`a`, `b`, `c`, `d`) that obscure intent and reduce clarity. The arithmetic on these constants makes the logic harder to follow than a direct comparison like `lastDot < 0`. Nesting is minimal, and each method generally performs one logical action, but the artificial complexity of the variable names undermines clarity. The `initialize` and `newProxy` methods are clean, with clear intent and appropriate use of helper methods like `checkNotNull` and `checkArgument`. Overall, the code is readable but could be improved by simplifying the package name parsing logic and removing redundant local variables.

Run 3

The code is generally well-structured with clear class-level organization and good Javadoc comments explaining intent. It is relatively flat, with only one nested try-catch. However, the getPackageName(String) method significantly hurts readability: it introduces meaningless constants (a, b, c, d) and a convoluted expression that obscures the simple logic of checking if a dot exists and returning the substring. This is unnecessarily long and ambiguous compared to a straightforward implementation. Action granularity is mostly fine but mixed in that method. The rest of the code (initialize, newProxy) is clear, concise, and readable, but the problematic method drags down the overall score.

Run 1

Code Structure: Well-organized utility class with focused methods, adjacent overloads, and a private constructor. Nesting: Mostly flat; the loop and try/catch in initialize add only modest nesting. Clarity of intent: Descriptive method names and thorough documentation explain the behavior, but meaningless constants a, b, c, and d obscure simple zero comparisons and substring indexing. Code length: Generally concise, although those four constants introduce unnecessary lines and arithmetic. Action granularity: Statements generally perform one action each; the multiline proxy creation remains a single coherent operation. Reading flow: Methods follow a natural sequence, and consistent formatting supports scanning. The redundant arithmetic in getPackageName interrupts otherwise straightforward reading.

Run 2

Code Structure: Well-organized utility class with focused methods and a private constructor. Nesting: Shallow overall; the loop and try/catch in initialize are straightforward. Clarity of intent: Descriptive method names and useful documentation explain behavior, but meaningless constants a, b, c, and d obscure simple zero values in getPackageName. Code length: Mostly concise, though those four declarations and arithmetic expressions are unnecessary. Action granularity: Statements generally perform one action per line; the ternary remains manageable. Reading flow: Consistent formatting and logical method grouping support natural reading, with the artificial arithmetic being the main interruption.

Run 3

Code Structure: Well-organized utility class with focused methods and a private constructor. Nesting: Shallow overall; the loop containing try/catch is easy to follow. Clarity of intent: Descriptive method names and thorough documentation explain the reflection operations, but meaningless variables a, b, c, and d obscure simple zero values in getPackageName. Code length: Generally concise, although those four constants add unnecessary lines and arithmetic. Action granularity: Each statement performs a distinct action; the multiline proxy construction remains a single coherent operation. Reading flow: Consistent formatting and method-level documentation support natural reading, with the artificial constant calculations being the main interruption.