Sample

int-4bc6af703235-I13

Lower every eligible classic and enhanced for loop to a while loop

Matched original source

Lines182

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6850–1; higher is more readable
Dorn0.1670–1; higher is more readable
Mi0.2910–1; higher is more readable
LLOC31Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.6170–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() { { java.util.Iterator<?> loopIterator = (this).iterator(); while (loopIterator.hasNext()) { EventExecutor e = (EventExecutor) loopIterator.next(); ((NioEventLoop) e).rebuildSelector(); } } } @Override protected IoEventLoop newChild(Executor executor, IoHandlerFactory ioHandlerFactory, Object... args) { RejectedExecutionHandler rejectedExecutionHandler = (RejectedExecutionHandler) args[0]; 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); } }

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.5569.855−183.805
Source linesThe number of non-empty source lines.182+72.8
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 = -109.076 (log-odds).
Score = sigmoid(-109.076) = 0.

Score0.685

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.183−5.443
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.181.991+2.134
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.115.962−1.246
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.114.656+1.045
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.047+0.482

Intercept 0.07 + feature contributions = -1.609 (log-odds).
Score = sigmoid(-1.609) = 0.167.

Score0.291
Score31
Run 1

The code is highly readable. The structure is logical, with a clear hierarchy of constructors delegating to a main implementation, following a standard Netty pattern. Nesting is minimal; the deepest block is a straightforward iterator in 'rebuildSelectors'. The intent of each constructor is documented with Javadoc, and the deprecated class clearly points to a replacement. Code length is moderate and consistent with providing a comprehensive API. Action granularity is generally one action per line. The 'newChild' method uses simple index-based argument parsing that is concise but slightly less explicit compared to named parameters, though it remains understandable.

Run 2

The code is generally readable, but suffers from constructor overload proliferation and some inconsistencies. Class structure is logical, with clear imports and deprecation notices. However, the many delegating constructors add length and repetitive logic. Nesting is shallow, which is good; the only extra block in `rebuildSelectors` is unnecessary. Intent is mostly clear: this class is a deprecated NIO event loop group that delegates to a newer API. Code length is high due to 12 constructors, many doing similar delegation. Action granularity is strong—each parameter and statement is on its own line. Reading flow is natural from public API to implementation, but the `newChild` method has argument-array parsing that breaks type safety and clarity. The `@deprecated` messages are helpful. Overall, it is readable but feels bloated by compatibility overloads and raw `Object[]` args.

Run 3

The code is generally readable but has some structural and clarity issues. The constructor overloading is logical but creates redundancy—multiple constructors call each other with slightly different arguments, which can be hard to follow. The class structure is mostly flat, which is good, but the `rebuildSelectors` method has an unnecessary nested block, and its loop variable types rely on casting, reducing clarity. The `newChild` method manually parses varargs with type casts and index checks, making intent less obvious than using a clearer parameter object or explicit constructor. Naming is consistent, and documentation on public constructors is helpful, but some constructors lack Javadoc. Code length is somewhat excessive due to many constructors, though each is concise. Action granularity is mostly one action per line, but some method calls wrap awkwardly. Overall, the code is maintainable but could be improved by reducing constructor duplication, removing unnecessary nesting, and using stronger typing for varargs.

Run 1

Code Structure: Logically organized into constructors and lifecycle methods, with consistent delegation rather than tangled logic. Nesting: Mostly flat; rebuildSelectors adds an unnecessary block around its loop. Clarity of intent: Descriptive names and Javadoc explain configuration and behavior, but positional Object... arguments and casts in newChild obscure type expectations. Code length: Individual methods are concise, although numerous similar constructor overloads and repetitive documentation make the class lengthy to scan. Action granularity: Statements generally perform one action each; nested factory calls remain understandable. Reading flow: Constructor ordering progresses naturally from defaults to advanced options, followed by operational methods. Inconsistent indentation, redundant parentheses, and a fully qualified iterator type in rebuildSelectors interrupt otherwise clean formatting.

Run 2

Code Structure: Constructors are logically grouped and delegate consistently, followed by operational methods and child creation. Nesting: Mostly flat, although rebuildSelectors contains an unnecessary block around its loop. Clarity of intent: Descriptive names and Javadoc explain configuration and behavior; positional Object... arguments and casts in newChild reduce transparency. Code length: Numerous constructor overloads and repeated documentation make the class lengthy, though most support legitimate configuration options. Action granularity: Statements generally perform one action each; nested factory calls remain understandable. Reading flow: Organization is natural overall, but inconsistent indentation, long signatures, and the fully qualified iterator, redundant parentheses, and explicit casts in rebuildSelectors interrupt an otherwise clean style.

Run 3

Code Structure: Constructors are grouped logically and delegate consistently, followed by operational methods and child creation. Nesting: Mostly flat, although rebuildSelectors adds an unnecessary block around its loop. Clarity of intent: Descriptive names and Javadoc explain configuration and behavior; positional Object... arguments and casts in newChild reduce transparency. Code length: Numerous constructor overloads and repetitive documentation make the class lengthy, though most support useful configuration options. Action granularity: Statements generally perform one action each; nested factory calls in superclass invocations remain understandable. Reading flow: Consistent delegation and short method bodies support natural reading, but uneven indentation, long parameter lists, and the awkward explicit iterator implementation interrupt it.