Sample

int-c7fc104045ff-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines49

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6190–1; higher is more readable
Dorn0.7220–1; higher is more readable
Mi0.5320–1; higher is more readable
LLOC14Logical lines; fewer is more readable
DeepSeek V4 Pro14.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.5930–1; higher is more readable

Views

Source code

package org.apache.kafka.streams.state.internals; import org.apache.kafka.common.utils.Bytes; import org.apache.kafka.streams.KeyValue; import org.apache.kafka.streams.kstream.Windowed; import org.apache.kafka.streams.state.KeyValueIterator; import static org.apache.kafka.streams.state.HeadersBytesStore.convertToHeaderFormat; /** * This class is used to ensure backward compatibility at DSL level between * {@link org.apache.kafka.streams.state.SessionStoreWithHeaders} and * {@link org.apache.kafka.streams.state.SessionStore}. * <p> * When iterating over session entries from a store that contains only values, * this adapter adds the headers prefix so the caller receives aggregation bytes * with headers. * * @see SessionToHeadersStoreAdapter */ class SessionToHeadersIteratorAdapter implements KeyValueIterator<Windowed<Bytes>, byte[]> { private final KeyValueIterator<Windowed<Bytes>, byte[]> innerIterator; SessionToHeadersIteratorAdapter(final KeyValueIterator<Windowed<Bytes>, byte[]> innerIterator) { this.innerIterator = innerIterator; } @Override public void close() { innerIterator.close(); } @Override public Windowed<Bytes> peekNextKey() { return innerIterator.peekNextKey(); } @Override public boolean hasNext() { return innerIterator.hasNext(); } @Override public KeyValue<Windowed<Bytes>, byte[]> next() { final KeyValue<Windowed<Bytes>, byte[]> keyValue = innerIterator.next(); if (!((keyValue == null))) {} else { return null; } return KeyValue.pair(keyValue.key, convertToHeaderFormat(keyValue.value)); } }

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.1480.876−48.869
Source linesThe number of non-empty source lines.49+19.6
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.763−7.145

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

Score0.619

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.99.92+0.808
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.50−0.734
Indentation frequencyHow rapidly indentation changes from line to line.39+0.612
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.99.9−0.566
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.48.792+0.272
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.087+0.096

Intercept 0.07 + feature contributions = 0.956 (log-odds).
Score = sigmoid(0.956) = 0.722.

Score0.532
Score14
Run 1

The adapter has clear intent and straightforward delegation to an inner iterator, but several implementation details harm readability. The most glaring issue is the bizarre null-check: `if (!((keyValue == null))) {} else { return null; }` with excessive parentheses and an empty 'if' branch. This should simply be `if (keyValue == null) return null;`. The class purpose is documented, and methods are reasonably named, but the null-check creates confusion. Nesting is generally flat, and method lengths are concise. However, the action granularity suffers because of the awkward conditional structure. The code follows a natural delegation pattern but is undermined by stylistic quirks and inconsistent formatting in the null-check. Overall, it is maintainable but requires a small cleanup to reach good readability.

Run 2

The code is generally structured with clear class boundaries and follows an adapter pattern, but several issues affect readability. The constructor and method delegation are logical, but the null-check in next() is convoluted: it uses a double-negative condition with empty braces, making the intent ambiguous. The method is fairly flat, which is good, but the null-check could be simplified to 'if (keyValue == null) return null;'. The class-level Javadoc helps clarify purpose, but static import placement and lack of blank lines between imports slightly hurt organization. Action granularity is acceptable - one main operation per line in next() - but the confusing null-check combines condition and control flow poorly. Reading flow is mostly natural, but the awkward null-check interrupts comprehension.

Run 3

The code is well-structured with clear separation of concerns and an informative Javadoc explaining the adapter's purpose. It is flat with minimal nesting and mostly straightforward delegation methods. The one minor flaw is the awkward `if (!((keyValue == null))) {} else { return null; }` construct, which harms clarity and should be rewritten as a simple `if (keyValue == null) return null;`. Otherwise, intent is clear, length is concise, and each operation is on its own line.

Run 1

Code Structure: The adapter is logically organized, with a constructor and small delegation methods. Nesting: Nearly flat, although the empty if branch and else introduce unnecessary complexity. Clarity of intent: Descriptive names and documentation clearly explain the compatibility purpose, but the negated, redundantly parenthesized null check obscures a simple guard condition. Code length: Concise overall; replacing the conditional with 'if (keyValue == null) return null;' would simplify it further. Action granularity: Most lines perform one action, except the compressed empty if/else line, which combines several structural elements. Reading flow: Delegation methods are straightforward and consistent, but the awkward null check interrupts the otherwise natural flow.

Run 2

Code Structure: The adapter is logically organized, with a clear field, constructor, and iterator methods. Nesting: Most methods are flat, but next() introduces an unnecessary empty branch and else block. Clarity of intent: Descriptive names and documentation explain the compatibility purpose; the negated, redundantly parenthesized null check obscures an otherwise straightforward operation. Code length: The implementation is concise, although the null handling could be shortened to a direct guard clause. Action granularity: Statements generally perform one action per line, with a natural combination of conversion and pair construction in the final return. Reading flow: Delegation methods are easy to follow, but the empty if block interrupts the flow in next(). Import spacing could also be improved.

Run 3

Code Structure: The adapter is logically organized, with a constructor and small methods delegating to the wrapped iterator. Nesting: Almost entirely flat, although the empty if branch and else introduce unnecessary complexity. Clarity of intent: Descriptive names and useful documentation explain the compatibility purpose, but the negated, redundantly parenthesized null check obscures a simple guard clause. Code length: Concise overall; the null check could be simplified to if (keyValue == null) return null. Action granularity: Most lines perform one clear action, though the empty branch and else share a line awkwardly. Reading flow: Delegation methods are easy to scan, and next() naturally retrieves then converts an entry, but its unusual conditional interrupts that flow. Import spacing could also be improved.