Sample

int-5738c6b5c269-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines105

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.4930–1; higher is more readable
Dorn0.3040–1; higher is more readable
Mi0.4670–1; higher is more readable
LLOC38Logical lines; fewer is more readable
DeepSeek V4 Pro9.330–20; mean of three runs
GPT-6.1 Sol13.330–20; mean of three runs
BTTF0.5410–1; higher is more readable

Views

Source code

package org.springframework.cache.jcache.interceptor; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import javax.cache.annotation.CacheInvocationParameter; import javax.cache.annotation.CacheKeyGenerator; import javax.cache.annotation.CacheKeyInvocationContext; import org.jspecify.annotations.Nullable; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; /** * Spring's {@link KeyGenerator} implementation that either delegates to a standard JSR-107 * {@link javax.cache.annotation.CacheKeyGenerator}, or wrap a standard {@link KeyGenerator} * so that only relevant parameters are handled. * * @author Stephane Nicoll * @author Juergen Hoeller * @since 4.1 */ class KeyGeneratorAdapter implements KeyGenerator { private final JCacheOperationSource cacheOperationSource; private @Nullable KeyGenerator keyGenerator; private @Nullable CacheKeyGenerator cacheKeyGenerator; /** * Create an instance with the given {@link KeyGenerator} so that {@link javax.cache.annotation.CacheKey} * and {@link javax.cache.annotation.CacheValue} are handled according to the spec. */ public KeyGeneratorAdapter(JCacheOperationSource cacheOperationSource, KeyGenerator target) { Assert.notNull(cacheOperationSource, "JCacheOperationSource must not be null"); Assert.notNull(target, "KeyGenerator must not be null"); this.cacheOperationSource = cacheOperationSource; this.keyGenerator = target; } /** * Create an instance used to wrap the specified {@link javax.cache.annotation.CacheKeyGenerator}. */ public KeyGeneratorAdapter(JCacheOperationSource cacheOperationSource, CacheKeyGenerator target) { Assert.notNull(cacheOperationSource, "JCacheOperationSource must not be null"); Assert.notNull(target, "CacheKeyGenerator must not be null"); this.cacheOperationSource = cacheOperationSource; this.cacheKeyGenerator = target; } /** * Return the target key generator to use in the form of either a {@link KeyGenerator} * or a {@link CacheKeyGenerator}. */ public Object getTarget() { if (!((this.cacheKeyGenerator != null))) {} else { return this.cacheKeyGenerator; } Assert.state(this.keyGenerator != null, "No key generator"); return this.keyGenerator; } @Override public Object generate(Object target, Method method, @Nullable Object... params) { JCacheOperation<?> operation = this.cacheOperationSource.getCacheOperation(method, target.getClass()); if (!((!(operation instanceof AbstractJCacheKeyOperation)))) {} else { throw new IllegalStateException("Invalid operation, should be a key-based operation " + operation); } CacheKeyInvocationContext<?> invocationContext = createCacheKeyInvocationContext(target, operation, params); if (!((this.cacheKeyGenerator != null))) { Assert.state(this.keyGenerator != null, "No key generator"); return doGenerate(this.keyGenerator, invocationContext); } else { return this.cacheKeyGenerator.generateCacheKey(invocationContext); } } private static Object doGenerate(KeyGenerator keyGenerator, CacheKeyInvocationContext<?> context) { List<Object> parameters = new ArrayList<>(); for (CacheInvocationParameter param : context.getKeyParameters()) { Object value = param.getValue(); if (!((param.getParameterPosition() == context.getAllParameters().length - 1 && context.getMethod().isVarArgs()))) { parameters.add(value); } else { parameters.addAll(CollectionUtils.arrayToList(value)); } } return keyGenerator.generate(context.getTarget(), context.getMethod(), parameters.toArray()); } @SuppressWarnings("unchecked") private CacheKeyInvocationContext<?> createCacheKeyInvocationContext( Object target, JCacheOperation<?> operation, @Nullable Object[] params) { AbstractJCacheKeyOperation<Annotation> keyCacheOperation = (AbstractJCacheKeyOperation<Annotation>) operation; return new DefaultCacheKeyInvocationContext<>(keyCacheOperation, target, 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.3939.97−130.019
Source linesThe number of non-empty source lines.105+42
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.944−7.416

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

Score0.493

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.106−2.717
Indentation frequencyHow rapidly indentation changes from line to line.89+2.341
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.89−1.621
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.111.953−1.077
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.104.858+1.056
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.109.849+0.968
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.081+0.151

Intercept 0.07 + feature contributions = -0.829 (log-odds).
Score = sigmoid(-0.829) = 0.304.

Score0.467
Score38
Run 1

The code has a clear class structure but suffers from poor readability due to unconventional boolean checks written as `if (!(...)) {} else { ... }`, which breaks natural reading flow and obscures intent. These inverted empty-if blocks appear multiple times, increasing cognitive load. Nesting is moderate, but `getTarget` and `generate` methods are awkwardly structured. Action granularity is generally one action per line, but the boolean-condition style harms clarity. Code length is reasonable, though some methods could be shorter. The class-level Javadoc is helpful, but method-level Javadoc is uneven. Overall, the logic is understandable but unnecessarily obfuscated by reversed conditionals, making the code harder to follow than it should be.

Run 2

The code has several readability issues. The most significant problem is the inverted boolean conditions throughout, such as 'if (!((this.cacheKeyGenerator != null))) {} else { return ... }' - this double negative with empty if-block is confusing and should be a simple null check. Similar patterns appear in generate() and doGenerate() methods. The negation of complex conditions like '!((param.getParameterPosition() == context.getAllParameters().length - 1 && context.getMethod().isVarArgs()))' adds unnecessary cognitive load. The getTarget() method also uses this inverted pattern with an odd empty if-block. While the class has a clear purpose and follows Spring conventions with proper annotations and documentation, the control flow is unnecessarily tangled. The code could be significantly improved by expressing conditions positively with standard if-else statements. Method names and variable names are generally good, and the code is not deeply nested, but the bizarre condition inversions make it harder to read than necessary.

Run 3

The code is moderately readable but contains several issues. The inverted if-else conditions like `if (!((this.cacheKeyGenerator != null))) {} else { ... }` are confusing and unnatural - normal positive conditions would be much clearer. The empty if-blocks with logic in else-branches violate the principle of clear intent. There are also awkward null checks with double negatives throughout. Variable naming is generally good and the class has a clear purpose with decent documentation. The method structure is logical but the conditional logic makes reading flow disorganized. Some methods use unnecessary wrapper conditions that add nesting complexity. The code length is reasonable and actions are mostly granular, but the unusual conditional patterns significantly reduce readability despite the otherwise clean structure.

Run 1

Code Structure: Well-organized adapter with separate constructors and focused helper methods, though empty conditional branches introduce needless complexity. Nesting: Mostly shallow, with only a loop containing a conditional. Clarity of intent: Descriptive names, documentation, and assertions explain the purpose, but excessive parentheses, negated conditions, and a double negation obscure straightforward checks. Code length: Generally reasonable, although duplicated constructor validation and verbose conditionals add clutter. Action granularity: Each statement performs a single clear action; no compressed multi-action lines. Reading flow: Method ordering and delegation are natural, but empty if blocks followed by meaningful else branches force readers to mentally invert conditions. Straightforward positive checks and guard clauses would substantially improve readability.

Run 2

Code Structure: Fields, constructors, delegation logic, and helpers are logically organized. Nesting: Mostly shallow, with only a loop containing a conditional. Clarity of intent: Descriptive names and documentation explain the adapter's purpose, but redundant parentheses, negated conditions, double negation, and empty if branches obscure straightforward checks. Code length: Reasonably concise overall, though unnecessary conditional scaffolding adds noise. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Method ordering and consistent formatting support navigation, but inverted branch logic and empty branches repeatedly interrupt natural reading. Simplifying conditions and using direct guard clauses would substantially improve readability.

Run 3

Code Structure: The adapter is logically organized into constructors, delegation methods, and context creation, with clear separation of responsibilities. Nesting: Depth is shallow, but empty if branches and unnecessary else blocks complicate simple decisions. Clarity of intent: Descriptive names, documentation, and assertions explain the purpose, while redundant parentheses and double/triple negations obscure conditions, especially the operation-type check. Code length: Mostly concise, although duplicated constructor setup and verbose conditional syntax add avoidable bulk. Action granularity: Statements generally perform one action per line, making assignments and parameter handling easy to follow. Reading flow: Method ordering and formatting are consistent, but inverted conditions and empty branches interrupt the otherwise natural flow and require readers to mentally simplify the logic.