Sample

int-dec670427c36-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines49

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.770–1; higher is more readable
Dorn0.6230–1; higher is more readable
Mi0.3120–1; higher is more readable
LLOC13Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol17.670–20; mean of three runs
BTTF0.6530–1; higher is more readable

Views

Source code

package io.netty.example.uptime; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; import io.netty.channel.MultiThreadIoEventLoopGroup; import io.netty.channel.nio.NioIoHandler; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.logging.LogLevel; import io.netty.handler.logging.LoggingHandler; /** * Uptime server is served as a connection server. * So it simply discards all message received. */ public final class UptimeServer { private static final int PORT = Integer.parseInt(System.getProperty("port", "8080")); private static final UptimeServerHandler handler = new UptimeServerHandler(); private UptimeServer() { } public static void main(String[] args) throws Exception { EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory()); try { ServerBootstrap b = new ServerBootstrap(); b.group(group) .channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) { ch.pipeline().addLast(handler); } }); // Bind and start to accept incoming connections. ChannelFuture f = b.bind(PORT).sync(); // Wait until the server socket is closed. // In this example, this does not happen, but you can do that to gracefully // shut down your server. f.channel().closeFuture().sync(); } finally { group.shutdownGracefully(); } } }

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.1782.669−58.828
Source linesThe number of non-empty source lines.49+19.6
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.54−6.809

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

Score0.77

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.42+0.716
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.49−0.699
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.90+0.648
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.42−0.543
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.48.945+0.274
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.078+0.181
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.89.92−0.143

Intercept 0.07 + feature contributions = 0.504 (log-odds).
Score = sigmoid(0.504) = 0.623.

Score0.312
Score13
Run 1

The code is generally well-structured and readable. It follows standard Netty server bootstrap patterns with clear separation of concerns. The class has a single responsibility, proper encapsulation with a private constructor, and logical grouping of imports. The main method has a clear flow: setup, bind, wait, cleanup. Nesting is minimal—only one anonymous inner class with a one-line method. The intent is clear through descriptive naming and helpful comments. Code length is appropriate for a server bootstrap example. Each line performs a distinct action, especially in the fluent configuration chain. Reading flow is natural, moving from configuration to execution to shutdown. Minor deductions: the static handler field could be explained, and the anonymous inner class could be a lambda for brevity, but these don't significantly impact readability.

Run 2

The code is well-structured and readable. It has clear separation of concerns with a private constructor, a main method, and a separate handler class. Nesting is minimal, with only one anonymous inner class for channel initialization. The purpose is evident from the Javadoc comment and method names. The code is concise without unnecessary repetition. Most lines perform a single logical action, especially in the bootstrap configuration chain. The reading flow is natural: setup, bind, then wait for shutdown. Minor deductions: the static handler field could be a local variable or instance field for better testability, and the comment block is slightly verbose, but overall this is very clean Netty boilerplate code.

Run 3

The code is well-structured and highly readable. It follows a clear logical organization with a standard main method setup. Nesting is minimal, with only an anonymous ChannelInitializer class adding one level. The intent is explicit: a simple uptime server that discards messages, documented in a class-level comment. Code length is concise and avoids unnecessary verbosity. Each action is on its own line, improving clarity. The reading flow is natural, progressing from configuration to binding to shutdown. Minor deductions: the anonymous inner class could be replaced with a lambda for brevity, though this is a style choice. Overall, the code exemplifies clean, maintainable Netty boilerplate.

Run 1

Code Structure: Clearly organized into configuration, server setup, execution, and cleanup. Nesting: Shallow overall, though the anonymous channel initializer adds a small nested block within the configuration chain. Clarity of intent: Netty API calls and lifecycle comments make the server's purpose clear; abbreviated names b and f and the awkward class documentation slightly reduce clarity. Code length: Compact without unnecessary logic or duplication. Action granularity: Statements generally perform one logical action, and chained configuration calls are separated onto individual lines. Reading flow: Execution proceeds naturally from initialization through binding and waiting to guaranteed cleanup in finally. Minor spacing improvements around imports and more descriptive local variable names would improve readability further.

Run 2

Code Structure: Logically separates constants, construction prevention, server configuration, execution, and cleanup. Nesting: Mostly shallow, with modest additional nesting from the anonymous channel initializer inside try/finally. Clarity of intent: Netty API calls and lifecycle comments clearly convey the server's purpose, though abbreviated variables b, f, and ch and awkward class documentation reduce clarity slightly. Code length: Compact and appropriate, with little unnecessary code. Action granularity: Statements generally perform one logical action; the fluent configuration chain places each configuration step on its own line. Reading flow: Follows a natural setup, bind, wait, and cleanup sequence, supported by consistent indentation and spacing.

Run 3

Code Structure: Logically organized into configuration, initialization, server startup, waiting, and cleanup. Nesting: Mostly shallow, though the anonymous ChannelInitializer inside the fluent configuration adds some depth. Clarity of intent: Netty API calls and lifecycle comments make the purpose clear, but abbreviated names b, f, and ch reduce clarity, and the class documentation is awkwardly worded. Code length: Concise, with little unnecessary code; the shutdown comment could be shorter. Action granularity: Most statements perform one logical action, and each bootstrap configuration step occupies its own line. Reading flow: The sequence follows the server lifecycle naturally, with try/finally clearly separating operation from cleanup. More descriptive local names and polished documentation would improve readability.