Sample

int-08c3795b452c-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines52

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.880–1; higher is more readable
Dorn0.8010–1; higher is more readable
Mi0.5950–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4560–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 nam) { this.name = nam; } @Override public synchronized RuntimeException handle(String failure, Throwable cau) { if (cau == null) { log.error("Encountered {} fault: {}", name, failure); } else { log.error("Encountered {} fault: {}", name, failure, cau); } FaultHandlerException e = (cau == null) ? new FaultHandlerException(name + ": " + failure) : new FaultHandlerException(name + ": " + failure + ": " + cau.getMessage(), cau); if (firstException == null) { firstException = e; } return firstException; } public synchronized void maybe() { if (firstException != null && !ignore) { throw firstException; } } public synchronized FaultHandlerException first() { return firstException; } public synchronized void set(boolean ign) { this.ignore = ign; } }

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.1563.782−51.605
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.555−6.833

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

Score0.88

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.981−0.443
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.079+0.172

Intercept 0.07 + feature contributions = 1.39 (log-odds).
Score = sigmoid(1.39) = 0.801.

Score0.595
Score21
Run 1

The code is well-structured and readable. Methods are short, focused, and have clear intent, following a natural flow with good naming conventions. Nesting is minimal, and the class has logical organization. However, some parameter names are abbreviated ('nam', 'cau', 'ign'), reducing clarity. The conditional expression for creating FaultHandlerException could be slightly more readable if formatted differently. The maybe() method's name is ambiguous without context. The code is concise but could benefit from slightly more descriptive naming and minor formatting improvements, making it a 16 out of 20.

Run 2

The code is generally clear and well-structured with a logical class layout. It has a single-purpose class with flat nesting and straightforward methods. However, readability is reduced by poor parameter naming (`nam`, `cau`, `ign`) and method names (`maybe`, `set`) that do not clearly communicate intent. The conditional logging and exception construction create some visual clutter, and the action granularity is slightly compressed in places. Overall, the class is concise but could be improved with more descriptive naming and slightly more spacing for readability.

Run 3

The code is generally structured and readable: it has a clear class purpose, Javadoc, simple fields, and flat, mostly understandable methods. However, readability is undermined by poor parameter names ('nam', 'cau', 'ign'), which obscure intent and introduce ambiguity. The 'handle' method contains a few multi-step lines and nested ternary logic that slightly harms readability. The 'maybe' method name is unclear; it would be better as 'maybeThrow' or 'checkAndThrow'. While the class is concise and avoids deep nesting, naming choices and lack of clear action separation bring the score down.

Run 1

Code Structure: Fields, constructor, and small methods are logically organized, with fault handling concentrated in one method. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: The class documentation and firstException field explain the main purpose, but names such as nam, cau, e, maybe, first, and set obscure parameter meanings and method behavior. The documentation also references handleFault rather than handle. Code length: Compact without substantial unnecessary code, although exception construction is somewhat visually dense. Action granularity: Statements generally perform one action per line; the multiline ternary combines branching, string construction, and object creation. Reading flow: The overall progression is natural, but abbreviated names, generic accessor names, and the wrapped ternary interrupt readability.

Run 2

Code Structure: Fields, constructor, fault handling, and accessors are logically organized. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: The class documentation and firstException field explain the main purpose, but vague method names (maybe, first, set) and abbreviated parameters (nam, cau, ign) obscure behavior. The documentation also references handleFault rather than the actual handle method. Code length: Compact and generally appropriate, though cause checking is repeated. Action granularity: Each statement performs a focused action, with no crowded multi-statement lines. Reading flow: Mostly natural, but the multiline ternary and message concatenation require extra attention. More descriptive names and slightly cleaner exception construction would improve readability.

Run 3

Code Structure: Fields, constructor, fault handling, and accessor methods are logically organized. Nesting: Shallow conditionals keep the code easy to follow. Clarity of intent: The class documentation and descriptive fields help, but method names such as maybe, first, and set, plus abbreviated parameters nam, cau, and ign, obscure intent. The documentation references handleFault rather than the actual handle method. Code length: Compact and mostly appropriate, though fault logging and exception construction repeat the null-cause distinction. Action granularity: Statements generally perform one action each; the multiline ternary requires slightly more effort to parse. Reading flow: Execution proceeds naturally from logging to exception construction, first-exception storage, and return, with minor friction from terse naming and the wrapped conditional expression.