Sample

int-bd550e2e6d2e-SRC

Unmodified source class

Lines52

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8310–1; higher is more readable
Dorn0.8080–1; higher is more readable
Mi0.5780–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.4790–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); } else { log.error("Encountered {} fault: {}", name, failureMessage, cause); } FaultHandlerException e = (cause == null) ? new FaultHandlerException(name + ": " + failureMessage) : new FaultHandlerException(name + ": " + failureMessage + ": " + cause.getMessage(), cause); if (firstException == null) { firstException = e; } return firstException; } public synchronized void maybeRethrowFirstException() { if (firstException != null && !ignore) { 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.1547.365−51.063
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.584−6.875

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

Score0.831

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.943−0.441
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.796+0.314
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.075+0.216

Intercept 0.07 + feature contributions = 1.435 (log-odds).
Score = sigmoid(1.435) = 0.808.

Score0.578
Score21
Run 1

The code is highly readable with clear structure, logical organization, and minimal nesting. The class purpose is documented, and methods are concise with single responsibilities. Variable names are descriptive (e.g., firstException, ignore) and the logic flows naturally. The only slight complexity is the ternary conditional for constructing FaultHandlerException, but it remains understandable. Overall, excellent readability.

Run 2

The code is well-structured with clear class responsibilities and appropriate synchronization. Nesting is minimal, with only one if-else branch and a ternary operator. Method names clearly convey intent (e.g., maybeRethrowFirstException, setIgnore). The class is concise, avoiding unnecessary verbose implementations. Action granularity is mostly one action per line, though the ternary operator for exception creation condenses logic. Reading flow is natural—constructor, override method, then helper methods. The Javadoc improves understanding. Minor deductions for the slightly complex ternary expression and inconsistent formatting around the ternary operator.

Run 3

The code is generally clear and well-structured. The class has a single responsibility as a mock fault handler for tests, with a logical organization of fields, constructor, and methods. Nesting is minimal, with only a couple of ternary expressions and an if-else block. Intent is mostly clear, though the 'ignore' flag could benefit from a brief comment explaining its purpose. Code length is appropriate—concise without being overly terse. Action granularity is good, with one main action per line except for the ternary expressions, which are still readable. Reading flow is natural: the handler logic flows from logging to exception creation to state tracking. Minor issues include the slightly complex ternary expression for exception creation and the 'ignore' field lacking explanation. Overall, the code is highly readable for its purpose.

Run 1

Code Structure: Fields, constructor, fault handling, and accessor methods are logically organized with clear responsibilities. Nesting: Shallow conditionals keep the code easy to follow. Clarity of intent: Descriptive method names and the class documentation clearly communicate first-fault capture and optional rethrowing; the generic local name 'e' and 'ignore' flag are slightly less explicit. Code length: Compact and appropriate, with only minor repetition in logging and exception construction. Action granularity: Statements generally perform one action per line, although the multiline ternary combines selection, message assembly, and construction. Reading flow: Execution proceeds naturally from logging to exception creation, storage, and return; the ternary and concatenated message slightly interrupt scanning.

Run 2

Code Structure: Fields, constructor, fault handling, and accessor methods are logically organized. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: Descriptive names and the class documentation clearly explain first-fault storage and optional rethrowing, though the meaning of ignore could be more explicit. Code length: Compact and appropriately sized, with only minor repetition in logging and exception construction. Action granularity: Each statement performs a distinct action; the multiline ternary is slightly harder to scan than the surrounding code. Reading flow: The progression from logging to exception creation, storage, and return is natural, followed by simple supporting methods. Overall, highly readable with small opportunities to clarify the ignore flag and simplify exception construction.

Run 3

Code Structure: Well-organized class with fields, constructor, and focused methods. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: Descriptive method names and the class documentation clearly explain first-fault storage and optional rethrowing; the local variable 'e' and field 'ignore' could be more specific. Code length: Concise overall, though null checks and exception-message construction introduce minor repetition. Action granularity: Statements generally perform one action each, with no compressed multi-statement lines. Reading flow: Methods follow a natural progression from handling faults to inspecting or rethrowing them and configuring behavior. The multiline ternary and concatenated exception message slightly interrupt otherwise smooth reading.