Sample

int-d4d008edca2e-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines55

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5970–1; higher is more readable
Dorn0.6330–1; higher is more readable
Mi0.6660–1; higher is more readable
LLOC13Logical lines; fewer is more readable
DeepSeek V4 Pro90–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.5370–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) { { int remainingSteps = 3; while (remainingSteps > 0) { remainingSteps--; } } 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.1164.689−38.435
Source linesThe number of non-empty source lines.55+22
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 = -15.018 (log-odds).
Score = sigmoid(-15.018) = 0.

Score0.597

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.56−0.946
Indentation frequencyHow rapidly indentation changes from line to line.37+0.543
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.82.911+0.533
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.37−0.428
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.54.774+0.356
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.069+0.267
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.946+0.152

Intercept 0.07 + feature contributions = 0.546 (log-odds).
Score = sigmoid(0.546) = 0.633.

Score0.666
Score13
Run 1

The code has clear naming, good Javadoc, and simple logic overall, but contains a severe structural problem: a random while loop with an unexplained 'remainingSteps' variable is inserted between the method signature and the body of generateKey. This unreachable, meaningless code breaks the reading flow and hides the actual intent. The indentation also breaks after the loop, making the structure appear tangled. While the individual if statements and return actions are clear and flat, the unnecessary loop adds length and confusion. Without it, the code would be concise and readable; with it, the comprehension is significantly damaged, and the purpose of the method is obscured.

Run 2

The code contains a major structural flaw: a randomly inserted block with a pointless while loop that breaks the natural reading flow and serves no purpose. This severely impacts clarity of intent and code structure. The generateKey method logic is otherwise straightforward and well-indented, but the unnecessary block makes the code ambiguous and confusing. Nesting is minimal and action granularity is generally one action per line, which are positives. However, the unnecessary code adds length without value and disrupts logical organization. The JavaDoc comments are good but cannot compensate for the structural defect. Overall, readability is significantly reduced by the extraneous control flow block.

Run 3

The code is mostly readable Java with clear structure, minimal nesting, and concise methods. However, it contains a stray block with an unused while loop that adds confusion and breaks the reading flow. The intent of the key generation logic is clear, but this dead code obscures overall clarity and creates an unnecessary action that distracts from the purpose. Method length and action granularity are acceptable, but the presence of confusing, non-functional code lowers the score significantly.

Run 1

Code Structure: The two methods separate parameter preprocessing from key generation logically, but the unrelated countdown block disrupts organization. Nesting: Mostly shallow, with early returns; the nested single-parameter check remains easy to follow. Clarity of intent: Descriptive names and documentation explain key generation well, although the countdown loop has no apparent purpose and Kotlin-specific preprocessing requires some context. Code length: The implementation is concise apart from the unnecessary countdown block. Action granularity: Statements generally perform one action per line; the conditional expression is compact but combines preprocessing and delegation. Reading flow: Key-generation cases proceed naturally from zero parameters to one parameter to the general case. However, inconsistent indentation and the unexplained standalone block interrupt that flow.

Run 2

Code Structure: The class cleanly separates method adaptation from key generation, but an unrelated countdown block disrupts the organization. Nesting: Early returns keep most logic shallow; the single-parameter check adds modest nesting, while the countdown introduces unnecessary scope and looping. Clarity of intent: Documentation, descriptive names, and explicit conditions clarify key generation, but the countdown has no meaningful purpose, and Kotlin parameter trimming is not explained locally. Code length: The implementation is concise overall, though the countdown adds avoidable lines. Action granularity: Statements generally perform one action per line; the conditional expression in generate combines detection, copying, and delegation compactly. Reading flow: Key selection follows a natural progression from zero parameters to one parameter to multiple parameters, but inconsistent indentation and the extraneous block interrupt that flow.

Run 3

Code Structure: The class separates method-aware parameter handling from key generation logically, but an unrelated countdown block disrupts that organization. Nesting: Mostly shallow conditionals and early returns keep complexity low; the extra block and loop add unnecessary nesting. Clarity of intent: Documentation, descriptive names, and straightforward key-selection rules clarify the purpose, although the countdown has no apparent purpose and Kotlin parameter trimming is not explained inline. Code length: Generally concise, but the countdown adds avoidable lines. Action granularity: Statements mostly perform one action per line; the ternary combines detection and parameter adjustment but remains manageable. Reading flow: Key generation proceeds naturally from empty parameters to a single eligible parameter to a composite key. Inconsistent indentation and the unrelated loop interrupt this flow.