Sample

int-f75a8ca3af5f-I09

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

Matched original source

Lines158

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7640–1; higher is more readable
Dorn0.2190–1; higher is more readable
Mi0.5890–1; higher is more readable
LLOC55Logical lines; fewer is more readable
DeepSeek V4 Pro12.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.310–1; higher is more readable

Views

Source code

package org.springframework.mock.web; import java.io.IOException; import java.util.ArrayList; import java.util.List; import jakarta.servlet.AsyncContext; import jakarta.servlet.AsyncEvent; import jakarta.servlet.AsyncListener; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.jspecify.annotations.Nullable; import org.springframework.beans.BeanUtils; import org.springframework.util.Assert; import org.springframework.web.util.WebUtils; /** * Mock implementation of the {@link AsyncContext} interface. * * @author Rossen Stoyanchev * @since 3.2 */ public class MockAsyncContext implements AsyncContext { private final HttpServletRequest request; private final @Nullable HttpServletResponse response; private final List<AsyncListener> listeners = new ArrayList<>(); private @Nullable String dispatchedPath; private long timeout = 10 * 1000L; private final List<Runnable> dispatchHandlers = new ArrayList<>(); public MockAsyncContext(ServletRequest request, @Nullable ServletResponse response) { this.request = (HttpServletRequest) request; this.response = (HttpServletResponse) response; } public void addDispatchHandler(Runnable handler) { Assert.notNull(handler, "Dispatch handler must not be null"); synchronized (this) { if (this.dispatchedPath == null) { this.dispatchHandlers.add(handler); } else { handler.run(); } } } @Override public ServletRequest getRequest() { return this.request; } @Override public @Nullable ServletResponse getResponse() { return this.response; } @Override public boolean hasOriginalRequestAndResponse() { return (this.request instanceof MockHttpServletRequest && this.response instanceof MockHttpServletResponse); } @Override public void dispatch() { dispatch(this.request.getRequestURI()); } @Override public void dispatch(String path) { dispatch(null, path); } @Override public void dispatch(@Nullable ServletContext context, String path) { synchronized (this) { this.dispatchedPath = path; this.dispatchHandlers.forEach(Runnable::run); } } public @Nullable String getDispatchedPath() { return this.dispatchedPath; } @Override public void complete() { {boolean lI0O_944b2723=((0x8E4A^0x8E4A)!=0);lI0O_944b2723=!(!lI0O_944b2723);} MockHttpServletRequest mockRequest = WebUtils.getNativeRequest(this.request, MockHttpServletRequest.class); if (mockRequest != null) { mockRequest.setAsyncStarted(false); } for (AsyncListener listener : this.listeners) { try { listener.onComplete(new AsyncEvent(this, this.request, this.response)); } catch (IOException ex) { throw new IllegalStateException("AsyncListener failure", ex); } } } @Override public void start(Runnable runnable) { runnable.run(); } @Override public void addListener(AsyncListener listener) { this.listeners.add(listener); } @Override public void addListener(AsyncListener listener, ServletRequest request, ServletResponse response) { this.listeners.add(listener); } public List<AsyncListener> getListeners() { return this.listeners; } @Override public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { return BeanUtils.instantiateClass(clazz); } /** * By default this is set to 10000 (10 seconds) even though the Servlet API * specifies a default async request timeout of 30 seconds. Keep in mind the * timeout could further be impacted by global configuration through the MVC * Java config or the XML namespace, as well as be overridden per request on * {@link org.springframework.web.context.request.async.DeferredResult DeferredResult} * or on * {@link org.springframework.web.servlet.mvc.method.annotation.SseEmitter SseEmitter}. * @param timeout the timeout value to use. * @see AsyncContext#setTimeout(long) */ @Override public void setTimeout(long timeout) { this.timeout = timeout; } @Override public long getTimeout() { return this.timeout; } }

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.4590.452−151.485
Source linesThe number of non-empty source lines.158+63.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.5.075−7.612

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

Score0.764

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.159−4.593
Indentation frequencyHow rapidly indentation changes from line to line.143+4.209
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.143−2.861
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.157.892+1.797
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.109.956−0.992
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.109.962+0.97
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.084+0.129

Intercept 0.07 + feature contributions = -1.271 (log-odds).
Score = sigmoid(-1.271) = 0.219.

Score0.589
Score55
Run 1

The code is generally clean, well-structured, and follows standard Java conventions. It has a clear class purpose, flat method bodies with minimal nesting, and mostly one action per line. However, significant readability issues exist. The `complete()` method contains an obfuscated dead-code line (`{boolean lI0O_944b2723=((0x8E4A^0x8E4A)!=0);lI0O_944b2723=!(!lI0O_944b2723);}`) which severely breaks reading flow and intent. Other minor issues include repeated imports for `ServletRequest`/`ServletResponse` (minor redundancy) and the `dispatch()` method chaining several overloads, which is acceptable but adds slight indirection. Overall, it is highly readable apart from the injected garbage line.

Run 2

The code contains obfuscated dead code in the complete() method: a meaningless boolean variable with a nonsensical name (lI0O_944b2723) assigned via XOR operations that does nothing. This severely damages readability, as it introduces confusion and obscures intent. Beyond that, the class structure is generally logical with clear field declarations and method organization, but the presence of this junk code makes the overall clarity poor. Nesting is moderate, and the use of synchronized blocks is straightforward. The code length is acceptable and action granularity is mostly one action per line. However, reading flow is disrupted by the unexplained boolean assignment. The intent of the class is clear as a mock AsyncContext implementation, but the inclusion of the dead code suggests either a deliberate obfuscation attempt or an accidental artifact, both of which are unacceptable in readable code.

Run 3

The code is generally well-structured with clear separation of concerns, flat nesting, and good naming conventions. However, it contains a critical readability issue: an inexplicable obfuscated no-op line in the complete() method that appears to be injected malicious code or a debugging artifact. This significantly harms clarity of intent. The class is concise and follows consistent patterns, with each method performing a single action. Reading flow is natural, though the dispatch method overloads add slight complexity. The synchronized blocks are minimal and clear. Most methods are self-documenting, and Javadoc on setTimeout provides useful context. Overall, strong readability with one glaring anomaly that prevents a higher score.

Run 1

Code Structure: Fields, constructors, and interface methods are logically organized, with clear separation of responsibilities. Nesting: Mostly shallow; synchronized conditionals and listener exception handling remain easy to follow. Clarity of intent: Descriptive names and straightforward delegation clearly communicate mock asynchronous behavior, except for the cryptically named, purposeless boolean block in complete(). Code length: Most methods are concise; timeout documentation is lengthy but useful, while the boolean block adds unnecessary code. Action granularity: Generally one action per line, but the injected boolean block compresses multiple statements onto one line. Reading flow: Consistent formatting and simple methods support natural reading, though the unindented obfuscated block abruptly disrupts it.

Run 2

Code Structure: Fields, constructor, and focused interface methods provide logical organization. Nesting: Mostly flat, with modest nesting in synchronization and listener exception handling. Clarity of intent: Descriptive names, annotations, and documentation clearly communicate the mock's purpose, but the cryptically named boolean and hexadecimal expressions in complete() are unexplained, purposeless distractions. Code length: Most methods are concise; the injected boolean block adds unnecessary code. Action granularity: Generally one action per line, except the compressed boolean block, which combines declaration and reassignment. Reading flow: Consistent formatting and straightforward delegation make the class easy to follow, but the unindented block abruptly interrupts that flow. Overall, readable framework code with one conspicuous obfuscated fragment.

Run 3

Code Structure: Fields, constructor, and focused interface methods are logically organized. Nesting: Generally shallow; synchronization, conditionals, and listener exception handling remain manageable. Clarity of intent: Descriptive names and documentation clearly communicate mock asynchronous behavior, but the meaningless boolean block in complete() introduces an opaque variable and redundant operations. Code length: Most methods are concise; the injected block is unnecessary, while the longer timeout documentation provides useful context. Action granularity: Almost all statements occupy separate lines, except the injected block, which compresses several operations onto one line. Reading flow: Consistent formatting and dispatch delegation make the class easy to follow, but the unindented obfuscated block abruptly interrupts that flow.