Sample

int-eecf914f32e6-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines151

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5840–1; higher is more readable
Dorn0.870–1; higher is more readable
Mi0.2550–1; higher is more readable
LLOC42Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.550–1; higher is more readable

Views

Source code

package com.google.common.util.concurrent; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Throwables.throwIfUnchecked; import static com.google.common.util.concurrent.Platform.restoreInterruptIfIsInterruptedException; import static java.util.concurrent.Executors.callable; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.J2ktIncompatible; import com.google.common.collect.ImmutableList; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Collection; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jspecify.annotations.Nullable; /** * An abstract {@code ExecutorService} that allows subclasses to {@linkplain #wrapTask(Callable) * wrap} tasks before they are submitted to the underlying executor. * * <p>Note that task wrapping may occur even if the task is never executed. * * <p>For delegation without task-wrapping, see {@link ForwardingExecutorService}. * * @author Chris Nokleberg */ @J2ktIncompatible @GwtIncompatible abstract class WrappingExecutorService implements ExecutorService { private final ExecutorService delegate; protected WrappingExecutorService(ExecutorService delegate) { this.delegate = checkNotNull(delegate); } /** * Wraps a {@code Callable} for submission to the underlying executor. This method is also applied * to any {@code Runnable} passed to the default implementation of {@link #wrapTask(Runnable)}. */ protected abstract <T extends @Nullable Object> Callable<T> wrapTask(Callable<T> callable); /** * Wraps a {@code Runnable} for submission to the underlying executor. The default implementation * delegates to {@link #wrapTask(Callable)}. */ protected Runnable wrapTask(Runnable command) { return () -> { try { (wrapTask(callable(command, null))).call(); } catch (Exception e) { restoreInterruptIfIsInterruptedException(e); throwIfUnchecked(e); throw new RuntimeException(e); } }; } /** * Wraps a collection of tasks. * * @throws NullPointerException if any element of {@code tasks} is null */ private <T extends @Nullable Object> ImmutableList<Callable<T>> wrapTasks( Collection<? extends Callable<T>> tasks) { ImmutableList.Builder<Callable<T>> builder = ImmutableList.builder(); for (Callable<T> task : tasks) { builder.add(wrapTask(task)); } return builder.build(); } // These methods wrap before delegating. @Override public final void execute(Runnable command) { delegate.execute(wrapTask(command)); } @Override public final <T extends @Nullable Object> Future<T> submit(Callable<T> task) { return delegate.submit(wrapTask(checkNotNull(task))); } @Override public final Future<?> submit(Runnable task) { return delegate.submit(wrapTask(task)); } @Override public final <T extends @Nullable Object> Future<T> submit( Runnable task, @ParametricNullness T result) { return delegate.submit(wrapTask(task), result); } @Override public final <T extends @Nullable Object> List<Future<T>> invokeAll( Collection<? extends Callable<T>> tasks) throws InterruptedException { return delegate.invokeAll(wrapTasks(tasks)); } @Override public final <T extends @Nullable Object> List<Future<T>> invokeAll( Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { return delegate.invokeAll(wrapTasks(tasks), timeout, unit); } @Override public final <T extends @Nullable Object> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException { return delegate.invokeAny(wrapTasks(tasks)); } @Override public final <T extends @Nullable Object> T invokeAny( Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return delegate.invokeAny(wrapTasks(tasks), timeout, unit); } // The remaining methods just delegate. @Override public final void shutdown() { delegate.shutdown(); } @Override @CanIgnoreReturnValue public final List<Runnable> shutdownNow() { return delegate.shutdownNow(); } @Override public final boolean isShutdown() { return delegate.isShutdown(); } @Override public final boolean isTerminated() { return delegate.isTerminated(); } @Override public final boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { return delegate.awaitTermination(timeout, unit); } }

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.5135.232−169.463
Source linesThe number of non-empty source lines.151+60.4
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.868−7.302

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

Score0.584

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.152−4.346
Indentation frequencyHow rapidly indentation changes from line to line.130+3.759
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.150.941+1.7
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.96.072+0.746
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.99.895−0.566
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.083+0.136

Intercept 0.07 + feature contributions = 1.898 (log-odds).
Score = sigmoid(1.898) = 0.87.

Score0.255
Score42
Run 1

The code is highly readable. It has clear logical structure, separating task-wrapping methods from pure delegation methods with comments. Nesting is minimal, though the Runnable wrapper lambda contains a try/catch with a nested call, which is acceptable. Intent is explicit: subclass to wrap tasks before submission. The code is concise, avoiding unnecessary verbosity, and each line generally performs one action. Reading flow is natural, from constructor to abstract wrap methods to wrapped delegation and finally plain delegation. Naming is descriptive and consistent. Minor clarity improvements could include extracting the lambda body into a private method, but overall this is exemplary Java code.

Run 2

The code demonstrates strong readability with clear structure and logical organization. The class has a single responsibility (wrapping tasks) and methods are grouped logically: wrapping methods, then wrapped delegation methods, then plain delegation methods. Nesting is minimal—the only lambda contains a try-catch but remains flat and understandable. Intent is clearly communicated through descriptive method names, comprehensive Javadoc, and comments separating different method categories. Code length is appropriate for an abstract executor service. Action granularity is generally one action per line, with only the lambda body combining a few operations. Reading flow is natural: declaration, constructor, abstract methods, private helper, then method groups in order of complexity. Minor deductions: nullness annotations add slight visual noise, and the wrapTask lambda could be extracted for clarity, but overall this is production-quality, maintainable code that follows clean code principles well.

Run 3

The code is highly readable with clear structure: wrapping methods are grouped separately from plain delegation methods, making intent obvious. Nesting is minimal, with only one lambda body and a try-catch block. Each method performs a single action, preserving consistent granularity and natural reading flow. Naming is explicit (wrapTask, wrapTasks, delegate), and Javadoc provides helpful context. Minor deductions: the generic type bounds like <T extends @Nullable Object> add slight verbosity, and the wrapTask(Runnable) lambda could be extracted for clarity, but overall the code is concise, well-organized, and maintainable.

Run 1

Code Structure: Clearly separates task-wrapping helpers, wrapped submission methods, and lifecycle delegation. Nesting: Mostly flat, with only a simple loop and a lambda containing try/catch. Clarity of intent: Descriptive names, Javadoc, and grouping comments make the wrapper/delegate purpose explicit; generic nullness annotations add some visual complexity. Code length: Methods are concise; most repetition is necessary to implement ExecutorService. Action granularity: Statements generally perform one action per line, although nested calls combine validation, wrapping, and delegation. Reading flow: Consistent formatting and predictable method organization support easy scanning. Minor distractions include tightly packed imports, an unnecessary blank line, redundant parentheses, and the slightly less obvious deferred wrapping inside the Runnable lambda.

Run 2

Code Structure: Clearly separates wrapping helpers, task-submission methods, and lifecycle delegation. Nesting: Shallow overall, with only a loop and a lambda containing try/catch. Clarity of intent: Descriptive names, Javadoc, and section comments explain the wrapper/delegate design; generic nullness annotations and nested callable conversion add minor complexity. Code length: Most methods are concise; repetition largely follows the ExecutorService interface rather than unnecessary verbosity. Action granularity: Statements generally perform one action per line, although composed wrapping and delegation calls require unpacking multiple operations. Reading flow: Consistent formatting and logical method grouping make the class easy to scan. Minor distractions include tightly packed imports, an extra blank line, and redundant parentheses in the Runnable wrapper.

Run 3

Code Structure: Clearly separates task-wrapping helpers, submission methods, and lifecycle delegation. Nesting: Shallow overall; only the Runnable wrapper adds a lambda with try/catch. Clarity of intent: Descriptive names, focused Javadoc, and section comments make the wrapping/delegation purpose explicit. Generic nullability annotations and the nested wrapTask(callable(...)).call() expression add some cognitive overhead. Code length: Concise implementations, although required ExecutorService overloads create repetitive boilerplate. Action granularity: Statements generally perform one action per line; composed wrapping and delegation calls remain understandable. Reading flow: Consistent formatting and logical method grouping support natural top-to-bottom reading. Minor distractions include tightly packed imports, a stray blank line, and unnecessary parentheses in the Runnable wrapper.