Sample

int-c3de445c806e-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines52

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8880–1; higher is more readable
Dorn0.7930–1; higher is more readable
Mi0.3590–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.660–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 is(Throwable exc) { if (exc == null) return false; if (exc instanceof ExecutionException) { exc = exc.getCause(); if (exc == null) return false; } return exc 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 new2(OptionalInt controller2) { if (controller2.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 new3(OptionalInt controller3) { if (controller3.isPresent()) { return new NotControllerException("The active controller appears to be node " + controller3.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.1066.689−35.201
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.28−6.42

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

Score0.888

Feature contributions

FeatureValueContribution
(log-odds)
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.93+0.696
Indentation frequencyHow rapidly indentation changes from line to line.36+0.508
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.048+0.472
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.67+0.312
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.92.981−0.273

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

Score0.359
Score16
Run 1

The code is simple but has clarity issues. The structure is mostly logical, but method names like 'is', 'new2', and 'new3' do not convey intent; 'is' is vague, while 'new2' and 'new3' are especially misleading because they do not indicate what exception is being created. This weakens the 'clarity of intent' criterion. Nesting is flat, which is good. Code length is concise, though some duplication exists between 'new2' and 'new3' (both have an else-branch returning the same 'no controller' message). Action granularity is fine. Reading flow is mostly natural, but the generic 'is' method disrupts flow without documentation of its specific role. Overall, the code is readable but impaired by ambiguous naming and mild duplication.

Run 2

The code is well-structured with clear method separation and Javadoc comments that explain purpose. Nesting is minimal (max 2 levels), and each method performs a single logical action. However, readability issues include poor method/parameter naming ('is', 'new2', 'new3', 'controller2', 'controller3') which obscures intent despite the comments. The 'is' method mutates its parameter (reassigning 'exc'), which is slightly confusing. Javadoc parameters don't match actual parameter names, and the behavior difference between new2/new3 is subtle and not immediately obvious from names. The code is concise but could benefit from more expressive naming and consistent documentation.

Run 3

The code is well-structured with clear separation of methods and helpful Javadoc comments. Nesting is minimal and readable. However, method names like 'is', 'new2', and 'new3' are ambiguous and do not clearly convey intent. Parameter names 'controller2' and 'controller3' are equally confusing. Some Javadoc params reference non-existent parameters (e.g., 'controllerId' but method uses 'controller2'). The ternary or if-else logic is straightforward, and each action is on its own line, aiding readability. But the unclear naming and inconsistent documentation reduce clarity, making the code harder to understand at a glance.

Run 1

Code Structure: Three small, logically separated methods make the class easy to navigate. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Exception messages and Javadocs explain behavior, but vague method names (is, new2, new3) and numbered parameter names obscure intent; Javadoc parameter names also mismatch the actual signatures. Code length: Concise overall, with minor repetition in exception construction and unnecessary else branches after returns. Action granularity: Most lines perform one action, although inline null checks combine a condition and return on one line. Reading flow: Straightforward control flow and consistent formatting support readability, but weak naming, stale documentation, and minimal spacing around imports interrupt understanding.

Run 2

Code Structure: Three small, logically separated methods provide clear organization. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Exception types, messages, and documentation explain behavior, but vague names such as is, new2, new3, controller2, and controller3 obscure purpose. Javadoc parameter names do not match the actual parameters, reducing trust in the documentation. Code length: Methods are concise, though redundant else branches and repeated exception construction add minor verbosity. Action granularity: Most lines contain a single action, but inline null checks combine conditions and returns. Reading flow: The methods are straightforward to follow, although inconsistent spacing around imports and poor naming interrupt an otherwise natural flow.

Run 3

Code Structure: Three small, logically separated methods provide clear organization. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Exception types, messages, and documentation explain behavior, but names such as is, new2, new3, controller2, and controller3 obscure purpose. Javadoc parameter names do not match actual parameters, reducing trust in the documentation. Code length: Methods are concise, though repeated exception construction and unnecessary else branches add minor redundancy. Action granularity: Most lines contain one action, but inline null checks combine conditions and returns. Reading flow: Method boundaries and straightforward control flow are easy to follow; weak naming, inconsistent import grouping, and mismatched documentation interrupt otherwise natural reading.