Sample

int-e1a3f5732cf5-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

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 Pro16.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 well-structured and readable. It has clear separation of concerns with logical method organization, flat nesting, and concise implementation. The class purpose is documented, method names clearly convey intent, and functionality is appropriately granular. Minor issues include slightly awkward conditional handling for null causes (could use a helper method or ternary for cleaner separation) and the ternary operator spanning multiple lines in handleFault reduces readability slightly. The maybeRethrowFirstException method shows clear intent, and synchronized methods maintain thread-safety, though this could be noted. Overall, the code follows good Java practices, maintains reasonable length, and flows naturally from top to bottom.

Run 2

The code is well-structured and readable overall. It follows a logical organization with clear separation of methods and fields. The nesting is minimal, with only one level of conditional in the handleFault method. Intent is clearly expressed through meaningful names like 'handleFault', 'maybeRethrowFirstException', and 'firstException'. The code is concise - no unnecessary boilerplate or redundant logic. Action granularity follows good practice, with each line performing a single logical operation. Reading flow is natural, with fields, constructor, override, and utility methods in a logical order. The conditional ternary for exception creation is readable but slightly complex; could be improved by extracting a helper method for exception construction. The logging and exception handling are clear. Overall, this is maintainable, test-oriented code with good Java conventions.

Run 3

The code is generally well-structured and readable. It has a clear class purpose, logical method organization, and minimal nesting (only one if-else in handleFault). Intent is mostly clear from method names and Javadoc. However, the handleFault method could be more readable: the ternary operator packs multiple actions into one expression, and the repeated cause == null checks add slight cognitive overhead. The class is concise with no unnecessary length. Each statement generally performs one action. Reading flow is natural, though the log-and-then-construct-exception sequence could be separated more explicitly. Overall, solid readability with minor room for simplification in the exception construction logic.

Run 1

Code Structure: Well-organized class with clearly separated state, constructor, fault handling, and accessors. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: Descriptive method names and the class comment clearly explain first-fault recording and optional rethrowing; the name 'ignore' is slightly vague. Code length: Concise overall, though repeated null checks and message construction add minor duplication. Action granularity: Statements generally perform one action per line; the multiline ternary combines exception selection and message construction, slightly increasing reading effort. Reading flow: Methods follow a natural sequence, and consistent formatting supports scanning. The ternary expression is the main readability distraction.

Run 2

Code Structure: Fields, constructor, fault handling, and accessors are logically organized into focused methods. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: The class documentation and descriptive method names clearly explain recording and optionally rethrowing the first fault; the generic local name 'e' and 'ignore' flag are slightly less explicit. Code length: Compact and appropriate, although null-dependent logging and exception construction repeat some logic. Action granularity: Each statement performs a distinct action, with no compressed multi-statement lines. Reading flow: Natural top-to-bottom progression and consistent formatting support readability. The multiline ternary and concatenated exception message introduce minor visual complexity.

Run 3

Code Structure: Fields, constructor, fault handling, and accessors are logically organized into focused methods. Nesting: Shallow conditionals make control flow easy to follow. Clarity of intent: The class documentation and descriptive method names clearly explain recording and optionally rethrowing the first fault; the generic variable name 'e' and 'ignore' field are slightly less explicit. Code length: Compact and appropriately sized, with little unnecessary code. Action granularity: Statements generally perform one action each, though exception construction combines conditional selection and message formatting. Reading flow: Natural top-to-bottom organization and consistent formatting support readability. The multiline ternary and concatenated exception message slightly interrupt the otherwise straightforward flow.