Sample

int-582270de9a87-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines75

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.4530–1; higher is more readable
Dorn0.7560–1; higher is more readable
Mi0.4420–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.4620–1; higher is more readable

Views

Source code

package org.apache.kafka.clients.admin; import org.apache.kafka.common.KafkaFuture; import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.annotation.InterfaceAudience; import org.apache.kafka.common.errors.ApiException; import org.apache.kafka.common.internals.KafkaFutureImpl; import org.apache.kafka.common.protocol.Errors; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * The result of the {@link Admin#alterShareGroupOffsets(String, Map, AlterShareGroupOffsetsOptions)} call. */ @InterfaceAudience.Public public class AlterShareGroupOffsetsResult { private final KafkaFuture<Map<TopicPartition, ApiException>> future; AlterShareGroupOffsetsResult(KafkaFuture<Map<TopicPartition, ApiException>> future) { this.future = future; } /** * Return a future which can be used to check the result for a given partition. */ public KafkaFuture<Void> partitionResult(final TopicPartition partition) { final KafkaFutureImpl<Void> result = new KafkaFutureImpl<>(); this.future.whenComplete((topicPartitions, throwable) -> { if (throwable != null) { result.completeExceptionally(throwable); } else if (!topicPartitions.containsKey(partition)) { result.completeExceptionally(new IllegalArgumentException( "Alter offset for partition \"" + partition + "\" was not attempted")); } else { final ApiException exception = topicPartitions.get(partition); if (exception == null) { result.complete(null); } else { result.completeExceptionally(exception); } } }); return result; } /** * Return a future which succeeds if all the alter offsets succeed. * If not, the first topic error shall be returned. */ public KafkaFuture<Void> all() { return this.future.thenApply(topicPartitionErrorsMap -> { List<TopicPartition> partitionsFailed = topicPartitionErrorsMap.entrySet() .stream() .filter(e -> e.getValue() != null) .map(Map.Entry::getKey) .collect(Collectors.toList()); for (ApiException exception : topicPartitionErrorsMap.values()) { if (exception != null) { String message = exception.getMessage(); if ((message != null) && !message.isEmpty()) { throw Errors.forException(exception).exception(message + " Failed altering group offsets for the following partitions: " + partitionsFailed); } else { throw Errors.forException(exception).exception( "Failed altering group offsets for the following partitions: " + partitionsFailed); } } } return null; }); } }

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.2825.028−93.226
Source linesThe number of non-empty source lines.75+30
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.445−6.668

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

Score0.453

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.76−1.655
Indentation frequencyHow rapidly indentation changes from line to line.68+1.615
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.112−1.079
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.111.961+1.002
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.74.867+0.637
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.083+0.14

Intercept 0.07 + feature contributions = 1.128 (log-odds).
Score = sigmoid(1.128) = 0.756.

Score0.442
Score25
Run 1

The code is generally readable but has some issues. The class structure is clear with a single field and two public methods. However, the 'all()' method is problematic: it uses a stream to collect failed partitions but then iterates over ALL values with a traditional loop, creating redundancy. This method could be simplified by filtering the entrySet once. The lambda callbacks in both methods are moderately nested (3 levels deep), slightly impacting readability. Clarity of intent is mostly good, but the error message construction in 'all()' is verbose and duplicated. Code length is acceptable for the functionality, though the 'all()' method is unnecessarily long due to the dual iteration approach. Action granularity is reasonable in most places, but the error handling in 'all()' packs multiple operations into single lines. The reading flow is natural in 'partitionResult()' but becomes choppy in 'all()' due to the mixed streaming and imperative styles.

Run 2

The code is well-structured and readable, with clear class purpose and logical method organization. The constructor and methods have obvious intentions, and Javadoc helps clarify behavior. Nesting in partitionResult is moderately deep but each branch is simple and readable. Action granularity is mostly one operation per line, though lambda bodies could be more concise. The all() method has slightly confusing flow: it collects failed partitions first, then iterates values to find the first error, making the purpose somewhat indirect. The double negative (filtering non-null exceptions, then checking for null) adds mild ambiguity. Overall the code is maintainable but could improve by extracting the error-handling logic or simplifying the stream operations. No major readability blockers, but minor improvements would elevate clarity.

Run 3

The code is well-structured, with clear separation between result handling for individual partitions and all partitions. It uses a flat structure with minimal nesting and small, focused methods. The intent of each method is clearly documented with Javadoc, and action granularity is mostly one action per line. However, readability is slightly reduced by the lambda in `all()` that mixes filtering, mapping, and error handling in a moderately dense block. The error-handling loop checks exception messages for emptiness, adding some cognitive load. Overall, the code is concise and maintainable.

Run 1

Code Structure: Well organized into a constructor and two focused result-access methods. Nesting: Moderate nesting in callbacks, especially the error-message handling in all(), slightly increases reading effort. Clarity of intent: Descriptive names, explicit error handling, and Javadoc make the purpose clear; null representing success is somewhat implicit. Code length: Mostly concise, though duplicated exception construction and separate collection and inspection passes add verbosity. Action granularity: Statements generally perform one action each, and the stream pipeline is split into readable stages. Reading flow: Natural progression from initialization to partition-specific and aggregate results, with clear success and failure branches. Minor formatting inconsistencies and nested asynchronous logic prevent a higher score.

Run 2

Code Structure: Well-organized class with separate methods for partition-specific and aggregate results. Nesting: Moderate nesting in callbacks and error-handling branches adds some complexity, particularly in all(). Clarity of intent: Descriptive method names, types, and Javadoc clearly communicate purpose; the null-as-success convention is implicit. Code length: Mostly concise, though duplicated exception construction and message formatting could be simplified. Action granularity: Statements generally perform one action each, and the stream pipeline separates transformations clearly. Reading flow: Natural progression from state and constructor to public methods; asynchronous callbacks and the combination of a stream with a subsequent loop slightly interrupt the flow. Overall, readable and maintainable with minor opportunities to reduce branching and repetition.

Run 3

Code Structure: Well-organized result wrapper with two focused methods and a clearly defined future field. Nesting: Moderate nesting in asynchronous callbacks, especially the loop and conditional branches in all(), slightly increases reading effort. Clarity of intent: Descriptive method names, types, and Javadoc make partition-level and aggregate outcomes clear, though null-as-success semantics are implicit. Code length: Mostly concise, but duplicated exception-message construction and separate stream and loop traversals add verbosity. Action granularity: Statements generally perform one action each; the stream pipeline remains readable despite combining several transformations. Reading flow: Natural progression from constructor to partition result to aggregate result, with consistent formatting overall. Minor spacing inconsistencies and nested error handling slightly interrupt the flow.