Sample

int-0d7d911e2022-I04

Replace method, parameter, and local names with deterministic ProGuard-style short identifiers

Matched original source

Lines103

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6050–1; higher is more readable
Dorn0.7920–1; higher is more readable
Mi0.0270–1; higher is more readable
LLOC39Logical lines; fewer is more readable
DeepSeek V4 Pro7.330–20; mean of three runs
GPT-6.1 Sol120–20; mean of three runs
BTTF0.2830–1; higher is more readable

Views

Source code

package kafka.server.share; import kafka.cluster.Partition; import kafka.server.ReplicaManager; import org.apache.kafka.common.IsolationLevel; import org.apache.kafka.common.TopicIdPartition; import org.apache.kafka.common.errors.NotLeaderOrFollowerException; import org.apache.kafka.common.errors.OffsetNotAvailableException; import org.apache.kafka.common.record.internal.FileRecords; import org.apache.kafka.common.requests.ListOffsetsRequest; import org.apache.kafka.server.partition.PartitionListener; import org.apache.kafka.server.share.PartitionMetadataProvider; import org.apache.kafka.server.storage.log.FetchIsolation; import org.apache.kafka.storage.internals.log.LogOffsetMetadata; import org.apache.kafka.storage.internals.log.LogOffsetSnapshot; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Optional; import scala.Some; /** * Implementation of {@link PartitionMetadataProvider} backed by {@link ReplicaManager}. */ public class ReplicaManagerPartitionMetadataProvider implements PartitionMetadataProvider { private static final Logger log = LoggerFactory.getLogger(ReplicaManagerPartitionMetadataProvider.class); private final ReplicaManager replicaManager; public ReplicaManagerPartitionMetadataProvider(ReplicaManager a) { this.replicaManager = a; } @Override public long a(TopicIdPartition b, int c) { // Isolation level is only required when reading from the latest offset hence use Option.empty() for now. Optional<FileRecords.TimestampAndOffset> d = replicaManager.fetchOffsetForTimestamp( b.topicPartition(), ListOffsetsRequest.EARLIEST_TIMESTAMP, scala.Option.empty(), Optional.of(c), true).timestampAndOffsetOpt(); if (d.isEmpty()) { throw new OffsetNotAvailableException("Offset for earliest timestamp not found for topic partition: " + b); } return d.get().offset; } @Override public long b(TopicIdPartition e, int f) { // Isolation level is set to READ_UNCOMMITTED, matching with that used in share fetch requests. Optional<FileRecords.TimestampAndOffset> g = replicaManager.fetchOffsetForTimestamp( e.topicPartition(), ListOffsetsRequest.LATEST_TIMESTAMP, new Some<>(IsolationLevel.READ_UNCOMMITTED), Optional.of(f), true).timestampAndOffsetOpt(); if (g.isEmpty()) { throw new OffsetNotAvailableException("Offset for latest timestamp not found for topic partition: " + e); } return g.get().offset; } @Override public long c(TopicIdPartition h, long i, int j) { Optional<FileRecords.TimestampAndOffset> k = replicaManager.fetchOffsetForTimestamp( h.topicPartition(), i, new Some<>(IsolationLevel.READ_UNCOMMITTED), Optional.of(j), true).timestampAndOffsetOpt(); if (k.isEmpty()) { throw new OffsetNotAvailableException("Offset for timestamp " + i + " not found for topic partition: " + h); } return k.get().offset; } @Override public LogOffsetMetadata d(TopicIdPartition l, FetchIsolation m) { Partition n = h(l); LogOffsetSnapshot o = n.fetchOffsetSnapshot(Optional.empty(), true); if (m == FetchIsolation.LOG_END) return o.logEndOffset(); else if (m == FetchIsolation.HIGH_WATERMARK) return o.highWatermark(); else return o.lastStableOffset(); } @Override public int e(TopicIdPartition p) { return h(p).getLeaderEpoch(); } @Override public boolean f(TopicIdPartition q, PartitionListener r) { return replicaManager.maybeAddListener(q.topicPartition(), r); } @Override public void g(TopicIdPartition s, PartitionListener t) { replicaManager.removeListener(s.topicPartition(), t); } private Partition h(TopicIdPartition u) { Partition v = replicaManager.getPartitionOrException(u.topicPartition()); if (!v.isLeader()) { log.debug("The broker is not the leader for topic partition: {}", u.topicPartition()); throw new NotLeaderOrFollowerException(); } return v; } }

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.4895.754−161.56
Source linesThe number of non-empty source lines.103+41.2
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.787−7.181

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

Score0.605

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.99+2.687
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.104−2.646
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.981−1.417
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.119.885+1.13
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.102.785+1.027
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.088+0.085

Intercept 0.07 + feature contributions = 1.334 (log-odds).
Score = sigmoid(1.334) = 0.792.

Score0.027
Score39
Run 1

The code has a logical structure and concise methods, but readability is severely hampered by obfuscated naming. Parameters and methods use meaningless single-letter identifiers (a, b, c, d...) instead of descriptive names, making the purpose of each method ambiguous despite comments. The logic is relatively simple and nesting is minimal, but the naming forces readers to mentally map variables without context. Action granularity is appropriate—one core operation per line—and control flow is straightforward. However, the disorganized naming pattern disrupts natural reading flow and reduces clarity of intent. The class would be highly readable if meaningful identifiers (e.g., partitionId, fetchEarliestOffset) replaced the terse placeholders. Current state is maintainable only with effort and documentation, hence a middling score.

Run 2

The code is severely hampered by obfuscated variable and method names (e.g., 'ReplicaManager a', 'TopicIdPartition b', methods 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'), which obscures the intent of every method and parameter. While the logical structure is flat and each line performs a single action, the lack of meaningful identifiers destroys readability. The comments offer some context for the offset-fetching methods, but the private helper method 'h' is especially confusing because its name collides with a parameter in method 'd' and its role is only inferable from context. Naming conventions are a foundational element of readable code, and their absence here overrides the positive aspects of simple nesting and concise length. Overall, the code is functionally structured but practically unreadable without renaming and documentation of each method's responsibility.

Run 3

The code uses extremely poor, single-letter variable names (a, b, c, d, etc.) for parameters, variables, and methods which severely impacts clarity and intent. While the structure is logical and nesting is minimal, the naming makes it impossible to understand purpose without deeply analyzing the code. The methods themselves have reasonable length and one action per line, but repetitive logic could be consolidated. The code preserves logical organization and flat nesting, but the cryptic identifiers undermine maintainability. Method names like a(), b(), c() provide zero semantic value. Comments help slightly but insufficient.

Run 1

Code Structure: Clearly organized into short methods with a shared partition-validation helper, though timestamp lookup logic is repeated. Nesting: Shallow conditionals and early exceptions keep complexity low; omitted braces in one conditional chain slightly reduce consistency. Clarity of intent: The descriptive class name, API calls, comments, and exception messages help, but single-letter method and variable names severely obscure responsibilities and parameter meanings. Code length: Generally concise, with modest duplication across offset-fetching methods. Action granularity: Most statements perform one action, although chained calls and multi-argument API invocations require extra parsing. Reading flow: Constructor, public methods, and private helper follow a conventional order, but cryptic names force readers to infer meaning repeatedly. Overall, the code is structurally readable but substantially weakened by naming.

Run 2

Code Structure: The class is logically organized into small interface implementations and a shared partition-validation helper. Nesting: Shallow conditionals and early exceptions keep control flow simple. Clarity of intent: Single-letter method and parameter names severely obscure purpose, requiring readers to infer behavior from API calls, constants, comments, and exception messages. Code length: Methods are concise, although three offset-fetching methods repeat similar lookup and validation logic. Action granularity: Most statements perform one clear action; chained calls and inline arguments add modest cognitive load. Reading flow: Consistent formatting and straightforward delegation support natural reading, but opaque names, tightly packed imports, and unbraced conditional branches reduce scanability. Overall, the implementation is structurally readable but substantially weakened by poor naming.

Run 3

Code Structure: Logically organized into small methods, with partition validation centralized in a helper. Nesting: Shallow conditionals and early exceptions keep control flow simple. Clarity of intent: The descriptive class name, API calls, constants, and comments provide context, but single-letter method and variable names severely obscure responsibilities and parameter meanings. Code length: Generally concise, although three timestamp lookup methods repeat similar fetching and error-handling logic. Action granularity: Most statements perform one action; chained calls are manageable, though positional boolean arguments obscure behavior. Reading flow: Formatting and straightforward method bodies support local reading, but meaningless names make navigation between methods difficult, and the brace-free conditional chain slightly weakens visual consistency. Overall, the implementation is structurally readable but substantially undermined by poor naming.