Sample

int-8f10810af5a8-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines185

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.780–1; higher is more readable
Dorn0.8130–1; higher is more readable
Mi0.4050–1; higher is more readable
LLOC53Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.5950–1; higher is more readable

Views

Source code

package org.springframework.jms.config; import java.util.ArrayList; import java.util.List; import org.jspecify.annotations.Nullable; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; import org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory; import org.springframework.util.Assert; /** * Helper bean for registering {@link JmsListenerEndpoint} with a {@link JmsListenerEndpointRegistry}. * * @author Stephane Nicoll * @author Juergen Hoeller * @since 4.1 * @see org.springframework.jms.annotation.JmsListenerConfigurer */ public class JmsListenerEndpointRegistrar implements BeanFactoryAware, InitializingBean { private @Nullable JmsListenerEndpointRegistry endpointRegistry; private @Nullable MessageHandlerMethodFactory messageHandlerMethodFactory; private @Nullable JmsListenerContainerFactory<?> containerFactory; private @Nullable String containerFactoryBeanName; private @Nullable BeanFactory beanFactory; private final List<JmsListenerEndpointDescriptor> endpointDescriptors = new ArrayList<>(); private boolean startImmediately; /** * Set the {@link JmsListenerEndpointRegistry} instance to use. */ public void setEndpointRegistry(@Nullable JmsListenerEndpointRegistry endpointRegistry) { this.endpointRegistry = endpointRegistry; } /** * Return the {@link JmsListenerEndpointRegistry} instance for this * registrar, may be {@code null}. */ public @Nullable JmsListenerEndpointRegistry getEndpointRegistry() { return this.endpointRegistry; } /** * Set the {@link MessageHandlerMethodFactory} to use to configure the message * listener responsible to serve an endpoint detected by this processor. * <p>By default, {@link DefaultMessageHandlerMethodFactory} is used and it * can be configured further to support additional method arguments * or to customize conversion and validation support. See * {@link DefaultMessageHandlerMethodFactory} javadoc for more details. */ public void setMessageHandlerMethodFactory(@Nullable MessageHandlerMethodFactory messageHandlerMethodFactory) { this.messageHandlerMethodFactory = messageHandlerMethodFactory; } /** * Return the custom {@link MessageHandlerMethodFactory} to use, if any. */ public @Nullable MessageHandlerMethodFactory getMessageHandlerMethodFactory() { return this.messageHandlerMethodFactory; } /** * Set the {@link JmsListenerContainerFactory} to use in case a {@link JmsListenerEndpoint} * is registered with a {@code null} container factory. * <p>Alternatively, the bean name of the {@link JmsListenerContainerFactory} to use * can be specified for a lazy lookup, see {@link #setContainerFactoryBeanName}. */ public void setContainerFactory(JmsListenerContainerFactory<?> containerFactory) { this.containerFactory = containerFactory; } /** * Set the bean name of the {@link JmsListenerContainerFactory} to use in case * a {@link JmsListenerEndpoint} is registered with a {@code null} container factory. * Alternatively, the container factory instance can be registered directly: * see {@link #setContainerFactory(JmsListenerContainerFactory)}. * @see #setBeanFactory */ public void setContainerFactoryBeanName(String containerFactoryBeanName) { this.containerFactoryBeanName = containerFactoryBeanName; } /** * A {@link BeanFactory} only needs to be available in conjunction with * {@link #setContainerFactoryBeanName}. */ @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } @Override public void afterPropertiesSet() { registerAllEndpoints(); } protected void registerAllEndpoints() { Assert.state(this.endpointRegistry != null, "No JmsListenerEndpointRegistry set"); for (JmsListenerEndpointDescriptor descriptor : this.endpointDescriptors) { this.endpointRegistry.registerListenerContainer( descriptor.endpoint, resolveContainerFactory(descriptor)); } this.startImmediately = true; // trigger immediate startup } private JmsListenerContainerFactory<?> resolveContainerFactory(JmsListenerEndpointDescriptor descriptor) { if (descriptor.containerFactory != null) { return descriptor.containerFactory; } else if (this.containerFactory != null) { return this.containerFactory; } else if (this.containerFactoryBeanName != null) { Assert.state(this.beanFactory != null, "BeanFactory must be set to obtain container factory by bean name"); // Consider changing this if live change of the factory is required... this.containerFactory = this.beanFactory.getBean( this.containerFactoryBeanName, JmsListenerContainerFactory.class); return this.containerFactory; } else { throw new IllegalStateException("Could not resolve the " + JmsListenerContainerFactory.class.getSimpleName() + " to use for [" + descriptor.endpoint + "] no factory was given and no default is set."); } } /** * Register a new {@link JmsListenerEndpoint} alongside the * {@link JmsListenerContainerFactory} to use to create the underlying container. * <p>The {@code factory} may be {@code null} if the default factory should be * used for the supplied endpoint. */ public void registerEndpoint(JmsListenerEndpoint endpoint, @Nullable JmsListenerContainerFactory<?> factory) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.hasText(endpoint.getId(), "Endpoint id must be set"); // Factory may be null, we defer the resolution right before actually creating the container JmsListenerEndpointDescriptor descriptor = new JmsListenerEndpointDescriptor(endpoint, factory); if (this.startImmediately) { // register and start immediately Assert.state(this.endpointRegistry != null, "No JmsListenerEndpointRegistry set"); this.endpointRegistry.registerListenerContainer(descriptor.endpoint, resolveContainerFactory(descriptor), true); } else { this.endpointDescriptors.add(descriptor); } } /** * Register a new {@link JmsListenerEndpoint} using the default * {@link JmsListenerContainerFactory} to create the underlying container. * @see #setContainerFactory(JmsListenerContainerFactory) * @see #registerEndpoint(JmsListenerEndpoint, JmsListenerContainerFactory) */ public void registerEndpoint(JmsListenerEndpoint endpoint) { registerEndpoint(endpoint, null); } private static class JmsListenerEndpointDescriptor { public final JmsListenerEndpoint endpoint; public final @Nullable JmsListenerContainerFactory<?> containerFactory; public JmsListenerEndpointDescriptor(JmsListenerEndpoint endpoint, @Nullable JmsListenerContainerFactory<?> containerFactory) { this.endpoint = endpoint; this.containerFactory = containerFactory; } } }

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.4066.04−134.179
Source linesThe number of non-empty source lines.185+74
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.891−7.336

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

Score0.78

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.186−5.549
Indentation frequencyHow rapidly indentation changes from line to line.136+3.967
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.184.85+2.174
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.111.962−1.077
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.111.962+1.002
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.047+0.488
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 1.472 (log-odds).
Score = sigmoid(1.472) = 0.813.

Score0.405
Score53
Run 1

The code is well-structured with clear separation of concerns: configuration, registration, and descriptor storage. The class has a single responsibility and uses clear, descriptive method names. Nesting is minimal—only one level in the registerEndpoint and resolveContainerFactory methods. Javadoc comments effectively explain non-obvious behavior (like deferred factory resolution). The code is concise despite its length, with each method doing one clear thing. However, slightly reduced readability comes from some methods having multiple responsibilities (resolveContainerFactory has a factory caching side effect), and the registerAllEndpoints method triggers a side effect (setting startImmediately) that might not be obvious at first glance. The field ordering and grouping is logical. The use of separate descriptor class adds clarity. Overall, the code follows clean, maintainable patterns typical of well-written Spring configuration classes.

Run 2

The code is well-structured and follows clear Spring patterns. Class responsibilities are focused on endpoint registration. It maintains good logical organization with fields, setters, lifecycle methods, and private helpers grouped together. Nesting is minimal: the deepest logic is a four-branch conditional in resolveContainerFactory, with no loops inside conditionals. Intent is generally clear—method names like registerAllEndpoints and resolveContainerFactory convey purpose. Javadoc and inline comments explain non-obvious behavior such as deferred factory resolution and immediate startup. Code length is appropriate for the tasks handled, though some Javadoc blocks are verbose. Most lines perform a single action, except a couple of multi-line method calls that remain readable. Reading flow is natural, moving from configuration setters to registration logic. Deductions stem from minor verbosity in Javadocs, slightly long conditional chain in resolveContainerFactory, and the startImmediately flag requiring careful tracing across methods to understand state changes.

Run 3

The code demonstrates excellent readability through clear structure, logical organization, and consistent formatting. It follows Spring's established conventions with well-organized fields, constructor, and methods. The nesting is minimal, with only one level in the resolveContainerFactory method and simple conditional blocks elsewhere. Intent is clearly communicated through descriptive method names like 'resolveContainerFactory' and 'registerAllEndpoints'. The code is concise without being overly compact, maintaining appropriate spacing and line breaks. Action granularity is well-managed, with one primary action per statement even when methods span multiple lines for parameter alignment. Reading flow is natural, progressing from setup methods to core registration logic. Javadoc comments provide necessary context without being excessive. Minor deductions come from public fields in the inner descriptor class and slightly longer method signatures, but these are consistent with framework design patterns.

Run 1

Code Structure: Configuration accessors, lifecycle initialization, factory resolution, endpoint registration, and the descriptor class are logically separated. Nesting: Control flow remains shallow, with straightforward conditionals and a single loop. Clarity of intent: Descriptive names, Javadoc, nullability annotations, and assertions clearly communicate responsibilities and prerequisites; the startImmediately lifecycle flag requires some cross-method reading. Code length: Implementation methods are concise, although extensive documentation and accessor boilerplate increase the overall reading volume. Action granularity: Statements generally perform one action per line, and wrapped calls remain easy to follow. Reading flow: The progression from configuration to initialization and registration is natural. Minor friction comes from the factory-resolution else-if chain, its caching side effect, and the need to connect deferred registration with lifecycle initialization.

Run 2

Code Structure: Well-organized fields, configuration methods, lifecycle handling, registration logic, and a small descriptor class separate responsibilities clearly. Nesting: Shallow loops and conditionals keep control flow easy to follow; factory resolution uses a straightforward fallback chain. Clarity of intent: Descriptive names, explicit assertions, nullability annotations, and useful Javadoc clearly communicate behavior. The state-dependent deferred versus immediate registration requires some cross-method understanding. Code length: Implementation methods are concise, though extensive documentation and accessor boilerplate increase overall length. Action granularity: Statements generally perform one action each, with sensible wrapping of longer calls. Reading flow: Configuration naturally precedes initialization and registration, with consistent formatting. Minor distractions include repeated registry assertions and an informal factory-caching comment.

Run 3

Code Structure: Well-organized fields, configuration methods, lifecycle handling, registration logic, and a small descriptor class separate responsibilities clearly. Nesting: Shallow loops and conditionals keep control flow easy to follow. Clarity of intent: Descriptive names, nullability annotations, assertions, and Javadoc explain registration behavior and factory-resolution precedence. Code length: Implementation methods are concise, although extensive documentation and routine accessors increase overall length. Action granularity: Statements generally perform one action each; wrapped calls remain readable. Reading flow: Configuration leads naturally into initialization and registration, with factory resolution isolated in a helper. Minor drawbacks include the state-dependent deferred versus immediate registration behavior, the cached factory lookup side effect, and verbose type names. These require some attention but do not substantially hinder readability.