Sample

int-766628c169e4-I09

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

Matched original source

Lines111

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5410–1; higher is more readable
Dorn0.2810–1; higher is more readable
Mi0.570–1; higher is more readable
LLOC38Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol15.330–20; mean of three runs
BTTF0.230–1; higher is more readable

Views

Source code

package org.springframework.web.socket.sockjs.transport.handler; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.regex.Pattern; import org.jspecify.annotations.Nullable; import org.springframework.http.MediaType; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.sockjs.SockJsException; import org.springframework.web.socket.sockjs.frame.SockJsFrame; import org.springframework.web.socket.sockjs.frame.SockJsFrameFormat; import org.springframework.web.socket.sockjs.transport.SockJsSession; import org.springframework.web.socket.sockjs.transport.SockJsSessionFactory; import org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession; import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriUtils; /** * Base class for HTTP transport handlers that push messages to connected clients. * * @author Rossen Stoyanchev * @since 4.0 */ public abstract class AbstractHttpSendingTransportHandler extends AbstractTransportHandler implements SockJsSessionFactory { /** * Pattern for validating callback parameter values. */ private static final Pattern CALLBACK_PARAM_PATTERN = Pattern.compile("[0-9A-Za-z_.]*"); @Override public final void handleRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, SockJsSession wsSession) throws SockJsException { AbstractHttpSockJsSession sockJsSession = (AbstractHttpSockJsSession) wsSession; // https://github.com/sockjs/sockjs-client/issues/130 // sockJsSession.setAcceptedProtocol(protocol); // Set content type before writing response.getHeaders().setContentType(getContentType()); handleRequestInternal(request, response, sockJsSession); } protected void handleRequestInternal(ServerHttpRequest request, ServerHttpResponse response, AbstractHttpSockJsSession sockJsSession) throws SockJsException { if (sockJsSession.isNew()) { if (logger.isDebugEnabled()) { logger.debug(request.getMethod() + " " + request.getURI()); } sockJsSession.handleInitialRequest(request, response, getFrameFormat(request)); } else if (sockJsSession.isClosed()) { if (logger.isDebugEnabled()) { logger.debug("Connection already closed (but not removed yet) for " + sockJsSession); } writeFrame(SockJsFrame.closeFrameGoAway(), request, response, sockJsSession); } else if (!sockJsSession.isActive()) { if (logger.isTraceEnabled()) { logger.trace("Starting " + getTransportType() + " async request."); } sockJsSession.handleSuccessiveRequest(request, response, getFrameFormat(request)); } else { if (logger.isDebugEnabled()) { logger.debug("Another " + getTransportType() + " connection still open for " + sockJsSession); } writeFrame(SockJsFrame.closeFrameAnotherConnectionOpen(), request, response, sockJsSession); } } private void writeFrame(SockJsFrame frame, ServerHttpRequest request, ServerHttpResponse response, AbstractHttpSockJsSession sockJsSession) { String formattedFrame = getFrameFormat(request).format(frame); try { response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET)); } catch (IOException ex) { throw new SockJsException("Failed to send " + formattedFrame, sockJsSession.getId(), ex); } } protected abstract MediaType getContentType(); protected abstract SockJsFrameFormat getFrameFormat(ServerHttpRequest request); protected final @Nullable String getCallbackParam(ServerHttpRequest request) { {boolean lI0O_0b0a6999=((0x51DD^0x51DD)!=0);lI0O_0b0a6999=!(!lI0O_0b0a6999);} String query = request.getURI().getQuery(); MultiValueMap<String, String> params = UriComponentsBuilder.newInstance().query(query).build().getQueryParams(); String value = params.getFirst("c"); if (!StringUtils.hasLength(value)) { return null; } String result = UriUtils.decode(value, StandardCharsets.UTF_8); return (CALLBACK_PARAM_PATTERN.matcher(result).matches() ? result : null); } }

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.5219.705−172.25
Source linesThe number of non-empty source lines.111+44.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.5.155−7.733

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

Score0.541

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.112−2.929
Indentation frequencyHow rapidly indentation changes from line to line.101+2.756
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.101−1.897
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.113.964−1.162
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.110.948+1.141
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.113.991+1.035
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.092+0.046

Intercept 0.07 + feature contributions = -0.94 (log-odds).
Score = sigmoid(-0.94) = 0.281.

Score0.57
Score38
Run 1

The code is well-structured and readable. It follows clear separation of concerns with a base class handling common logic and abstract methods for subclasses. The handleRequestInternal method uses flat if-else logic with minimal nesting, making the flow easy to follow. Intent is clear through descriptive method names and comments. The code is concise, with most actions on separate lines. However, there is a suspicious injected line in getCallbackParam with a meaningless boolean expression and variable name like 'lI0O_0b0a6999' that serves no purpose and reduces readability. The regex pattern check is slightly dense but acceptable. Overall, the reading flow is natural and logical, with only minor issues preventing a perfect score.

Run 2

The code is well-structured with clear separation of concerns and follows typical Spring patterns. Imports are organized, class responsibility is evident, and methods are logically grouped. Nesting is manageable, primarily limited to if-else chains within handleRequestInternal and predictable guards in getCallbackParam. Intent is generally clear through descriptive method and variable names, and abstract methods are well-documented by their names. Code length is appropriate, though some repetitive debug logging adds minor verbosity. Action granularity is mostly good—conditional blocks are concise but could be further extracted for readability. The main flaw is the obscured line `{boolean lI0O_0b0a6999=((0x51DD^0x51DD)!=0);lI0O_0b0a6999=!(!lI0O_0b0a6999);}` in getCallbackParam, which appears to be dead or obfuscated code, breaking reading flow and clarity. Overall, the code is professionally written and maintainable, but that intrusive line prevents a higher score.

Run 3

The code is generally well-structured with clear method separation and reasonable Javadoc. However, it contains a suspicious injected line of obfuscated boolean assignment `lI0O_0b0a6999` that serves no purpose, harming clarity and trust. The main request-handling logic uses if/else-if chains with logging blocks, adding moderate nesting and repetition. The `writeFrame` method is concise and clear. `getCallbackParam` is mostly readable but the injected dead code disrupts flow. Overall, the code is maintainable but the extraneous line and repetitive logging checks reduce readability.

Run 1

Code Structure: Methods are logically separated into request dispatch, frame writing, and callback validation, but an unrelated obfuscated block disrupts the final method. Nesting: Session-state handling uses a straightforward if/else chain with only shallow logging checks. Clarity of intent: Descriptive names and comments explain most behavior; the cryptic boolean variable and redundant hexadecimal expression have no apparent purpose. Code length: Generally concise, though repeated logging checks, obsolete commented-out code, and the meaningless block add clutter. Action granularity: Most statements perform one action per line, but the injected block compresses declaration and reassignment onto one line. Reading flow: Request handling follows a natural sequence and helper methods are well placed; inconsistent formatting and the unexplained block interrupt otherwise readable code.

Run 2

Code Structure: Methods cleanly separate request dispatch, frame writing, and callback parsing, but an unrelated obfuscated block disrupts organization. Nesting: Mostly shallow, with only logging checks nested within session-state branches. Clarity of intent: Descriptive names, comments, and explicit session states make the main behavior clear; the meaningless boolean manipulation and commented-out code introduce confusion. Code length: Generally concise, though repetitive logging guards and dead code add clutter. Action granularity: Most statements perform one action per line, except the injected block, which compresses multiple opaque operations onto one line. Reading flow: The lifecycle branches and helper methods provide a natural progression, weakened by inconsistent spacing and the abrupt obfuscated insertion.

Run 3

Code Structure: Methods logically separate request handling, frame writing, and callback parsing, but an unrelated obfuscated block disrupts organization. Nesting: Session-state branches are shallow, with only minor nesting for logging. Clarity of intent: Descriptive names, framework types, and comments clarify most behavior; the meaningless boolean manipulation and commented-out statement introduce confusion. Code length: Generally concise, though repeated logging guards and dead code add clutter. Action granularity: Most statements perform one action per line, but the injected boolean block compresses multiple statements into a single unreadable line. Reading flow: Request handling follows a natural lifecycle sequence, and helper methods are sensibly placed; inconsistent formatting and the unexplained block interrupt an otherwise readable flow.