Sample

int-05e522d8b0f4-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines178

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6970–1; higher is more readable
Dorn0.1390–1; higher is more readable
Mi0.2910–1; higher is more readable
LLOC28Logical lines; fewer is more readable
DeepSeek V4 Pro140–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.5350–1; higher is more readable

Views

Source code

package io.netty.channel.nio; import io.netty.channel.Channel; import io.netty.channel.DefaultSelectStrategyFactory; import io.netty.channel.EventLoopTaskQueueFactory; import io.netty.channel.IoEventLoop; import io.netty.channel.IoEventLoopGroup; import io.netty.channel.IoHandlerFactory; import io.netty.channel.MultiThreadIoEventLoopGroup; import io.netty.channel.SelectStrategyFactory; import io.netty.channel.SingleThreadEventLoop; import io.netty.util.concurrent.EventExecutor; import io.netty.util.concurrent.EventExecutorChooserFactory; import io.netty.util.concurrent.RejectedExecutionHandler; import io.netty.util.concurrent.RejectedExecutionHandlers; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; import java.nio.channels.Selector; import java.nio.channels.spi.SelectorProvider; import java.util.concurrent.Executor; import java.util.concurrent.ThreadFactory; /** * {@link MultiThreadIoEventLoopGroup} implementation which is used for NIO {@link Selector} based {@link Channel}s. * * @deprecated Use {@link MultiThreadIoEventLoopGroup} with {@link NioIoHandler#newFactory()}. */ @Deprecated public class NioEventLoopGroup extends MultiThreadIoEventLoopGroup implements IoEventLoopGroup { private static final InternalLogger LOGGER = InternalLoggerFactory.getInstance(NioEventLoopGroup.class); /** * Create a new instance using the default number of threads, the default {@link ThreadFactory} and * the {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}. */ public NioEventLoopGroup() { this(0); } /** * Create a new instance using the specified number of threads, {@link ThreadFactory} and the * {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}. */ public NioEventLoopGroup(int nThreads) { this(nThreads, (Executor) null); } /** * Create a new instance using the default number of threads, the given {@link ThreadFactory} and the * {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}. */ public NioEventLoopGroup(ThreadFactory threadFactory) { this(0, threadFactory, SelectorProvider.provider()); } /** * Create a new instance using the specified number of threads, the given {@link ThreadFactory} and the * {@link SelectorProvider} which is returned by {@link SelectorProvider#provider()}. */ public NioEventLoopGroup(int nThreads, ThreadFactory threadFactory) { this(nThreads, threadFactory, SelectorProvider.provider()); } public NioEventLoopGroup(int nThreads, Executor executor) { this(nThreads, executor, SelectorProvider.provider()); } /** * Create a new instance using the specified number of threads, the given {@link ThreadFactory} and the given * {@link SelectorProvider}. */ public NioEventLoopGroup( int nThreads, ThreadFactory threadFactory, final SelectorProvider selectorProvider) { this(nThreads, threadFactory, selectorProvider, DefaultSelectStrategyFactory.INSTANCE); } public NioEventLoopGroup(int nThreads, ThreadFactory threadFactory, final SelectorProvider selectorProvider, final SelectStrategyFactory selectStrategyFactory) { super(nThreads, threadFactory, NioIoHandler.newFactory(selectorProvider, selectStrategyFactory), RejectedExecutionHandlers.reject()); } public NioEventLoopGroup( int nThreads, Executor executor, final SelectorProvider selectorProvider) { this(nThreads, executor, selectorProvider, DefaultSelectStrategyFactory.INSTANCE); } public NioEventLoopGroup(int nThreads, Executor executor, final SelectorProvider selectorProvider, final SelectStrategyFactory selectStrategyFactory) { super(nThreads, executor, NioIoHandler.newFactory(selectorProvider, selectStrategyFactory), RejectedExecutionHandlers.reject()); } public NioEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, final SelectorProvider selectorProvider, final SelectStrategyFactory selectStrategyFactory) { super(nThreads, executor, NioIoHandler.newFactory(selectorProvider, selectStrategyFactory), chooserFactory, RejectedExecutionHandlers.reject()); } public NioEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, final SelectorProvider selectorProvider, final SelectStrategyFactory selectStrategyFactory, final RejectedExecutionHandler rejectedExecutionHandler) { super(nThreads, executor, NioIoHandler.newFactory(selectorProvider, selectStrategyFactory), chooserFactory, rejectedExecutionHandler); } public NioEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, final SelectorProvider selectorProvider, final SelectStrategyFactory selectStrategyFactory, final RejectedExecutionHandler rejectedExecutionHandler, final EventLoopTaskQueueFactory taskQueueFactory) { super(nThreads, executor, NioIoHandler.newFactory(selectorProvider, selectStrategyFactory), chooserFactory, rejectedExecutionHandler, taskQueueFactory); } /** * @param nThreads the number of threads that will be used by this instance. * @param executor the Executor to use, or {@code null} if default one should be used. * @param chooserFactory the {@link EventExecutorChooserFactory} to use. * @param selectorProvider the {@link SelectorProvider} to use. * @param selectStrategyFactory the {@link SelectStrategyFactory} to use. * @param rejectedExecutionHandler the {@link RejectedExecutionHandler} to use. * @param taskQueueFactory the {@link EventLoopTaskQueueFactory} to use for * {@link SingleThreadEventLoop#execute(Runnable)}, * or {@code null} if default one should be used. * @param tailTaskQueueFactory the {@link EventLoopTaskQueueFactory} to use for * {@link SingleThreadEventLoop#executeAfterEventLoopIteration(Runnable)}, * or {@code null} if default one should be used. */ public NioEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory) { super(nThreads, executor, NioIoHandler.newFactory(selectorProvider, selectStrategyFactory), chooserFactory, rejectedExecutionHandler, taskQueueFactory, tailTaskQueueFactory); } /** * This method is a no-op. * * @deprecated */ @Deprecated public void setIoRatio(int ioRatio) { LOGGER.debug("NioEventLoopGroup.setIoRatio(int) logic was removed, this is a no-op"); } /** * Replaces the current {@link Selector}s of the child event loops with newly created {@link Selector}s to work * around the infamous epoll 100% CPU bug. */ public void rebuildSelectors() { for (EventExecutor e: this) { ((NioEventLoop) e).rebuildSelector(); } } @Override protected IoEventLoop newChild(Executor executor, IoHandlerFactory ioHandlerFactory, Object... args) { EventLoopTaskQueueFactory taskQueueFactory = null; EventLoopTaskQueueFactory tailTaskQueueFactory = null; int argsLength = args.length; if (argsLength > 1) { taskQueueFactory = (EventLoopTaskQueueFactory) args[1]; } if (argsLength > 2) { tailTaskQueueFactory = (EventLoopTaskQueueFactory) args[2]; } return new NioEventLoop( this, executor, ioHandlerFactory, taskQueueFactory, tailTaskQueueFactory, ((RejectedExecutionHandler) args[0])); } }

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.5260.131−173.584
Source linesThe number of non-empty source lines.178+71.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.627−6.941

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

Score0.697

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.178−5.266
Indentation frequencyHow rapidly indentation changes from line to line.139+4.071
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.139−2.769
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.177.953+2.078
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.127.966−1.755
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.127.235+1.248
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.496

Intercept 0.07 + feature contributions = -1.827 (log-odds).
Score = sigmoid(-1.827) = 0.139.

Score0.291
Score28
Run 1

The code is generally structured and uses clear naming, but it suffers from readability issues mainly due to constructor chaining, inconsistent formatting, and excessive boilerplate. The class has many overloaded constructors, which is common in builder-like APIs but creates clutter. Several constructors and methods lack Javadocs, and formatting is inconsistent (e.g., mixed indentation, missing spaces after commas). The ‘newChild’ method has weak readability: it uses nullable variables, magic index-based argument handling, and a blank line right after the method signature. The ‘rebuildSelectors’ method is concise and clear. Nesting is low, which is good. Overall, the code reads as maintainable but requires careful attention to understand the constructor hierarchy and argument handling.

Run 2

The code is moderately readable but has significant issues. The class has a clear purpose and follows a consistent structure, but it suffers from excessive constructor overloading (10 constructors), creating redundancy and making the API difficult to navigate. The nesting is generally flat, which is good, but the `newChild` method has confusing array-based argument processing with magic indices that lack clarity. Variable naming is mostly clear, but the constructors lack documentation for several overloads, making intent ambiguous. Code length is unnecessarily long due to repetitive constructor patterns that could be consolidated. Action granularity is reasonable, with one operation per line. The reading flow is logical but interrupted by the verbose constructor chain. The `rebuildSelectors` method has an unnecessary space in the enhanced for loop and a deprecated no-op method adds clutter. Overall, while the code is functional and somewhat organized, the constructor overloads and unclear argument handling in `newChild` significantly reduce readability.

Run 3

The code is highly readable. Structure is logical and follows a clear pattern of escalating constructor overloads that eventually delegate to a single comprehensive constructor. Nesting is minimal, with only a simple loop and two if-blocks. Intent is clear: provide NIO-specific event loop group creation with backward compatibility and deprecation notices. Action granularity is excellent—most constructors perform one operation (delegating via this or super), keeping each line focused. Reading flow is natural, from simple constructors to more complex ones, with Javadoc on key constructors. Minor readability reductions: many overloaded constructors create repetitive code length, and some lines in super() calls wrap awkwardly. Parameter alignment is inconsistent in a few constructors. The deprecation notice and no-op method are clearly explained. Overall, this is a clean, maintainable API even though constructor overloading is extensive.

Run 1

Code Structure: Logically organized into constructors, compatibility methods, and child-loop creation, with consistent delegation. Nesting: Very shallow; only a loop and two independent conditionals. Clarity of intent: Descriptive names and Javadoc explain most behavior, including deprecation and the no-op method. However, positional Object... arguments and casts in newChild obscure the argument contract. Code length: Individual methods are concise, but numerous similar constructor overloads and repetitive documentation increase scanning effort. Action granularity: Statements generally perform one action each; nested factory calls and the long final constructor invocation add minor cognitive load. Reading flow: Progression from simple constructors to configurable overloads is natural, followed by operational methods. Inconsistent parameter indentation, long signatures, uneven documentation coverage, and the abbreviated loop variable slightly reduce readability.

Run 2

Code Structure: Logically organized into constructors, public operations, and child-loop creation; constructor delegation avoids duplicated initialization. Nesting: Very shallow, with only a simple loop and independent conditionals. Clarity of intent: Descriptive class, method, and parameter names plus Javadoc make the purpose clear, although positional Object... arguments and casts in newChild obscure the argument contract. Code length: Individual methods are concise, but numerous similar constructor overloads and repeated documentation make the class lengthy to scan. Action granularity: Statements generally perform one action each; nested factory calls and the final constructor expression slightly increase cognitive load. Reading flow: The progression from simple constructors to advanced configuration and operational methods is natural, though inconsistent parameter indentation, long lines, and uneven documentation reduce polish.

Run 3

Code Structure: Logically organized into constructors, public operations, and child creation, with consistent delegation. Nesting: Very shallow; only a simple loop and independent conditionals. Clarity of intent: Descriptive class, method, and parameter names plus Javadoc make the purpose clear, but positional Object... arguments and casts in newChild obscure parameter meaning. Code length: Individual methods are concise, although numerous constructor overloads and repetitive documentation make the class lengthy. Action granularity: Statements generally perform one action each; nested factory calls in constructor delegation slightly increase cognitive load. Reading flow: Progression from simple constructors to advanced configuration and operational methods is natural. Inconsistent parameter indentation, long lines, and uneven documentation modestly disrupt scanning.