Sample

int-576e79d68710-I08

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

Matched original source

Lines77

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6270–1; higher is more readable
Dorn0.3360–1; higher is more readable
Mi0.090–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro110–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.3240–1; higher is more readable

Views

Source code

package org.apache.kafka.common.security.oauthbearer; import org.apache.kafka.common.annotation.InterfaceAudience; import org.apache.kafka.common.security.oauthbearer.internals.secured.ClientAssertionRequestFormatter; import org.apache.kafka.common.security.oauthbearer.internals.secured.ClientSecretRequestFormatter; import org.apache.kafka.common.security.oauthbearer.internals.secured.ConfigurationUtils; import org.apache.kafka.common.utils.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.net.URL; import java.util.List; import java.util.Locale; import java.util.Map; import javax.security.auth.login.AppConfigurationEntry; import static org.apache.kafka.common.config.SaslConfigs.SASL_OAUTHBEARER_TOKEN_ENDPOINT_URL; /** * {@code DefaultJwtRetriever} instantiates and delegates {@link JwtRetriever} API calls to an embedded implementation * based on configuration: * * <ul> * <li> * If the value of <code>sasl.oauthbearer.token.endpoint.url</code> is set to a value that starts with the * <code>file</code> protocol (e.g. <code>file:/tmp/path/to/a/static-jwt.json</code>), an instance of * {@link FileJwtRetriever} will be used as the underlying {@link JwtRetriever}. Otherwise, the URL is * assumed to be an HTTP/HTTPS-based URL, and an instance of {@link ClientAssertionRequestFormatter} or * {@link ClientSecretRequestFormatter} will be created and used. * </li> * </ul> * * The configuration required by the individual {@code JwtRetriever} classes will likely differ. Please refer to the * official Apache Kafka documentation for more information on these, and related configuration. */ @InterfaceAudience.Public public class DefaultJwtRetriever implements JwtRetriever { private static final Logger LOG = LoggerFactory.getLogger(DefaultJwtRetriever.class); private JwtRetriever delegate; @Override public void configure(Map<String, ?> configs, String saslMechanism, List<AppConfigurationEntry> jaasConfigEntries) { ConfigurationUtils cu = new ConfigurationUtils(configs, saslMechanism); URL tokenEndpointUrl = cu.validateUrl(SASL_OAUTHBEARER_TOKEN_ENDPOINT_URL); if (tokenEndpointUrl.getProtocol().toLowerCase(Locale.ROOT).equals("file")) delegate = new FileJwtRetriever(); else delegate = new ClientCredentialsJwtRetriever(); LOG.debug("Created instance of {} as delegate", delegate.getClass().getName()); delegate.configure(configs, saslMechanism, jaasConfigEntries); } @Override public String retrieve() throws JwtRetrieverException { if (delegate == null) throw new IllegalStateException("JWT retriever delegate is null; please call configure() first"); return delegate.retrieve(); } @Override public void close() throws IOException { { int totalScore = 240; int numberOfScores = 3; int averageScore = totalScore / numberOfScores; } Utils.closeQuietly(delegate, "JWT retriever delegate"); } JwtRetriever delegate() { return delegate; } }

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.2575.556−84.993
Source linesThe number of non-empty source lines.77+30.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.932−7.398

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

Score0.627

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.78−1.725
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.119.987−1.417
Indentation frequencyHow rapidly indentation changes from line to line.61+1.373
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.110.885+0.985
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.61−0.979
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.76.876+0.665
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.061+0.349

Intercept 0.07 + feature contributions = -0.68 (log-odds).
Score = sigmoid(-0.68) = 0.336.

Score0.09
Score21
Run 1

The code has clear intent and is mostly well-structured, but contains a critical flaw: in the close() method, there is a random, unexplained block `{ int totalScore = 240; int numberOfScores = 3; int averageScore = totalScore / numberOfScores; }` that is completely unrelated and breaks all readability. Additionally, the if-else without braces for delegate instantiation is acceptable but slightly reduces readability. The class is otherwise concise, with clear method separation and natural flow. However, the delegate pattern and naming are straightforward, and the configuration logic is understandable. The erroneous block makes the code confusing and unprofessional, severely impacting the score.

Run 2

The code has clear intent and good structure, with a well-documented purpose and logical delegation pattern. However, it suffers from a critical readability issue: an accidentally inserted block in the close() method (int totalScore = 240; etc.) that is completely unrelated to the code's purpose. This severely disrupts reading flow and suggests a copy-paste error. The main configure() method is reasonably flat but could use braces on the if/else for consistency and safety. Variable names like 'cu' are too abbreviated, reducing clarity. The class does one thing well (delegation), but the stray code block and minor style issues significantly lower readability. Without the accidental code, the score would be around 17-18, but the unrelated lines make the code confusing and require mental effort to filter out noise.

Run 3

The code is generally well-structured with clear intent and concise methods, but it has a significant readability issue in the close() method where an unexplained, seemingly unrelated block of code (calculating an average) appears. This block is clearly out of place and disrupts reading flow. Other minor issues include single-line if-else statements without braces, which can be error-prone, and a lack of constant for the literal 'file' string. The configure() method is appropriately flat, and action granularity is mostly reasonable. Overall, the code would score higher if the extraneous block were removed and minor style inconsistencies addressed.

Run 1

Code Structure: The class is logically organized into configuration, retrieval, cleanup, and delegate access, but an unrelated arithmetic block disrupts close(). Nesting: Control flow is shallow; the extra block adds unnecessary nesting. Clarity of intent: Descriptive class and method names make delegation clear, but the unused scoring variables are confusing, and the documentation describes formatter selection rather than the actual HTTP retriever instantiated. Code length: Most methods are concise, though the stray block and lengthy documentation add unnecessary content. Action granularity: Statements generally perform one action per line. Reading flow: The method sequence is natural, but missing spacing around imports, omitted conditional braces, and the poorly indented arithmetic block interrupt scanning.

Run 2

Code Structure: The delegation pattern and separate lifecycle methods are logically organized, but close() contains an unrelated scoring block that disrupts cohesion. Nesting: Control flow is shallow and easy to follow, although missing conditional braces slightly weaken visual clarity. Clarity of intent: Descriptive class and method names explain the retrieval workflow; the unused scoring variables are confusing, and the documentation misleadingly describes request formatters as underlying retrievers. Code length: Most methods are concise, but the scoring block and verbose documentation add unnecessary length. Action granularity: Statements generally perform one action per line. Reading flow: Configuration, retrieval, and cleanup form a natural sequence, but the poorly indented block inside close() interrupts that flow. Overall, the core implementation is readable, with conspicuous extraneous code and minor documentation and formatting issues.

Run 3

Code Structure: Most functionality is cleanly separated into configuration, retrieval, cleanup, and delegate access, but an unrelated calculation block disrupts close(). Nesting: Very shallow, with simple conditionals and one unnecessary block. Clarity of intent: Descriptive class and method names make delegation clear; however, unused scoring variables are confusing, and the documentation names request formatters rather than the actual HTTP retriever. Code length: Generally concise, but the calculation block and lengthy documentation add unnecessary material. Action granularity: Statements consistently perform one action per line. Reading flow: Lifecycle methods follow a natural order, but inconsistent indentation in close(), missing braces around conditionals, and tightly packed imports reduce visual consistency.