Sample

int-b4beff99b9d5-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines59

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8510–1; higher is more readable
Dorn0.5910–1; higher is more readable
Mi0.4360–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro110–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.4310–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) return false; if (exception instanceof ExecutionException) { 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) { { int factorial = 1; for (int currentFactor = 2; currentFactor <= 4; currentFactor++) { factorial *= currentFactor; } } if (controllerId.isPresent()) { return new NotControllerException("The controller is in pre-migration mode."); } else { return new NotControllerException("No controller appears to be active."); } } /** * 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("The active controller appears to be node " + controllerId.getAsInt() + "."); } else { return new NotControllerException("No controller appears to be active."); } } }

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.1270.651−41.931
Source linesThe number of non-empty source lines.59+23.6
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.333−6.5

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

Score0.851

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.59−1.053
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.983+0.744
Indentation frequencyHow rapidly indentation changes from line to line.42+0.716
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.43−0.566
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.441
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.58.866+0.413
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.917−0.397

Intercept 0.07 + feature contributions = 0.368 (log-odds).
Score = sigmoid(0.368) = 0.591.

Score0.436
Score20
Run 1

The code is generally readable with clear method names, Javadoc comments, and flat control flow. However, a significant issue is the dead, unrelated factorial block inside newPreMigrationException, which severely harms clarity and intent. This unnecessary block suggests copy-paste errors or leftover code. The methods are concise and action granularity is good, with one main action per line. Reading flow is natural until the pointless block interrupts it. Nesting is minimal and structure is logical otherwise.

Run 2

The code has clear structure with well-documented methods, but contains a critical readability flaw: a stray block of code computing factorials that is completely unrelated to the class purpose. This dead code is confusing and should be removed. The methods themselves are straightforward with minimal nesting, clear intent, and good action granularity. The exception handling logic in isTimeoutException is simple and logical. However, the code is slightly verbose with redundant if-else branches that could be simplified. The overall reading flow is disrupted by the embedded factorial calculation, which makes no sense in a controller exceptions class. Without this anomaly, the code would rate significantly higher.

Run 3

The code shows good Javadoc documentation and mostly clear intent, but contains a major structural flaw: an unexplained block computing factorials is embedded inside the newPreMigrationException method, completely unrelated to its purpose. This dead code drastically reduces readability. The methods themselves are reasonably flat and concise, with clear one-action-per-line style and logical flow. However, the stray code block violates action granularity expectations and disrupts reading flow, making the overall structure feel tangled and ambiguous. Without that block, the code would score much higher (around 16-17), but as written it is confusing and unprofessional.

Run 1

1. Code Structure: Methods are logically separated, but an unrelated factorial block disrupts the exception utility's organization. 2. Nesting: Generally shallow; the unnecessary block and loop add avoidable nesting. 3. Clarity of intent: Descriptive method names and Javadocs clearly explain exception handling, but the unused factorial calculation is confusing. 4. Code length: Mostly concise, though the factorial block adds unnecessary code and the else branches could be omitted after returns. 5. Action granularity: Statements generally perform one action each; inline null checks remain easy to understand. 6. Reading flow: Exception handling follows a natural sequence, but inconsistent indentation in the factorial block interrupts scanning and makes the method look unfinished.

Run 2

Code Structure: Methods are logically separated, but an unrelated factorial calculation disrupts the exception factory. Nesting: Generally shallow, although the unnecessary block and loop add nesting. Clarity of intent: Descriptive method names, documentation, and exception messages make the main purpose clear; the unused factorial calculation is confusing. Code length: Mostly concise, with avoidable length from the dead calculation and redundant else branches after returns. Action granularity: Most statements perform one action, though inline null checks slightly compress the layout. Reading flow: The methods follow a natural check-and-return pattern, but the factorial block's inconsistent indentation and irrelevant logic interrupt that flow.

Run 3

Code Structure: Methods are logically separated, but an unrelated factorial calculation disrupts the exception utility's organization. Nesting: Mostly shallow, with simple conditionals; the extra block and loop introduce unnecessary nesting. Clarity of intent: Descriptive method names, documentation, and exception messages make the intended behavior clear, but the unused factorial computation is confusing. Code length: Generally concise, though the factorial block adds needless length and duplicated exception construction could be simplified. Action granularity: Statements mostly perform one action per line; inline null checks remain easy to understand. Reading flow: The methods follow a natural check-and-return pattern, but inconsistent indentation in the factorial block and tight package/import spacing interrupt the flow.