Sample

int-5ec62ab0d2fe-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines52

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8640–1; higher is more readable
Dorn0.7650–1; higher is more readable
Mi0.3770–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro110–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.6520–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))) {} else { return false; } if (!((exception instanceof ExecutionException))) {} else { 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("No controller appears to be active."); } else { return new NotControllerException("The controller is in pre-migration mode."); } } /** * 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("No controller appears to be active."); } else { return new NotControllerException("The active controller appears to be node " + controllerId.getAsInt() + "."); } } }

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.1224.717−40.416
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.331−6.496

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

Score0.864

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
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.962−0.399
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.057+0.384
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.51.907+0.316

Intercept 0.07 + feature contributions = 1.18 (log-odds).
Score = sigmoid(1.18) = 0.765.

Score0.377
Score16
Run 1

The code is generally readable but contains unusual constructs that impair clarity. In `isTimeoutException`, the pattern `if (!((exception == null))) {} else { return false; }` is a convoluted way to write `if (exception == null) return false;`, which adds confusion. Similarly, the check for `ExecutionException` uses an empty if-block with logic in the else, violating the principle of clear intent. The other methods are straightforward and well-documented, with concise logic and good action granularity. However, `newPreMigrationException` does not use its `controllerId` parameter, which is ambiguous. Overall structure is logical and nesting is minimal, but the first method's unnatural control flow and unused parameter reduce readability.

Run 2

The code structure is generally logical, with clear method separation and helpful Javadoc comments. However, readability is severely impacted by the use of inverted conditional patterns like 'if (!((condition))) {} else { ... }' in isTimeoutException. This is a confusing anti-pattern that obscures intent and makes the code difficult to follow. Nesting depth is moderate, but the awkward conditional logic creates unnecessary cognitive overhead. While variable names are reasonable and methods are concise, the abnormal syntax undermines clarity. The action granularity is acceptable, but reading flow is broken by the need to mentally invert conditions. The controller ID parameter is unused in the last two methods, adding slight ambiguity. Overall, the code works but requires extra effort to parse due to unconventional conditional constructs.

Run 3

The code has clear documentation and logical purpose, but suffers from awkward control flow. The `if (!((condition))) {} else { ... }` pattern is highly unidiomatic and confusing; standard `if (condition) { ... }` would be much clearer. In `isTimeoutException`, the null check and exception unwrapping are hard to follow due to this style. The helper methods for exceptions are straightforward, but there is minor redundancy: both `newPreMigrationException` and `newWrongControllerException` share the 'No controller appears to be active' branch, which could be extracted. The string concatenation in `newWrongControllerException` is acceptable. Overall, the code is readable at a high level due to comments and simple actions, but the unnatural conditionals reduce clarity and maintainability.

Run 1

Code Structure: Three clearly separated utility methods provide logical organization. Nesting: Depth is low, but empty if branches and unnecessary else blocks obscure otherwise simple checks. Clarity of intent: Descriptive method names, Javadoc, and exception messages explain the purpose; negated conditions and redundant parentheses make the implementation harder to interpret. Code length: The class is reasonably short, though empty branches and avoidable syntax add noise. Action granularity: Most statements perform one action, but inline empty branches and returns compress control flow onto single lines. Reading flow: Methods follow a sensible sequence, yet inverted checks repeatedly interrupt natural reading. Straightforward null checks, positive instanceof conditions, and early returns would substantially improve readability.

Run 2

Code Structure: Three small, logically separated methods provide good organization. Nesting: Generally shallow, although empty branches and else blocks introduce unnecessary complexity. Clarity of intent: Descriptive method names, documentation, and exception messages explain the purpose, but negated conditions with redundant parentheses obscure straightforward checks. Code length: Compact overall, with avoidable empty branches and else blocks after returns. Action granularity: Most statements perform one action, but inline conditionals and returns in isTimeoutException reduce scanability. Reading flow: Method boundaries and documentation support natural reading, while inverted conditions and empty if bodies repeatedly interrupt it. Conventional guard clauses and simpler boolean expressions would substantially improve readability.

Run 3

Code Structure: Three small, focused methods provide logical organization, although empty if branches obscure the timeout-checking logic. Nesting: Mostly shallow, with only one nested null check. Clarity of intent: Descriptive method names, documentation, and exception messages explain the purpose, but negated conditions and redundant parentheses make simple checks harder to interpret. Code length: Compact overall, though empty branches and unnecessary else blocks add avoidable syntax. Action granularity: Most lines contain one action, but inline conditionals and the compressed empty-branch/else statements reduce scanability. Reading flow: Method boundaries and documentation support navigation, while inverted control flow interrupts the natural progression of guard checks and exception handling.