Sample

int-b7e1492f9055-I10

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

Matched original source

Lines100

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6630–1; higher is more readable
Dorn0.030–1; higher is more readable
Mi0.0010–1; higher is more readable
LLOC69Logical lines; fewer is more readable
DeepSeek V4 Pro5.330–20; mean of three runs
GPT-6.1 Sol110–20; mean of three runs
BTTF0.1550–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 { 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.5008.496−165.28
Source linesThe number of non-empty source lines.100+40
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.821−7.231

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

Score0.663

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.217.95−5.566
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.217.99+2.713
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.101−2.54
Indentation frequencyHow rapidly indentation changes from line to line.93+2.48
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.93−1.713
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.99.863+0.986
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.086+0.107

Intercept 0.07 + feature contributions = -3.464 (log-odds).
Score = sigmoid(-3.464) = 0.03.

Score0.001
Score69
Run 1

This code is difficult to read due to severe formatting issues. Multiple statements are packed onto single lines (e.g., package declaration with imports, field declarations like 'private final int bytes; private final boolean supportsClone;', and method bodies). This violates the one-action-per-line principle and creates visual clutter. The indentation is inconsistent, with some blocks properly indented but others flattened. Nesting is moderate in the newHasher() method with try-catch inside an if-else. While variable names are descriptive (prototype, supportsClone, toString), the dense formatting obscures the code's intent. The class structure is logical, but reading flow is severely disrupted by the compressed layout. The code would be much more readable with standard formatting, each statement on its own line, and consistent indentation.

Run 2

The code suffers from severe readability issues. Multiple statements are compressed onto single lines, violating the 'one action per line' principle. Import statements are not properly separated, and class structure is cramped with methods and fields intertwined without clear visual separation. Nesting depth is moderate but made worse by inline conditional logic. The intent of the class (adapting MessageDigest to HashFunction) is recognizable, but the implementation details are obscured by formatting choices. There are several long chains of statements that could be broken into logical blocks. The reading flow is disrupted by inconsistent line breaks and brace placement, forcing the reader to visually parse dense clusters rather than naturally scanning the code. While the overall architecture is logical, the formatting choices undermine clarity significantly.

Run 3

The code suffers from excessive line compression, with multiple statements crammed onto single lines, making it hard to follow. Imports are collapsed into one long line, fields are grouped together without spacing, and methods like `supportsClone` and `newHasher` have poor formatting. The structure itself is logical, but the visual presentation destroys readability. Nesting is moderate but made worse by the formatting. Intent is somewhat clear from class names and comments, but the dense style obscures it. Length is reasonable but not concise due to compression. Action granularity fails badly - multiple actions per line throughout. Reading flow is severely disrupted by the inconsistent spacing and line breaks. While the underlying code quality is decent, the formatting makes it unnecessarily difficult to read. A proper reformat would significantly improve the score.

Run 1

Code Structure: Responsibilities are logically separated into digest creation, hashing, and serialization, but compressed formatting obscures class and method boundaries. Nesting: Generally shallow; newHasher adds moderate nesting through an if and try/catch. Clarity of intent: Descriptive class and method names, validation calls, and comments make the adapter's purpose understandable, though the field named toString is less clear. Code length: Implementation is reasonably concise without substantial unnecessary code, but excessive line compression reduces readability. Action granularity: Multiple imports, declarations, assignments, and method boundaries frequently share lines, making individual operations harder to scan. Reading flow: The overall organization is sensible, but inconsistent indentation, inline annotations, and crowded braces interrupt natural top-to-bottom reading.

Run 2

Code Structure: Responsibilities are logically separated into the hash function, serialization proxy, and hasher, but compressed formatting obscures boundaries. Nesting: Mostly shallow, with manageable nested conditional and try/catch logic in newHasher. Clarity of intent: Descriptive class and method names, validation checks, and comments make the purpose clear; the bytes parameter shadowing a field adds minor ambiguity. Code length: Reasonably concise with little unnecessary code, though excessive compression sacrifices readability. Action granularity: Many lines combine imports, declarations, assignments, methods, or control-flow transitions, making individual actions harder to scan. Reading flow: Inconsistent line breaks, inline annotations, and closing braces followed immediately by new methods interrupt natural reading. Overall, sound organization and clear intent are substantially undermined by formatting.

Run 3

Code Structure: Constructors, helper methods, serialization support, and hashing behavior are logically separated, but compressed formatting obscures these boundaries. Nesting: Generally shallow; the nested if/try/catch in newHasher is manageable but difficult to scan. Clarity of intent: Descriptive class and method names, standard API usage, and comments make the purpose clear, although the field named toString is slightly confusing. Code length: Reasonably concise with little unnecessary logic; excessive line compression reduces readability rather than improving concision. Action granularity: Multiple imports, declarations, assignments, and method boundaries share lines, frequently violating one-action-per-line presentation. Reading flow: Inconsistent indentation, inline braces, and annotations attached to neighboring methods interrupt otherwise natural progression. Overall, the underlying design is readable, but poor formatting substantially increases reading effort.