Sample

int-67b34b8847c3-SRC

Unmodified source class

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. Structure is logical: a small, single-purpose class with a clear public interface. Nesting is minimal — only two levels deep in generateKey. Intent is explicit through method names, Javadoc, and the SimpleKey concept. Length is concise for what it does. Action granularity is good — one meaningful operation per line, with no multiple actions stacked on a single line. Reading flow is natural: the generate method delegates to generateKey, then checks edge cases (zero params, one non-array non-null param) before falling through to the general case. The only slight deduction is the inline conditional in the first method call, which is mildly dense but still easily parsed, given the surrounding context and naming.

Run 2

The code is well-structured, with clear separation between the interface implementation and the static utility method. Nesting is minimal—only two conditional levels deep within generateKey. Intent is clear from the method names and Javadoc, particularly regarding the kotlin suspending function handling. Code length is concise without unnecessary verbosity. Action granularity is excellent, with one logical operation per line (e.g., array copy, parameter count checks, parameter extraction). Reading flow is natural: the generate method delegates to generateKey, followed by the utility logic. Minor deductions: the Kotlin-specific array copy logic slightly obscures intent without inline explanation, and the conditional logic in generateKey could benefit from a brief comment explaining the edge case handling. Otherwise, the code is exemplary Spring framework standard.

Run 3

The code demonstrates excellent readability through clear structure and purpose. The class has a single responsibility and follows Spring's established patterns. Nesting is minimal with early returns reducing cognitive load. The intent is unambiguous: generate cache keys from method parameters. Code length is concise with no unnecessary boilerplate. Action granularity is appropriate—each line performs one logical operation. The reading flow is natural, starting with the interface method, handling Kotlin suspending functions inline, then delegating to a clean static utility method with clear conditional logic. The Javadoc is informative but concise. Minor deductions: the ternary expression for Kotlin detection slightly compresses logic, and the nullability annotations are not specified on the interface method parameters (though inherited implicitly). Overall, this is highly maintainable, idiomatic Java code that would be immediately understandable to any Spring developer.

Run 1

Code Structure: Well organized into a framework entry point and a focused key-generation helper. Nesting: Shallow overall, with only one nested conditional; early returns simplify control flow. Clarity of intent: Descriptive names and documentation explain the key-generation policy, though the Kotlin-specific parameter removal requires background knowledge, and the summary omits the single-array exception. Code length: Concise, with no unnecessary implementation code. Action granularity: Statements generally perform one action each, although the entry-point expression combines detection, parameter adjustment, and delegation. Reading flow: Natural progression from no parameters to one eligible parameter to the fallback key; the wrapped ternary slightly interrupts readability.

Run 2

Code Structure: Two focused methods clearly separate method-aware parameter handling from key generation. Nesting: Early returns keep control flow mostly flat, with only one shallow nested condition. Clarity of intent: Descriptive names and useful documentation explain key selection well, though excluding the final Kotlin coroutine parameter is not explained. Code length: The implementation is concise without unnecessary logic; documentation is proportionate. Action granularity: Statements generally perform one action each, although the ternary expression combines detection, array copying, and delegation. Reading flow: The empty, single-value, and composite-key cases follow a natural order. The multiline ternary and redundant parentheses slightly interrupt otherwise smooth reading.

Run 3

Code Structure: Well-organized, separating method-aware parameter handling from key generation. Nesting: Shallow, with early returns and only one nested conditional. Clarity of intent: Descriptive names and documentation make the purpose clear, though the Kotlin-specific removal of the final parameter is not explained, and the class summary omits the single-array exception. Code length: Concise, with little unnecessary code. Action granularity: Statements generally perform one action; the ternary combines detection, parameter copying, and delegation in one expression. Reading flow: Natural progression from special cases to the default key construction, although the multiline ternary and extra parentheses slightly interrupt readability.