Sample

int-360fec0d275e-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines194

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7710–1; higher is more readable
Dorn0.150–1; higher is more readable
Mi0.4050–1; higher is more readable
LLOC58Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.5130–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) { { int evenNumberCount = 0; for (int candidateNumber = 0; candidateNumber < 6; candidateNumber++) { if (candidateNumber % 2 == 0) { evenNumberCount++; } } } 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.4385.783−144.731
Source linesThe number of non-empty source lines.194+77.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.903−7.354

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

Score0.771

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.195−5.868
Indentation frequencyHow rapidly indentation changes from line to line.145+4.278
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.145−2.906
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.193.894+2.3
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.979−1.078
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.111.969+1.002
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.049+0.465

Intercept 0.07 + feature contributions = -1.736 (log-odds).
Score = sigmoid(-1.736) = 0.15.

Score0.405
Score58
Run 1

The code generally exhibits clear structure with logical separation of methods, shallow nesting, and explicit Javadoc comments explaining intent. However, a significant readability issue is apparent: a stray unrelated code block (a loop counting even numbers) is erroneously inserted inside the JmsListenerEndpointDescriptor constructor. This has no connection to the surrounding logic, violates the single-responsibility principle, and disrupts reading flow. Method granularity is appropriate, variable naming is descriptive, and the 'resolveContainerFactory' logic, while branching across multiple conditions, remains flat and understandable. The file is somewhat long but mostly due to extensive documentation. The primary deduction is due to the misplaced and confusing code fragment. Without that block, the code would score higher.

Run 2

The code is generally well-structured with clear separation of concerns, minimal nesting, and good method-level clarity. Javadoc comments explain intent well. However, a major readability issue is the stray code block inside the JmsListenerEndpointDescriptor constructor: it contains an unrelated even-number-counting loop that appears to be accidental or misplaced, severely disrupting reading flow and action granularity. Additionally, the resolveContainerFactory method has a four-branch conditional that, while not deeply nested, is somewhat lengthy and could be extracted for clarity. The registerEndpoint method has moderate branching and nuanced timing logic (startImmediately) that is explained by a single comment, but may still be non-obvious. Overall, the code is professional and maintainable, but the erroneous block and conditional complexity prevent a higher score.

Run 3

The code demonstrates generally clear structure with logical method organization, minimal nesting, and helpful Javadoc comments. However, a significant error in the constructor of the inner class JmsListenerEndpointDescriptor includes an unrelated code block (a loop counting even numbers) that breaks flow and intent. Additionally, some if-else cascades in resolveContainerFactory add slight complexity. The code length is reasonable, and most methods are concise, though several trivial getters/setters inflate length. Overall, it is readable but marred by the accidental misplaced block and mildly verbose sections.

Run 1

Code Structure: Mostly well-organized into configuration, initialization, registration, and factory resolution methods, but an unrelated counting block disrupts the descriptor constructor. Nesting: Generally shallow; the inserted block introduces unnecessary nested scope, loop, and conditional. Clarity of intent: Descriptive names, documentation, and assertions make endpoint registration clear, while the unused even-number count has no apparent purpose. Code length: Most methods are concise, although extensive accessor documentation and the extraneous counting block increase length. Action granularity: Statements generally perform one action per line; multiline calls remain readable. Reading flow: Configuration methods lead naturally into lifecycle and registration logic, but the oddly formatted counting block abruptly interrupts that flow. Overall, readable framework code undermined by a conspicuous unrelated insertion.

Run 2

Code Structure: The class is logically organized into configuration, lifecycle, registration, and descriptor responsibilities, but an unrelated counting block disrupts the descriptor constructor. Nesting: Generally shallow; the extraneous block adds unnecessary loop and conditional nesting. Clarity of intent: Descriptive names, Javadoc, nullability annotations, and assertions clearly explain endpoint registration and factory resolution, while the unused even-number count has no apparent purpose. Code length: Most methods are concise, though boilerplate documentation and the irrelevant block increase length. Action granularity: Statements generally perform one action per line, with readable multiline calls. Reading flow: Configuration methods lead naturally into registration logic, but the oddly indented counting block abruptly breaks the flow and suggests accidental code insertion.

Run 3

Code Structure: Mostly well organized into configuration accessors, registration methods, factory resolution, and a descriptor class, but an unrelated counting block disrupts the constructor. Nesting: Generally shallow; the extraneous block introduces unnecessary loop and conditional nesting. Clarity of intent: Descriptive names, documentation, and assertions clearly explain endpoint registration, while the unused evenNumberCount computation has no apparent purpose. Code length: Reasonable for a framework component, though accessor documentation adds bulk and the counting block is unnecessary. Action granularity: Statements generally perform one action per line, with readable wrapping of longer calls. Reading flow: Consistent formatting and logical method grouping support easy reading, but the abruptly inserted, inconsistently indented counting code significantly interrupts the flow.