Sample

int-db472a2c30cf-I11

Split eligible integer literals into pairs of short-named intermediate variables

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 Sol170–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 easy to follow. It uses clear, descriptive variable names and separates the server setup from configuration logically. The nested ChannelInitializer is a common Netty pattern and remains readable due to its single-purpose anonymous class. Indentation and line breaks are consistent. The main method follows a straightforward flow: create event loop group, configure bootstrap, bind, and wait for shutdown. Comments clarify the blocking behavior and shutdown intention without being excessive. However, there are minor readability drawbacks: the static PORT initialization uses a one-liner that combines property retrieval and parsing, slightly reducing clarity. The anonymous inner class adds nesting compared to a lambda or static nested class. Additionally, the handler is a static mutable field, which could be made final and thread-safe but does not significantly hinder readability. Overall, the code is concise, purposeful, and adheres to Netty conventions.

Run 3

The code demonstrates excellent readability through clear package structure, logical imports, and a single-purpose class with a private constructor. The main method follows a clean bootstrap pattern with flat nesting and well-placed comments explaining the bind and shutdown behavior. Each line performs one logical action, and the method chaining is formatted with proper indentation. The anonymous inner class for ChannelInitializer is minimal and purposeful. Variable names are concise yet meaningful ('b' for bootstrap, 'f' for channel future, 'group' for event loop group). The only minor deductions are for 'b' and 'f' being slightly abbreviated, and the try-finally block could potentially be enhanced with try-with-resources in newer Java versions. Overall, this follows idiomatic Netty patterns with clear intent and natural reading flow.

Run 1

Code Structure: Logically separates configuration, initialization, binding, waiting, and cleanup. Nesting: Mostly shallow; the anonymous ChannelInitializer introduces moderate nesting but remains easy to follow. Clarity of intent: Netty API calls and lifecycle comments make the server's purpose clear, although names such as b, f, and ch are terse, and the class documentation is awkwardly worded. Code length: Concise, with little unnecessary code; the shutdown comment could be shortened. Action granularity: Statements generally perform one logical action, and the fluent configuration places each step on its own line. Reading flow: Execution proceeds naturally from setup through shutdown, with consistent indentation and useful spacing inside main. A blank line between the package declaration and imports, plus more descriptive local names, would improve readability.

Run 2

Code Structure: Logically organized into configuration, initialization, binding, waiting, and cleanup, with a clear try/finally lifecycle. Nesting: Mostly shallow, though the anonymous ChannelInitializer introduces additional indentation within the fluent configuration chain. Clarity of intent: Netty API names and lifecycle comments communicate the server's purpose well; abbreviated variables b, f, and ch and the awkward class documentation reduce clarity slightly. Code length: Concise, with little unnecessary code, although the shutdown comment could be shorter. Action granularity: Statements generally perform one logical action, and bootstrap configuration steps occupy separate lines; chained calls remain readable. Reading flow: Execution proceeds naturally from setup to shutdown, with consistent formatting and helpful whitespace. The actual message-discarding behavior is delegated to UptimeServerHandler, so it is not directly visible here.

Run 3

Code Structure: Logically organized into configuration, server setup, binding, waiting, and cleanup; try/finally clearly expresses resource management. Nesting: Mostly shallow, though the anonymous ChannelInitializer adds a moderately nested block inside the fluent configuration chain. Clarity of intent: Netty API calls and lifecycle comments make the purpose clear, but abbreviated names such as b, f, and ch reduce clarity, and the class documentation is awkwardly phrased. Code length: Concise, with little unnecessary code; the shutdown comment could be shorter. Action granularity: Most statements perform one clear action, and chained configuration calls appear on separate lines. Reading flow: Execution proceeds naturally from initialization through shutdown, with consistent indentation and useful spacing.