Sample

int-becc504c6cd2-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines52

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8230–1; higher is more readable
Dorn0.7930–1; higher is more readable
Mi0.5660–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro100–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.4330–1; higher is more readable

Views

Source code

package org.apache.kafka.common.test; import org.apache.kafka.server.fault.FaultHandler; import org.apache.kafka.server.fault.FaultHandlerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This is a fault handler suitable for use in JUnit tests. It will store the result of the first * call to handleFault that was made. */ public class MockFaultHandler implements FaultHandler { private static final Logger log = LoggerFactory.getLogger(MockFaultHandler.class); private final String name; private FaultHandlerException firstException = null; private boolean ignore = false; public MockFaultHandler(String name) { this.name = name; } @Override public synchronized RuntimeException handleFault(String failureMessage, Throwable cause) { if (!((cause == null))) { log.error("Encountered {} fault: {}", name, failureMessage, cause); } else { log.error("Encountered {} fault: {}", name, failureMessage); } FaultHandlerException e = (cause == null) ? new FaultHandlerException(name + ": " + failureMessage) : new FaultHandlerException(name + ": " + failureMessage + ": " + cause.getMessage(), cause); if (!((firstException == null))) {} else { firstException = e; } return firstException; } public synchronized void maybeRethrowFirstException() { if (!((firstException != null && !ignore))) {} else { throw firstException; } } public synchronized FaultHandlerException firstException() { return firstException; } public synchronized void setIgnore(boolean ignore) { this.ignore = ignore; } }

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.1674.297−55.252
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.603−6.905

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

Score0.823

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.49+0.958
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.97+0.761
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.96.962−0.442
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.806+0.314
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.084+0.122

Intercept 0.07 + feature contributions = 1.341 (log-odds).
Score = sigmoid(1.341) = 0.793.

Score0.566
Score21
Run 1

The code has clear class-level intent and is relatively short, but readability suffers from several issues. The if-else conditions are inverted and use double negatives like `if (!((cause == null)))`, which makes the logic unnecessarily hard to follow. Several empty if blocks with else-only logic (`if (!((firstException == null))) {} else { ... }`) are confusing and violate action granularity. Nesting is shallow, which is good, and the class structure is logical. However, reading flow is disrupted by these awkward conditionals and empty blocks. The ternary operator for exception creation is acceptable but combined with the inverted conditions adds cognitive load. Variable naming is clear, and logging is appropriately placed. Overall, the code needs refactoring for clarity of intent and more natural conditionals to reach good readability.

Run 2

The code has a clear purpose and decent structure, but readability is hampered by awkward conditional logic, unnecessary nesting, and a confusing return value in handleFault. The use of 'if (!((...))) {} else {...}' patterns is obscure and should be simplified to straightforward 'if (...) {...} else {...}'. The method handleFault returns the stored first exception rather than the newly created one, which is non-intuitive and makes the code harder to follow. Some lines combine multiple actions or are excessively long. The logging and exception creation could be more concise. Overall, the code is understandable but would benefit from cleaner conditional expressions and clearer intent.

Run 3

The code has a clear class-level purpose and good logging, but several choices hurt readability. The conditionals like `if (!((cause == null)))` and `if (!((firstException == null))) {} else { ... }` are inverted and awkward, forcing the reader to mentally negate expressions. Empty `if` blocks before `else` statements are confusing and add unnecessary nesting. The ternary expression for creating `FaultHandlerException` is compact but reduces clarity compared to a simple if-else. Action granularity is mostly fine, but the overall reading flow suffers from unnatural condition ordering. Structurally, the class is short and single-purpose, and method names are descriptive. Reducing the negated conditions and empty blocks would immediately improve readability to a higher level.

Run 1

Code Structure: Fields, constructor, and focused methods are logically organized. Nesting: Control flow is shallow, but empty if branches followed by else blocks add needless complexity. Clarity of intent: Descriptive names and the class comment explain the purpose, while redundant parentheses and negated conditions obscure straightforward null checks and rethrow logic. Code length: The class is compact, though several conditional expressions could be simplified. Action granularity: Most lines perform one action; the multiline exception construction remains understandable. Reading flow: Method order is natural, but inverted checks, empty branches, and the wrapped ternary interrupt otherwise clean reading.

Run 2

Code Structure: Fields, constructor, and focused methods are logically organized. Nesting: Control flow is shallow, but empty if branches followed by else blocks add avoidable complexity. Clarity of intent: Class documentation and method names explain the purpose well; redundant parentheses and negated conditions obscure straightforward null checks and rethrow logic. Code length: The class is compact, though repeated logging branches and awkward conditional forms introduce unnecessary verbosity. Action granularity: Most lines perform one action, with no dense sequences of statements; the multiline exception-construction ternary is somewhat harder to scan. Reading flow: The overall progression is natural, but inverted conditions, empty blocks, and wrapped string concatenation interrupt readability.

Run 3

Code Structure: Fields, constructor, and small methods are logically organized with clear responsibilities. Nesting: Control flow is shallow, but empty if branches followed by else blocks obscure simple conditions. Clarity of intent: Descriptive method names and the class comment explain the purpose; redundant parentheses and negated conditions make exception handling harder to understand. Code length: Mostly concise, though unnecessary conditional syntax and repeated exception-message construction add clutter. Action granularity: Statements generally perform one action per line; compressed empty branches reduce visual clarity. Reading flow: The overall progression is natural, but inverted null checks, empty branches, and a multiline ternary interrupt straightforward reading.