Sample

int-c5a58538d3be-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines48

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6610–1; higher is more readable
Dorn0.6840–1; higher is more readable
Mi0.6780–1; higher is more readable
LLOC10Logical lines; fewer is more readable
DeepSeek V4 Pro120–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.6440–1; higher is more readable

Views

Source code

package org.springframework.cache.interceptor; import java.lang.reflect.Method; import java.util.Arrays; import org.jspecify.annotations.Nullable; import org.springframework.core.KotlinDetector; /** * Simple key generator. Returns the parameter itself if a single non-null * value is given, otherwise returns a {@link SimpleKey} of the parameters. * * <p>No collisions will occur with the keys generated by this class. * The returned {@link SimpleKey} object can be safely used with a * {@link org.springframework.cache.concurrent.ConcurrentMapCache}, however, * might not be suitable for all {@link org.springframework.cache.Cache} * implementations. * * @author Phillip Webb * @author Juergen Hoeller * @author Sebastien Deleuze * @since 4.0 * @see SimpleKey * @see org.springframework.cache.annotation.CachingConfigurer */ public class SimpleKeyGenerator implements KeyGenerator { @Override public Object gen(Object tar, Method met, @Nullable Object... par) { return generate((KotlinDetector.isSuspendingFunction(met) ? Arrays.copyOf(par, par.length - 1) : par)); } /** * Generate a key based on the specified parameters. */ public static Object generate(@Nullable Object... par2) { if (par2.length == 0) { return SimpleKey.EMPTY; } if (par2.length == 1) { Object par3 = par2[0]; if (par3 != null && !par3.getClass().isArray()) { return par3; } } return new SimpleKey(par2); } }

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.1036.03−34.189
Source linesThe number of non-empty source lines.48+19.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.5−7.499

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

Score0.661

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.49−0.699
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.75.939+0.449
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.72.857+0.371
Indentation frequencyHow rapidly indentation changes from line to line.30+0.301
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.067+0.289
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.30−0.268
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.47.766+0.258

Intercept 0.07 + feature contributions = 0.771 (log-odds).
Score = sigmoid(0.771) = 0.684.

Score0.678
Score10
Run 1

The code has clear logical structure and separation of concerns, with a clean public API and sensible static utility method. The main readability issues stem from poor parameter naming: 'tar', 'met', 'par', 'par2', 'par3' obscure intent and force the reader to infer meaning from context. The ternary operator with Arrays.copyOf adds moderate nesting and complexity to the first method. Action granularity is acceptable but could be improved by extracting the ternary into a local variable. Reading flow suffers from abbreviated names and the inline conditional. The code follows Spring conventions for structure and documentation, which aids readability, but the terse naming style significantly reduces clarity of intent. Overall, the code is maintainable but requires more cognitive effort than necessary due to cryptic variable names.

Run 2

The code has a logical structure with clear class and method separation. However, readability is significantly hampered by poor naming: 'gen', 'tar', 'met', 'par', 'par2', 'par3' obscure the meaning of variables. Nesting is manageable but could be reduced. The intent of the cache key generation is understandable from the Javadoc, but the code itself lacks clarity. The method 'gen' performs multiple actions in one line (Kotlin detection, array copying, delegation), violating action granularity. Reading flow is disrupted by the abbreviated names. While concise, the code sacrifices clarity for brevity. More descriptive names and a separate line for parameter preparation would improve readability.

Run 3

The code has clear intent and logical structure, but readability is reduced by the use of abbreviated parameter names (tar, met, par, par2, par3) which obscure meaning. The method 'gen' is short but contains a nested conditional expression involving KotlinDetector and Arrays.copyOf, which slightly increases cognitive load. Nesting is otherwise minimal and action granularity is reasonable. The class-level Javadoc is helpful, but the parameter names undermine clarity. The generate method is concise and straightforward, but the variable naming convention ('par2', 'par3') feels arbitrary and unnecessary. Overall, the code is functional and organized, but could be significantly improved with descriptive parameter names and a clearer separation of concerns in the 'gen' method.

Run 1

Code Structure: Two small methods cleanly separate parameter preparation from key generation. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Documentation explains the purpose, but abbreviated names such as gen, tar, met, par2, and par3 obscure roles; the Kotlin-specific parameter removal is unexplained. Code length: Concise implementation with little unnecessary code. Action granularity: Most lines perform one action, although the ternary combines detection, copying, and selection within a return expression. Reading flow: Key generation follows a natural progression from empty parameters to a single reusable value to a composite key; the wrapped ternary and extra parentheses slightly interrupt that flow.

Run 2

Code Structure: Two small methods cleanly separate argument handling from key generation. Nesting: Mostly flat, with early returns and only one nested conditional. Clarity of intent: Documentation and straightforward conditions explain the main purpose, but abbreviated names such as tar, met, par2, and par3 obscure meaning; excluding the Kotlin continuation parameter is not explained. Code length: Concise, with little unnecessary code, though the return expression has redundant parentheses. Action granularity: Each statement performs a focused action, while the ternary expression combines detection and argument transformation compactly. Reading flow: Key generation proceeds naturally from empty parameters to a single eligible value and finally a composite key. The wrapped ternary and weak variable names slightly interrupt otherwise clear reading.

Run 3

Code Structure: Two focused methods cleanly separate invocation handling from key generation. Nesting: Mostly flat, with early returns and only one nested conditional. Clarity of intent: Documentation explains the purpose, but abbreviated names such as gen, tar, met, par2, and par3 obscure roles; the Kotlin-specific parameter removal lacks explanation. Code length: Compact without substantial redundancy, though the ternary expression has unnecessary parentheses. Action granularity: Each statement performs one clear action; the ternary combines detection and argument adjustment but remains manageable. Reading flow: Key generation proceeds naturally from empty parameters to a single eligible value to the general fallback. Missing spacing around the package and imports slightly reduces visual organization.