Sample

int-04977a141eed-I10

Remove about 40% of line-break groups while retaining structure

Matched original source

Lines50

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.550–1; higher is more readable
Dorn0.0780–1; higher is more readable
Mi00–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro70–20; mean of three runs
GPT-6.1 Sol10.670–20; mean of three runs
BTTF0.4120–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 { 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.2411.137−79.568
Source linesThe number of non-empty source lines.50+20
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.953−7.429

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

Score0.55

Feature contributions

FeatureValueContribution
(log-odds)
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.232.98−6.203
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.233+2.955
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.51−0.769
Indentation frequencyHow rapidly indentation changes from line to line.34+0.439
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.061+0.349
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.49.821+0.287

Intercept 0.07 + feature contributions = -2.475 (log-odds).
Score = sigmoid(-2.475) = 0.078.

Score0
Score18
Run 1

The code suffers from severe formatting issues that make it extremely difficult to read. Multiple statements are crammed onto single lines (e.g., package declaration followed by multiple imports on one line, class declaration concatenated with Javadoc, method signatures combined with method bodies). This violates fundamental readability principles. The logic itself is relatively simple - a factory pattern that delegates to either FileJwtRetriever or ClientCredentialsJwtRetriever based on URL protocol - but the poor formatting obscures this intent. Nesting is minimal and action granularity is acceptable in some places but compromised elsewhere by line compression. The reading flow is disrupted by inconsistent spacing and the mixing of unrelated code elements on single lines. While the code's purpose is understandable once deciphered, a developer would need to reformat it first to work with it effectively. Proper formatting alone would likely raise this to a 15+ score.

Run 2

The code has several readability problems. Multiple statements are packed onto single lines, and imports are jumbled together with class declarations and Javadocs on the same physical lines. The class-level Javadoc is thorough but visually cramped due to formatting. The configure() method combines variable declarations, conditional logic, logging, and delegation into a compact block, making the flow harder to follow. While the overall logic is straightforward and the structure could be clear with standard formatting, the current presentation significantly hinders scanning and comprehension. Nesting is minimal, and intent is generally understandable, but the lack of whitespace and conventional line breaks undermines clarity and creates a disorganized reading experience.

Run 3

The code is functional but poorly structured. Multiple imports and class declarations are compressed onto single lines, breaking the natural reading flow. The `configure()` method has an if-else with single-line bodies and no braces, reducing clarity. Javadoc is dense and complex. The `delegate` field, while simple, is not immediately obvious from the structure. On the positive side, methods are relatively short and each performs a single action per line. However, the inconsistent formatting, lack of vertical separation between members, and mixed style choices (some braces used, some not) all contribute to reduced readability and maintainability.

Run 1

Code Structure: The delegation design and separation into configure, retrieve, close, and accessor methods are logical, but compressed declarations obscure boundaries. Nesting: Control flow is shallow and easy to follow, although missing braces reduce visual clarity. Clarity of intent: Descriptive class and method names, logging, and the initialization check communicate purpose; the documentation misleadingly describes formatter creation rather than the actual retriever selection. Code length: The implementation is concise without substantial unnecessary logic, though documentation is disproportionately long. Action granularity: Multiple imports, annotations, declarations, and statements share lines, making scanning difficult. Reading flow: The configuration-to-delegation sequence is natural, but inconsistent line breaks and formatting repeatedly interrupt readability.

Run 2

Code Structure: The delegation design and separate configure, retrieve, and close methods provide logical organization, but compressed declarations obscure boundaries. Nesting: Control flow is shallow and straightforward, although missing conditional braces reduce visual clarity. Clarity of intent: Descriptive class and method names, logging, and documentation explain the purpose; however, the documentation names request formatters where the implementation creates ClientCredentialsJwtRetriever. Code length: The implementation is concise without substantial redundant logic, though the documentation is relatively verbose. Action granularity: Multiple imports, annotations, declarations, and statements share lines, making individual actions harder to scan. Reading flow: Inconsistent line breaks and formatting interrupt otherwise natural initialization and delegation flow. Standard formatting would substantially improve readability.

Run 3

Code Structure: The class logically separates configuration, retrieval, cleanup, and delegate access, but compressed declarations obscure these boundaries. Nesting: Shallow conditionals and a simple guard clause keep control flow easy to follow. Clarity of intent: Descriptive names and documentation explain delegation clearly, although the documentation refers to request formatters rather than the actual HTTP delegate instantiated. Code length: The implementation is concise without substantial redundancy; the documentation is relatively lengthy for the small class. Action granularity: Multiple imports, annotations, declarations, and statements share lines, making individual operations harder to scan. Reading flow: Inconsistent formatting, missing conditional braces, and method boundaries sharing lines interrupt otherwise straightforward execution flow. Overall, simple logic supports readability, but presentation significantly weakens it.