Sample

int-a578a7274134-I08

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

Matched original source

Lines82

Scores

MethodScoreScale
Posnett0.0460–1; higher is more readable
Scalabrino0.8530–1; higher is more readable
Dorn0.7660–1; higher is more readable
Mi0.3820–1; higher is more readable
LLOC15Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol190–20; mean of three runs
BTTF0.6870–1; higher is more readable

Views

Source code

package com.google.common.io; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.DataInput; import java.io.IOException; import org.jspecify.annotations.Nullable; /** * An extension of {@code DataInput} for reading from in-memory byte arrays; its methods offer * identical functionality but do not throw {@link IOException}. * * <p><b>Warning:</b> The caller is responsible for not attempting to read past the end of the * array. If any method encounters the end of the array prematurely, it throws {@link * IllegalStateException} to signify <i>programmer error</i>. This behavior is a technical violation * of the supertype's contract, which specifies a checked exception. * * @author Kevin Bourrillion * @since 1.0 */ @J2ktIncompatible @GwtIncompatible public interface ByteArrayDataInput extends DataInput { @Override void readFully(byte[] b); @Override void readFully(byte[] b, int off, int len); // not guaranteed to skip n bytes so result should NOT be ignored // use ByteStreams.skipFully or one of the read methods instead @Override int skipBytes(int n); @CanIgnoreReturnValue // to skip a byte @Override boolean readBoolean(); @CanIgnoreReturnValue // to skip a byte @Override byte readByte(); @CanIgnoreReturnValue // to skip a byte @Override int readUnsignedByte(); @CanIgnoreReturnValue // to skip some bytes @Override short readShort(); @CanIgnoreReturnValue // to skip some bytes @Override int readUnsignedShort(); @CanIgnoreReturnValue // to skip some bytes @Override char readChar(); @CanIgnoreReturnValue // to skip some bytes @Override int readInt(); @CanIgnoreReturnValue // to skip some bytes @Override long readLong(); @CanIgnoreReturnValue // to skip some bytes @Override float readFloat(); @CanIgnoreReturnValue // to skip some bytes @Override double readDouble(); @CanIgnoreReturnValue // to skip a line @Override @Nullable String readLine(); @CanIgnoreReturnValue // to skip a field @Override String readUTF(); }

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.1135.35−37.467
Source linesThe number of non-empty source lines.82+32.8
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.828−7.241

Intercept 8.87 + feature contributions = -3.038 (log-odds).
Score = sigmoid(-3.038) = 0.046.

Score0.853

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.83−1.902
Indentation frequencyHow rapidly indentation changes from line to line.57+1.234
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.98.699+0.788
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.81.832+0.734
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.99.88−0.565
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.431
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 1.188 (log-odds).
Score = sigmoid(1.188) = 0.766.

Score0.382
Score15
Run 1

The code is highly readable due to its logical structure and clear intent. The interface declaration is straightforward, with a concise yet informative Javadoc explaining the behavior and contract deviations. Method declarations are flat, with no nesting, and each method is presented on a single line, making the structure easy to scan. The use of @Override and @CanIgnoreReturnValue annotations is consistent, and the brief comments for each method clarify the intended use when return values are ignored. Imports are organized and limited. The code avoids unnecessary length, with only essential methods and documentation. Reading flow is natural, grouping related read methods logically. Overall, this is an exemplary implementation of a well-documented, minimal interface.

Run 2

The code is highly readable. It has a clear purpose as an interface extending DataInput, with a concise Javadoc explaining the contract and significant behavioral difference (no IOException, but IllegalStateException on overrun). Structure is logical: imports, documentation, interface declaration, then method signatures. There is no deep nesting. Each overridden method occupies one line, maintaining action granularity. The annotations with inline comments like '// to skip a byte' clarify intent and usage context. Code length is appropriate—only necessary elements are present. Reading flow is natural and follows a consistent grouping of related methods. Minor deductions: the warning about skipBytes could be slightly more formal, and some comments are repetitive, but overall clarity and organization are excellent.

Run 3

The code is highly readable as an interface definition. It follows a logical structure: package, imports, Javadoc, annotations, then method declarations. The Javadoc clearly explains the class's purpose and the important behavioral difference regarding IOException vs IllegalStateException. Nesting is non-existent, as expected for an interface. Each method is declared on a single line, contributing to concise code and flat structure. Repeated @CanIgnoreReturnValue annotations with comments provide consistent, clear intent for each method's return value usage. The reading flow is natural: methods are grouped by type (readFully, skip, primitives, String). Minor deductions: the @Nullable placement on the same line as readLine slightly disrupts readability, and the sheer number of repetitive annotations could be considered slightly verbose, though each adds specific documentation value. Overall, the code is straightforward, self-documenting, and maintains a clean, natural flow, characteristic of a well-designed API interface.

Run 1

Code Structure: Cleanly organized interface with related method declarations and consistent annotation placement. Nesting: Flat, with no nested control flow. Clarity of intent: Descriptive method names and detailed interface documentation clearly explain the purpose and exception behavior; comments clarify skipping semantics. Code length: Appropriate for redeclaring the DataInput contract without checked exceptions, though repeated annotations and comments add minor visual repetition. Action granularity: Each method declaration occupies its own line, with annotations generally separated; there are no compound operations. Reading flow: Methods follow a natural progression from bulk reads and skipping to primitive and string reads. Minor formatting issues, such as no blank line after the package declaration and placing @Nullable beside the return type, slightly reduce visual consistency.

Run 2

Code Structure: A well-organized interface groups related input methods with consistent formatting. Nesting: Completely flat aside from the interface scope. Clarity of intent: The documentation clearly explains the purpose, exception behavior, and caller responsibilities; annotations and comments clarify return-value handling. Code length: Concise for the API it declares, though repeated annotations and comments add minor visual repetition. Action granularity: Each method declaration occupies its own line, with no combined operations. Reading flow: Predictable ordering and spacing make scanning easy. Minor readability drawbacks include terse parameter names such as b, off, and len, and the lack of separation between the package declaration and imports.

Run 3

Code Structure: Well-organized interface with imports, class documentation, and consistently grouped method declarations. Nesting: Flat, with no nested control flow. Clarity of intent: The documentation clearly explains the interface's purpose and exception behavior; standard DataInput method names and annotations reinforce meaning. Code length: Appropriately concise for redeclaring inherited methods without checked exceptions, though repeated annotation comments add slight visual noise. Action granularity: Each declaration occupies its own line, with annotations clearly associated with individual methods. Reading flow: Natural and consistent, progressing from bulk reads and skipping to primitive and string reads. Minor drawbacks include abbreviated parameter names and the lack of spacing between the package declaration and imports.