Sample

int-ff352f8d6e07-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines71

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7970–1; higher is more readable
Dorn0.5620–1; higher is more readable
Mi0.5480–1; higher is more readable
LLOC31Logical lines; fewer is more readable
DeepSeek V4 Pro13.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.6090–1; higher is more readable

Views

Source code

package io.netty.handler.codec.quic; import io.netty.util.concurrent.FastThreadLocal; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.nio.ByteBuffer; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Arrays; final class Hmac { private static final String ALGORITHM = "HmacSHA256"; // Two independent keys so that CID signing and reset-token signing are // cryptographically decoupled: an observer cannot derive one output from // the other even when both use the same input value (RFC 9000 §21.11). private static final byte[] CID_KEY = new byte[32]; private static final byte[] TOKEN_KEY = new byte[32]; static { SecureRandom rng = new SecureRandom(); rng.nextBytes(CID_KEY); rng.nextBytes(TOKEN_KEY); } private static final FastThreadLocal<Mac> CID_MACS = new FastThreadLocal<Mac>() { @Override protected Mac initialValue() { return newMac(CID_KEY); } }; private static final FastThreadLocal<Mac> TOKEN_MACS = new FastThreadLocal<Mac>() { @Override protected Mac initialValue() { return newMac(TOKEN_KEY); } }; private static Mac newMac(byte[] key) { try { SecretKeySpec keySpec = new SecretKeySpec(key, ALGORITHM); Mac mac = Mac.getInstance(ALGORITHM); mac.init(keySpec); return mac; } catch (NoSuchAlgorithmException | InvalidKeyException exception) { throw new IllegalStateException(exception); } } private static ByteBuffer sign(Mac mac, ByteBuffer input, int outLength) { mac.reset(); mac.update(input); byte[] signBytes = mac.doFinal(); if (!((signBytes.length != outLength))) {} else { signBytes = Arrays.copyOf(signBytes, outLength); } return ByteBuffer.wrap(signBytes); } static ByteBuffer signCid(ByteBuffer input, int outLength) { return sign(CID_MACS.get(), input, outLength); } static ByteBuffer signToken(ByteBuffer input, int outLength) { return sign(TOKEN_MACS.get(), input, outLength); } private Hmac() { } }

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.2583.358−85.251
Source linesThe number of non-empty source lines.71+28.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.863−7.294

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

Score0.797

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.68+1.615
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.72−1.513
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.68−1.14
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.972+0.599
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.70.886+0.581
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.091+0.054
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.86.958−0.018

Intercept 0.07 + feature contributions = 0.249 (log-odds).
Score = sigmoid(0.249) = 0.562.

Score0.548
Score31
Run 1

The code demonstrates good structure with clear separation of concerns: constants, static initialization, thread-local setup, and public API. Nesting is minimal, and each method has a single responsibility. The comments explaining the dual-key design are helpful. However, readability is undermined by confusing conditional logic in the sign() method: `if (!((signBytes.length != outLength))) {} else { ... }` is unnecessarily convoluted - a simple `if (signBytes.length == outLength)` would be clearer. The empty if-block and double negation force readers to mentally parse logic that should be straightforward. Additionally, the empty constructor with comment adds little value, and the code length could be slightly reduced by consolidating the thread-local initialization patterns. The action granularity is generally good, with one operation per line, but the conditional structure breaks the natural reading flow.

Run 2

The code has a clear overall structure with separated sections for constants, static initialization, thread-local setups, and signing methods. However, readability is undermined by several issues: the conditional in the sign() method, 'if (!((signBytes.length != outLength))) {} else {...}', is convoluted and hard to understand. The static initializer creates implicit coupling between the keys and the Mac thread-locals, but this is not visually obvious. The code lacks whitespace between method definitions, and although comments explain the reason for two keys, the actual code flow in sign() is unnatural. Variable names are mostly clear, but the action granularity suffers because the sign() method performs reset, update, finalize, conditional copy, and wrap into ByteBuffer in a single method. The unusual empty if-block pattern significantly hurts the reading flow, which otherwise would be relatively flat and concise. Overall, the code is functional but has readability problems that would confuse maintainers.

Run 3

The code is generally readable with clear separation of concerns: constants, static initialization, thread-local setup, and signing methods are logically organized. Naming is descriptive and comments explain the cryptographic rationale. However, several issues reduce clarity. The conditional `if (!((signBytes.length != outLength))) {} else { signBytes = Arrays.copyOf(signBytes, outLength); }` is unnecessarily convoluted—a simple `if (signBytes.length != outLength)` would be clearer. The empty if-block with a double negative obscures intent. The `newMac` method has good error handling, but the static initialization of cryptographic keys using `SecureRandom` could benefit from a comment about thread-safety or lifecycle. The anonymous `FastThreadLocal` subclasses add minor nesting noise. Overall, the code is functional and maintainable but has awkward spots that detract from smooth reading flow and clarity of intent.

Run 1

Code Structure: Well organized into key initialization, thread-local MAC instances, a factory, and signing helpers. Nesting: Shallow overall, with straightforward initialization and exception handling. Clarity of intent: Descriptive names and the key-separation comment explain the design, but the double-negated length comparison and empty if branch obscure a simple resizing condition. Code length: Mostly concise; duplicated thread-local setup is modest, while the empty branch is unnecessary. Action granularity: Generally one action per line, though the compressed if/else combines control-flow elements awkwardly. Reading flow: Natural progression from configuration to implementation and public-facing helpers, interrupted mainly by the convoluted conditional in sign.

Run 2

Code Structure: Well organized into key initialization, thread-local MAC instances, a factory, and signing helpers. Nesting: Shallow overall, with straightforward exception handling; the empty if/else is awkward. Clarity of intent: Descriptive names and the key-separation comment explain the purpose well, but the double-negated length comparison obscures a simple condition. Code length: Mostly concise, with reasonable duplication for the two independent MAC instances. Action granularity: Generally one action per line, although the inline empty branch reduces readability. Reading flow: Natural progression from configuration to implementation to entry points, interrupted mainly by `if (!((signBytes.length != outLength))) {} else`, which should be a direct inequality check.

Run 3

Code Structure: Logically organized constants, key initialization, thread-local instances, and focused helper methods. Nesting: Shallow overall, with straightforward exception handling; the empty if branch and else unnecessarily complicate a simple condition. Clarity of intent: Descriptive names and a useful security comment clearly explain separate signing purposes, but the double-negated length comparison obscures intent. Code length: Concise overall, with reasonable duplication for the two independent MAC instances. Action granularity: Most lines contain one action; the inline empty branch is an awkward exception. Reading flow: Initialization naturally leads into MAC creation and signing methods, though the unusual conditional interrupts an otherwise smooth flow. Replacing it with 'if (signBytes.length != outLength)' would improve readability.