Sample

int-da794b21ceac-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines48

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6140–1; higher is more readable
Dorn0.6530–1; higher is more readable
Mi0.6830–1; higher is more readable
LLOC10Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6690–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 generate(Object target, Method method, @Nullable Object... params) { return generateKey((KotlinDetector.isSuspendingFunction(method) ? Arrays.copyOf(params, params.length - 1) : params)); } /** * Generate a key based on the specified parameters. */ public static Object generateKey(@Nullable Object... params) { if (params.length == 0) { return SimpleKey.EMPTY; } if (params.length == 1) { Object param = params[0]; if (param != null && !param.getClass().isArray()) { return param; } } return new SimpleKey(params); } }

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.1031.948−34.054
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.4.969−7.453

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

Score0.614

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
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.81.265+0.507
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.065+0.31
Indentation frequencyHow rapidly indentation changes from line to line.30+0.301
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.774+0.258
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.82.959+0.151

Intercept 0.07 + feature contributions = 0.63 (log-odds).
Score = sigmoid(0.63) = 0.653.

Score0.683
Score10
Run 1

The code is highly readable with clear structure and intent. The class follows a logical organization, starting with imports, class documentation, and method implementation. Nesting is minimal—only two levels in generateKey—and the flat structure aids comprehension. The purpose of each block is evident: generateKey handles zero, single, and multiple parameter cases distinctly. Code length is concise with no redundant logic. Action granularity is well-maintained, with each line performing a single logical operation. The reading flow is natural, progressing from simple cases to the default. The only minor complexity is the Kotlin detection logic, which slightly obscures the intent of generate(), but the overall design remains clean and maintainable.

Run 2

The code is well-structured with clear separation of concerns between the interface implementation and the static key generation logic. Nesting is minimal - only two levels deep in the conditional checks. Intent is clearly expressed through descriptive method names and Javadoc comments. The code is concise, with no unnecessary verbosity. Action granularity is appropriate with one logical action per line. Reading flow is natural from the public interface method to the static utility method. Minor deductions: the ternary operator in generate() adds slight complexity and the @Nullable annotation on varargs could be clearer for readers unfamiliar with Spring conventions. Overall, this is highly readable production-quality code.

Run 3

The code is highly readable with clear structure and intent. The class has a single responsibility (generating cache keys) and follows Spring conventions. The generate method uses a clean ternary for handling Kotlin suspending functions, though the inline expression could be slightly more readable if extracted. The generateKey method uses early returns to avoid nesting, making the logic flat and easy to follow. Variable names are descriptive, and the method length is appropriate. The Javadoc provides useful context about usage and limitations. Minor deductions: the ternary expression in generate() packs multiple actions into one line, and the condition checking for arrays in the single-parameter case could benefit from a helper method for clarity. Overall, the code demonstrates good readability with logical flow and minimal complexity.

Run 1

Code Structure: Two focused methods cleanly separate Kotlin parameter handling from key generation. Nesting: Mostly flat, with early returns and only one shallow nested condition. Clarity of intent: Descriptive names and documentation explain the key-generation rules; excluding the final parameter of a Kotlin suspending function could use a brief explanatory comment. Code length: Concise implementation with useful, slightly extensive documentation. Action granularity: Each statement performs one clear action, although the ternary combines parameter selection and copying within a method call. Reading flow: The progression from no parameters to a single eligible parameter and then the general fallback is natural. Minor formatting issues, such as tightly grouped imports and redundant parentheses around the ternary, slightly reduce readability.

Run 2

Code Structure: Two focused methods cleanly separate framework integration from key generation. Nesting: Early returns keep control flow mostly flat, with only a shallow nested check for a single parameter. Clarity of intent: Descriptive names and documentation explain the key-generation rules, although the Kotlin-specific removal of the final parameter lacks an explanatory comment. Code length: The implementation is concise, and the documentation provides useful context. Action granularity: Statements generally perform one action each; the conditional expression in generate combines parameter adjustment and delegation, slightly increasing cognitive load. Reading flow: The empty, single-value, and fallback cases follow a natural sequence. Minor formatting issues, such as tightly grouped imports and redundant parentheses around the conditional expression, slightly reduce polish.

Run 3

Code Structure: Two focused methods cleanly separate Kotlin-specific parameter handling from key generation. Nesting: Early returns keep control flow mostly flat, with only one modest nested condition. Clarity of intent: Descriptive names and documentation clearly explain key generation, though excluding the final parameter for Kotlin suspending functions requires background knowledge. Code length: The implementation is concise without unnecessary repetition; documentation adds useful context. Action granularity: Each statement performs a focused action, although the ternary expression combines detection, array copying, and delegation. Reading flow: Parameter handling followed by empty, single-value, and general cases reads naturally. The wrapped ternary and missing spacing between package and import declarations slightly reduce readability.