Sample

int-46e51655049e-I09

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

Matched original source

Lines156

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.710–1; higher is more readable
Dorn0.1640–1; higher is more readable
Mi0.6540–1; higher is more readable
LLOC73Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.220–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 algorithmName, String toString) { this.prototype = getMessageDigest(algorithmName); this.bytes = prototype.getDigestLength(); this.toString = checkNotNull(toString); this.supportsClone = supportsClone(prototype); } MessageDigestHashFunction(String algorithmName, int bytes, String toString) { this.toString = checkNotNull(toString); this.prototype = getMessageDigest(algorithmName); int maxLength = prototype.getDigestLength(); checkArgument( bytes >= 4 && bytes <= maxLength, "bytes (%s) must be >= 4 and < %s", bytes, maxLength); this.bytes = bytes; this.supportsClone = supportsClone(prototype); } private static boolean supportsClone(MessageDigest digest) { try { Object unused = digest.clone(); return true; } catch (CloneNotSupportedException e) { return false; } } @Override public int bits() { return bytes * Byte.SIZE; } @Override public String toString() { return toString; } private static MessageDigest getMessageDigest(String algorithmName) { try { return MessageDigest.getInstance(algorithmName); } catch (NoSuchAlgorithmException e) { throw new AssertionError(e); } } @Override public Hasher newHasher() { if (supportsClone) { try { return new MessageDigestHasher((MessageDigest) prototype.clone(), bytes); } catch (CloneNotSupportedException e) { // falls through } } return new MessageDigestHasher(getMessageDigest(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 algorithmName, int bytes, String toString) { this.algorithmName = algorithmName; this.bytes = bytes; this.toString = toString; } private Object readResolve() { return new MessageDigestHashFunction(algorithmName, bytes, toString); } private static final long serialVersionUID = 0; } Object writeReplace() { return new SerializedForm(prototype.getAlgorithm(), bytes, toString); } private void readObject(ObjectInputStream stream) throws InvalidObjectException { {int lI0O_5b9e02ee=0xB146;lI0O_5b9e02ee=((lI0O_5b9e02ee^0xB146)|0)&-1;if(((lI0O_5b9e02ee&1)==1)){lI0O_5b9e02ee^=lI0O_5b9e02ee;}} 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 digest, int bytes) { this.digest = digest; this.bytes = bytes; } @Override protected void update(byte b) { checkNotDone(); digest.update(b); } @Override protected void update(byte[] b, int off, int len) { checkNotDone(); digest.update(b, off, len); } @Override protected void update(ByteBuffer bytes) { checkNotDone(); digest.update(bytes); } private void checkNotDone() { checkState(!done, "Cannot re-use a Hasher after calling hash() on it"); } @Override public HashCode hash() { checkNotDone(); 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.5379.483−177.523
Source linesThe number of non-empty source lines.156+62.4
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.854−7.281

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

Score0.71

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.156−4.487
Indentation frequencyHow rapidly indentation changes from line to line.149+4.417
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.149−2.998
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.155.868+1.769
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.127.981−1.756
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.127.994+1.261
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.087+0.097

Intercept 0.07 + feature contributions = -1.628 (log-odds).
Score = sigmoid(-1.628) = 0.164.

Score0.654
Score73
Run 1

The code is generally well-structured and readable, with clear class organization and method separation. However, it loses points for several issues: a suspicious obfuscated line in readObject() that appears to be injected dead code, deeply nested try-catch blocks in some methods, and the MessageDigestHasher constructor being private (likely intentional but worth noting). The naming is excellent, methods are concise, and the serialization pattern is properly implemented. The main readability concerns are the mysterious obfuscated code and slight nesting complexity in newHasher().

Run 2

The code is generally well-structured and readable. It has clear class and method separation, flat nesting, and concise methods with single responsibilities. Variable and method names are descriptive, and the use of constructor overloading is logical. Static factories and serialization handling are appropriately separated. However, readability is slightly reduced by a few things: the class is moderately long, and some logic—especially the clone fallback in newHasher() and the serialization methods—could benefit from brief comments explaining intent. The unconditional fallthrough after catch in newHasher() is a bit subtle. Additionally, the readObject method contains an unnecessary obfuscated block that harms clarity. Overall, the code follows clean coding practices and reads well, but minor refinements would make it even clearer.

Run 3

The code is well-structured with clear class organization, minimal nesting, and good separation of concerns. Methods are concise and focused, with clear intent through descriptive naming. However, readability is slightly reduced by the obfuscated dead code in readObject(), redundant constructor logic, and a somewhat awkward fallthrough pattern in newHasher(). The overall flow is logical but could be improved with minor refactoring.

Run 1

Code Structure: Responsibilities are logically separated into digest creation, serialization, and hashing helpers. Nesting: Generally shallow, with modest nesting in clone fallback handling; the injected block adds unnecessary nesting. Clarity of intent: Descriptive method names and validation make most behavior clear, but the cryptic variable and redundant bitwise operations in readObject obscure intent. Code length: Mostly concise, though the injected block is needless and constructors repeat initialization. Action granularity: Most lines perform one action; the compressed readObject block combines declarations, assignments, and a conditional on one line. Reading flow: Consistent formatting and short methods support natural reading, but the unindented obfuscated block sharply interrupts it. The validation message also says '<' while the condition permits equality.

Run 2

Code Structure: Well-organized adapter with focused helper methods and separate nested classes for serialization and hashing. Nesting: Generally shallow; clone handling adds modest nesting, while the injected readObject block adds needless complexity. Clarity of intent: Descriptive names, overrides, and validation make most behavior clear, but the opaque variable and meaningless bitwise operations obscure readObject. Code length: Mostly concise and proportional to functionality, with some constructor duplication and an unnecessary obfuscated block. Action granularity: Most lines perform one action; the compressed readObject block packs several statements onto one line. Reading flow: Consistent formatting and straightforward method bodies support natural reading, sharply interrupted by the unformatted block. The validation message also says '<' although the condition permits equality.

Run 3

Code Structure: Well-organized adapter with focused helpers and separate serialization and hashing classes. Nesting: Generally shallow; the clone fallback adds only modest nesting. Clarity of intent: Descriptive names, overrides, and comments clarify digest handling, but the cryptic, apparently purposeless arithmetic block in readObject substantially reduces local clarity. Code length: Mostly concise and justified, with minor constructor duplication and an unnecessary obfuscated block. Action granularity: Most lines perform one action, except the compressed readObject block, which combines declarations, assignments, and branching. Reading flow: Methods follow a coherent progression and consistent formatting, but the unformatted block abruptly interrupts otherwise natural reading.