Sample

int-457500e9e433-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines52

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8680–1; higher is more readable
Dorn0.7850–1; higher is more readable
Mi0.3410–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.680–1; higher is more readable

Views

Source code

package org.apache.kafka.controller.errors; import org.apache.kafka.common.errors.NotControllerException; import org.apache.kafka.common.errors.TimeoutException; import java.util.OptionalInt; import java.util.concurrent.ExecutionException; public class ControllerExceptions { /** * Check if an exception is a normal timeout exception. * * @param exception The exception to check. * @return True if the exception is a timeout exception. */ public static boolean isTimeoutException(Throwable exception) { if (exception == null) return false; if (exception instanceof ExecutionException) { exception = exception.getCause(); if (exception == null) return false; } return exception instanceof TimeoutException; } /** * Create a new exception indicating that the controller is in pre-migration mode, so the * operation cannot be completed. * * @param controllerId The current controller. * @return The new NotControllerException. */ public static NotControllerException newPreMigrationException(OptionalInt controllerId) { if (controllerId.isPresent()) { return new NotControllerException("The controller is in pre-migration mode."); } else { return new NotControllerException("No controller appears to be active."); } } /** * Create a new exception indicating that current node is not the controller. * * @param controllerId The current controller. * @return The new NotControllerException. */ public static NotControllerException newWrongControllerException(OptionalInt controllerId) { if (controllerId.isPresent()) { return new NotControllerException("The active controller appears to be node " + controllerId.getAsInt() + "."); } else { return new NotControllerException("No controller appears to be active."); } } }

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.1061.18−35.019
Source linesThe number of non-empty source lines.52+20.8
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.297−6.445

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

Score0.868

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.53−0.84
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.96+0.744
Indentation frequencyHow rapidly indentation changes from line to line.36+0.508
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.497
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.95.943−0.399
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.51.814+0.314

Intercept 0.07 + feature contributions = 1.293 (log-odds).
Score = sigmoid(1.293) = 0.785.

Score0.341
Score16
Run 1

The code is well-structured, using a clean utility class with three static methods, each serving a clear purpose. Nesting is minimal, limited to straightforward conditional checks. Variable and method names (e.g., `isTimeoutException`, `newPreMigrationException`) clearly communicate intent. The code is concise, with each method focused on a single task. The `isTimeoutException` method uses early returns for flat, readable logic. Action granularity is good, with one logical operation per line. Reading flow is natural, moving from exception checking to exception creation. Minor deductions: repeated 'No controller appears to be active.' string could be extracted for consistency, and some string concatenation in `newWrongControllerException` is slightly awkward but not unreadable.

Run 2

The code is highly readable with clear structure, minimal nesting, and concise methods. Each method has a single responsibility and clear Javadoc documentation. The only minor issues are slightly repetitive if-else blocks in the exception factory methods and a multi-line string concatenation that could be slightly cleaner.

Run 3

The code is well-organized into a single utility class with clear static methods. Structure is logical, and each method has a single responsibility. Nesting is minimal—only one level deep in the timeout check and simple if/else branches elsewhere. The intent is clearly communicated through descriptive method names and Javadoc comments. Code length is concise and avoids unnecessary verbosity. Action granularity is generally one action per line, except the if/else returns which are acceptable. Reading flow is natural: null handling, cause unwrapping, then type check reads cleanly. Minor deductions: the `newPreMigrationException` and `newWrongControllerException` methods have repeated 'No controller appears to be active' strings, which could be extracted, and the timeout method's reassignment of the parameter slightly reduces clarity. Overall, highly readable.

Run 1

1. Code Structure: Three focused utility methods are logically organized and documented. 2. Nesting: Shallow conditionals and early returns keep control flow simple. 3. Clarity of intent: Descriptive method names, explicit exception types, and clear messages communicate purpose well; the pre-migration method's documentation could better explain its inactive-controller case. 4. Code length: The implementation is concise, though return-after-if branches could omit else, and documentation is somewhat verbose for simple methods. 5. Action granularity: Most lines perform one action; inline null checks combine a condition and return but remain easy to understand. 6. Reading flow: Consistent formatting and straightforward branching support natural reading, with minor improvements possible in import grouping and spacing.

Run 2

Code Structure: Three focused methods are logically grouped in a utility-style class. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Descriptive method names, JavaDoc, and explicit exception messages make each method's purpose clear. Code length: Methods are concise, though repeated inactive-controller messages and unnecessary else blocks after returns introduce minor redundancy. Action granularity: Most lines perform one action; inline null-check returns slightly compress condition and action. Reading flow: Methods follow a natural check-and-return sequence, with consistent formatting overall. Import grouping and spacing could be improved, but these are minor readability issues.

Run 3

Code Structure: Three focused utility methods are logically organized and documented. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Descriptive method names, explicit exception types, and helpful messages clearly communicate purpose. Code length: Methods are concise, though repeated inactive-controller messages and unnecessary else branches add minor verbosity. Action granularity: Statements generally perform one action each; inline null checks slightly compress condition and return onto one line. Reading flow: Consistent formatting and straightforward branching make execution easy to follow, with only minor interruptions from parameter reassignment and multiline string concatenation.