Sample

int-c29b66ae842a-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines133

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.4210–1; higher is more readable
Dorn0.0820–1; higher is more readable
Mi0.3560–1; higher is more readable
LLOC84Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.3920–1; higher is more readable

Views

Source code

package io.netty.handler.codec.quic; import io.netty.util.internal.ObjectUtil; import java.nio.ByteBuffer; import java.nio.ByteOrder; final class SipHash { static final int SEED_LENGTH = 16; private final int compressionRounds; private final int finalizationRounds; private static final long INITIAL_STATE_V0 = 0x736f6d6570736575L; private static final long INITIAL_STATE_V1 = 0x646f72616e646f6dL; private static final long INITIAL_STATE_V2 = 0x6c7967656e657261L; private static final long INITIAL_STATE_V3 = 0x7465646279746573L; private final long initialStateV0; private final long initialStateV1; private final long initialStateV2; private final long initialStateV3; private long v0; private long v1; private long v2; private long v3; SipHash(int compressionRounds, int finalizationRounds, byte[] seed) { if (seed.length != SEED_LENGTH) { throw new IllegalArgumentException("seed must be of length " + SEED_LENGTH); } this.compressionRounds = ObjectUtil.checkPositive(compressionRounds, "compressionRounds"); this.finalizationRounds = ObjectUtil.checkPositive(finalizationRounds, "finalizationRounds"); ByteBuffer keyBuffer = ByteBuffer.wrap(seed).order(ByteOrder.LITTLE_ENDIAN); final long k0 = keyBuffer.getLong(); final long k1 = keyBuffer.getLong(); initialStateV0 = INITIAL_STATE_V0 ^ k0; initialStateV1 = INITIAL_STATE_V1 ^ k1; initialStateV2 = INITIAL_STATE_V2 ^ k0; initialStateV3 = INITIAL_STATE_V3 ^ k1; } long macHash(ByteBuffer input) { v0 = initialStateV0; v1 = initialStateV1; v2 = initialStateV2; v3 = initialStateV3; int remaining = input.remaining(); int position = input.position(); int len = remaining - (remaining % Long.BYTES); boolean needsReverse = input.order() == ByteOrder.BIG_ENDIAN; for (int offset = position; offset < len; offset += Long.BYTES) { long m = input.getLong(offset); if (needsReverse) { m = Long.reverseBytes(m); } v3 ^= m; for (int i = 0; i < compressionRounds; i++) { sipround(); } v0 ^= m; } final int left = remaining & (Long.BYTES - 1); long b = (long) remaining << 56; assert left < Long.BYTES; switch (left) { case 7: b |= (long) input.get(position + len + 6) << 48; case 6: b |= (long) input.get(position + len + 5) << 40; case 5: b |= (long) input.get(position + len + 4) << 32; case 4: b |= (long) input.get(position + len + 3) << 24; case 3: b |= (long) input.get(position + len + 2) << 16; case 2: b |= (long) input.get(position + len + 1) << 8; case 1: b |= input.get(position + len); break; case 0: break; default: throw new IllegalStateException("Unexpected value: " + left); } v3 ^= b; for (int i = 0; i < compressionRounds; i++) { sipround(); } v0 ^= b; v2 ^= 0xFF; for (int i = 0; i < finalizationRounds; i++) { sipround(); } return v0 ^ v1 ^ v2 ^ v3; } private void sipround() { v0 += v1; v2 += v3; v1 = Long.rotateLeft(v1, 13); v3 = Long.rotateLeft(v3, 16); v1 ^= v0; v3 ^= v2; v0 = Long.rotateLeft(v0, 32); v2 += v1; v0 += v3; v1 = Long.rotateLeft(v1, 17); v3 = Long.rotateLeft(v3, 21); v1 ^= v2; v3 ^= v0; v2 = Long.rotateLeft(v2, 32); } }

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.5373.21−177.316
Source linesThe number of non-empty source lines.133+53.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.541−6.811

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

Score0.421

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.133+3.863
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.134−3.708
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.133−2.631
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.132.892+1.448
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
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.100.978−0.612
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.101−0.043

Intercept 0.07 + feature contributions = -2.417 (log-odds).
Score = sigmoid(-2.417) = 0.082.

Score0.356
Score84
Run 1

The code demonstrates solid algorithmic structure with clear separation of initialization, processing, and finalization phases. Constants and field names are descriptive, and helper methods like `sipround()` encapsulate complex operations well. However, readability is hampered by several factors: the switch-case fallthrough for tail bytes is non-obvious and requires deep understanding of the algorithm; multiple fields (`v0-v3`) lack explanatory context; the use of raw bit operations throughout makes intent harder to grasp. The code is well-organized but assumes significant domain knowledge, making it less approachable for general developers.

Run 2

The code is well-structured and generally readable. It uses clear field names, meaningful constants, and separates concerns across methods. The macHash method is logically organized into processing chunks, handling the remaining bytes, and finalization, with light, justifiable nesting. However, readability is reduced by the absence of comments explaining the SipHash algorithm's phases, especially around the switch fall-through logic for tail bytes. The switch statement's deliberate fall-through is a potential source of confusion and could benefit from explicit documentation. Additionally, the macHash method is somewhat long and performs multiple responsibilities—could be split into helper methods for chunk processing and final block construction. The inline comments and alignment of constants improve readability, but the loop with `offset += Long.BYTES` and manual endian handling adds minor clutter. Overall, it is clean and maintainable but would benefit from more comments and method decomposition.

Run 3

The code is highly readable. It follows a clear logical structure with well-defined constants, fields, and methods. Nesting is minimal, with only two nested loops in the main hashing function and a flat switch statement. Intent is clearly expressed through descriptive variable names and constants. The code is concise, avoiding unnecessary boilerplate while maintaining clarity. Action granularity is appropriate, with one main operation per line. The reading flow is natural, with the compression and finalization rounds clearly separated. Minor readability improvements could include extracting the tail-processing switch into a helper method, but overall the code is well-organized and understandable.

Run 1

Code Structure: Logical separation into initialization, hashing, and a round helper, although macHash combines several processing stages. Nesting: Shallow overall, with straightforward loops and conditionals. Clarity of intent: Descriptive round counts and constants help, but terse state names, unexplained bit operations, and undocumented switch fall-through require SipHash knowledge. Code length: Reasonably concise for the algorithm; repeated round loops and excessive blank lines add minor clutter. Action granularity: Statements generally perform one action per line, making state updates easy to track. Reading flow: Processing proceeds naturally from initialization through block handling, trailing bytes, and finalization, but missing explanatory comments and ambiguous position-versus-length indexing interrupt comprehension.

Run 2

Code Structure: Constants, initialization, hashing, and the round operation are logically separated, though macHash combines several processing phases. Nesting: Shallow loops and conditionals keep control flow manageable; the fall-through switch requires extra attention. Clarity of intent: SipHash and round-count names convey purpose, but abbreviated state variables, unexplained bit operations, magic rotation values, and undocumented switch fall-through make details harder to follow. Code length: Generally concise for a cryptographic implementation, with some repetitive state assignments and excessive blank lines. Action granularity: Statements consistently perform one action per line, making state changes easy to trace. Reading flow: Initialization, block processing, remainder handling, and finalization follow a natural sequence, but missing explanatory comments and the ambiguous relationship between position, len, and offset interrupt comprehension.

Run 3

Code Structure: Initialization, hashing, and round operations are logically separated, although macHash combines several processing phases. Nesting: Mostly shallow, with only a nested compression loop and conditional. Clarity of intent: Descriptive configuration names and constants help, but cryptographic state names, unexplained bit operations, and undocumented switch fall-through require algorithm knowledge. The offset-versus-length loop bound also makes buffer traversal harder to interpret. Code length: Reasonably concise for the algorithm, though repeated round loops and excessive blank lines introduce clutter. Action granularity: Each statement generally performs one operation, making state transformations easy to follow individually. Reading flow: Initialization, block processing, tail handling, and finalization form a natural sequence, but missing phase comments and subtle byte-packing behavior interrupt comprehension.