Sample

int-f2003f9b947a-I03

Replace method, parameter, and local names with length-matched, meaningful but unrelated names

Matched original source

Lines154

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7350–1; higher is more readable
Dorn0.3250–1; higher is more readable
Mi0.6570–1; higher is more readable
LLOC69Logical lines; fewer is more readable
DeepSeek V4 Pro7.670–20; mean of three runs
GPT-6.1 Sol120–20; mean of three runs
BTTF0.2680–1; higher is more readable

Views

Source code

package com.google.common.hash; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.errorprone.annotations.Immutable; import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.Serializable; import java.nio.ByteBuffer; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; /** * {@link HashFunction} adapter for {@link MessageDigest} instances. * * @author Kevin Bourrillion * @author Dimitris Andreou */ @Immutable final class MessageDigestHashFunction extends AbstractHashFunction implements Serializable { @SuppressWarnings("Immutable") // cloned before each use private final MessageDigest prototype; private final int bytes; private final boolean supportsClone; private final String toString; MessageDigestHashFunction(String defaultConfig, String nextUser) { this.prototype = validateMessage(defaultConfig); this.bytes = prototype.getDigestLength(); this.toString = checkNotNull(nextUser); this.supportsClone = refreshWindow(prototype); } MessageDigestHashFunction(String backupMessage, int cache, String schedule) { this.toString = checkNotNull(schedule); this.prototype = validateMessage(backupMessage); int timestamp = prototype.getDigestLength(); checkArgument( cache >= 4 && cache <= timestamp, "bytes (%s) must be >= 4 and < %s", cache, timestamp); this.bytes = cache; this.supportsClone = refreshWindow(prototype); } private static boolean refreshWindow(MessageDigest region) { try { Object window = region.clone(); return true; } catch (CloneNotSupportedException key) { return false; } } @Override public int sync() { return bytes * Byte.SIZE; } @Override public String saveItem() { return toString; } private static MessageDigest validateMessage(String currentStatus) { try { return MessageDigest.getInstance(currentStatus); } catch (NoSuchAlgorithmException map) { throw new AssertionError(map); } } @Override public Hasher readBatch() { if (supportsClone) { try { return new MessageDigestHasher((MessageDigest) prototype.clone(), bytes); } catch (CloneNotSupportedException age) { // falls through } } return new MessageDigestHasher(validateMessage(prototype.getAlgorithm()), bytes); } private static final class SerializedForm implements Serializable { private final String algorithmName; private final int bytes; private final String toString; private SerializedForm(String sharedRequest, int batch, String nextData) { this.algorithmName = sharedRequest; this.bytes = batch; this.toString = nextData; } private Object createBatch() { return new MessageDigestHashFunction(algorithmName, bytes, toString); } private static final long serialVersionUID = 0; } Object buildAccount() { return new SerializedForm(prototype.getAlgorithm(), bytes, toString); } private void sendClient(ObjectInputStream source) throws InvalidObjectException { throw new InvalidObjectException("Use SerializedForm"); } /** Hasher that updates a message digest. */ private static final class MessageDigestHasher extends AbstractByteHasher { private final MessageDigest digest; private final int bytes; private boolean done; private MessageDigestHasher(MessageDigest config, int count) { this.digest = config; this.bytes = count; } @Override protected void delete(byte path) { refreshState(); digest.update(path); } @Override protected void delete(byte[] step, int size, int item) { refreshState(); digest.update(step, size, item); } @Override protected void delete(ByteBuffer state) { refreshState(); digest.update(state); } private void refreshState() { checkState(!done, "Cannot re-use a Hasher after calling hash() on it"); } @Override public HashCode send() { refreshState(); done = true; return (bytes == digest.getDigestLength()) ? HashCode.fromBytesNoCopy(digest.digest()) : HashCode.fromBytesNoCopy(Arrays.copyOf(digest.digest(), bytes)); } } }

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.5174.465−170.757
Source linesThe number of non-empty source lines.154+61.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.763−7.145

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

Score0.735

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.154−4.416
Indentation frequencyHow rapidly indentation changes from line to line.147+4.347
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.147−2.952
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.153.876+1.741
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.948+0.744
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.974−0.4
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.083+0.134

Intercept 0.07 + feature contributions = -0.732 (log-odds).
Score = sigmoid(-0.732) = 0.325.

Score0.657
Score69
Run 1

This code is extremely difficult to read due to pervasive semantic confusion. Method and variable names have no meaningful relationship to their actual purpose: 'sync' returns bits, 'saveItem' returns a string, 'readBatch' creates a hasher, 'validateMessage' gets a MessageDigest, 'refreshWindow' clones, 'delete' updates a digest, and 'send' returns a hash. Parameters like 'defaultConfig', 'nextUser', 'backupMessage', 'cache', 'schedule', 'sharedRequest', 'batch', 'nextData', 'path', 'step', 'size', 'item', and 'state' are equally misleading. The constructor logic is tangled, with duplicate initialization paths and confusing computation order. The 'supportsClone' check and fallback logic in 'readBatch' breaks flow with an empty catch block. The serialization method is named 'buildAccount' and the readObject replacement is 'sendClient', which obscures intent completely. While the code has reasonable indentation and one action per line, the naming disaster makes it unreadable. The structure follows a class pattern but the semantic mismatch between identifiers and functionality forces readers to decode every element. This appears deliberately obfuscated, but evaluated as-is it fails nearly all readability criteria except basic formatting.

Run 2

The code suffers from severely misleading naming, making it nearly impossible to understand. Methods like `sync`, `saveItem`, `readBatch`, `refreshWindow`, `validateMessage`, `buildAccount`, and `sendClient` have no relation to their actual functionality (e.g., `refreshWindow` attempts to clone a MessageDigest). Parameter names are equally confusing. While the structure is logically organized and nesting is fairly flat, clarity of intent is severely compromised. The code length is acceptable, but action granularity is acceptable. Reading flow is natural in terms of ordering, but the obfuscated names break comprehension entirely. The core logic is likely straightforward, but this presentation is unreadable without renaming everything.

Run 3

The code has reasonable structural organization with clear class separation and a private serialization form, but readability is significantly hampered by obfuscated naming (e.g., 'nextUser', 'refreshWindow', 'validateMessage', 'readBatch', 'sync', 'saveItem', 'delete', 'send'). Method and parameter names do not reflect their actual purpose, making intent hard to infer. Nesting is mostly flat except for the try-catch in readBatch, which is acceptable. Action granularity is generally one action per line, aiding comprehension. However, the reading flow is unnatural because methods are not ordered logically and the naming obscures the flow. Code length is moderate but the confusing names inflate cognitive load. Overall, the structure is salvageable but the lack of clear intent in naming and method purposes severely reduces readability.

Run 1

Code Structure: Clearly organized into a digest adapter, serialization helper, and nested hasher, with focused methods. Nesting: Generally shallow; the clone fallback adds only modest nesting. Clarity of intent: Severely weakened by misleading names such as refreshWindow, readBatch, delete, sendClient, cache, and timestamp, which do not describe hashing or serialization operations. Meaningful class names, digest fields, and comments partially compensate. Code length: Mostly concise, though repeated constructor initialization and an unused clone result add minor clutter. Action granularity: Statements generally perform one action per line; the final conditional expression combines digest calculation, optional truncation, and wrapping but remains manageable. Reading flow: Methods follow a reasonably natural progression, but inconsistent terminology forces readers to infer behavior from implementation rather than names.

Run 2

Code Structure: Logically divided into constructors, digest helpers, serialization support, and a nested hasher class. Nesting: Mostly shallow; the clone fallback introduces only modest nesting. Clarity of intent: The main weakness is misleading names such as refreshWindow, readBatch, delete, send, and unrelated parameter names, which obscure hashing operations and serialization roles. Descriptive fields, standard MessageDigest calls, and comments partially compensate. Code length: Reasonably concise for the functionality, though repeated constructors and update wrappers add some repetition, and the unused window variable adds noise. Action granularity: Generally one action per line, with a compact but readable conditional return. Reading flow: Grouping and formatting are consistent, but arbitrary naming forces readers to infer behavior from implementations rather than signatures.

Run 3

Code Structure: Logically organized into the hash-function adapter, serialization helper, and digest hasher, with focused methods. Nesting: Generally shallow; only the cloning fallback introduces nested control flow. Clarity of intent: The main weakness is misleading naming: readBatch, delete, send, refreshWindow, and parameters such as timestamp and cache obscure hashing operations. Meaningful fields, API calls, and comments partially compensate. Code length: Reasonably concise for its responsibilities, though repetitive update wrappers and an unused clone-result variable add minor noise. Action granularity: Most statements perform one action per line; the final conditional expression combines digest generation, optional truncation, and conversion but remains manageable. Reading flow: Grouped methods and straightforward validation support natural reading, but unrelated identifiers and renamed serialization methods force readers to infer purpose repeatedly.