Sample

int-9ead56ffff6d-I10

Remove about 40% of line-break groups while retaining structure

Matched original source

Lines131

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6430–1; higher is more readable
Dorn0.0460–1; higher is more readable
Mi00–1; higher is more readable
LLOC53Logical lines; fewer is more readable
DeepSeek V4 Pro50–20; mean of three runs
GPT-6.1 Sol120–20; mean of three runs
BTTF0.4250–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.131+52.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.875−7.312

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

Score0.643

Feature contributions

FeatureValueContribution
(log-odds)
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.256.992−7.22
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.132−3.637
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.257+3.342
Indentation frequencyHow rapidly indentation changes from line to line.82+2.099
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.130.86+1.419
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.047+0.486
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = -3.043 (log-odds).
Score = sigmoid(-3.043) = 0.046.

Score0
Score53
Run 1

This code is severely hampered by formatting issues that make it nearly unreadable despite being logically straightforward. Multiple statements are crammed onto single lines, Javadoc comments are interleaved with code rather than placed above methods, and field declarations are run together. These problems violate nearly every readability criterion: action granularity (multiple actions per line), code structure (compressed and chaotic), nesting (if-else chains become hard to track), and reading flow (non-sequential scanning). While the underlying logic is not deeply nested and the method names are clear, the presentation makes it extremely difficult to parse. The code violates standard Java formatting conventions and would require significant reformatting before it could be maintained or reviewed effectively.

Run 2

The code has severe readability issues. The package and import statements are crammed onto single lines, making the header difficult to scan. Critical structural elements like fields, methods, and Javadoc comments are frequently collapsed onto one line, destroying the natural vertical flow. This violates the 'one action per line' principle and makes the code feel tangled. While the core logic (registering endpoints, resolving container factories) is not deeply nested, the inconsistent brace placement and compressed statements within conditional blocks (e.g., in resolveContainerFactory and registerEndpoint) obscure the intent. The 'reading flow' is severely disrupted by the lack of consistent line breaks. Overall, the code requires significant reformatting to meet basic readability standards, despite the underlying structure being conceptually sound.

Run 3

The code suffers from severe formatting issues that significantly impair readability. Multiple statements are crammed onto single lines (e.g., field declarations, setter methods, and Javadoc comments), violating the 'one action per line' principle. The inconsistent placement of comments and braces creates a tangled structure with poor reading flow. While the core logic and class structure are relatively clear, the code length is unnecessarily compressed, making it difficult to scan. The nesting is moderate, and the intent of the registrar is understandable, but the erratic line breaks and merged declarations obscure the logical organization. Proper formatting alone would raise this to a much higher score, as the underlying design is not inherently complex.

Run 1

Code Structure: Responsibilities are logically separated into configuration, registration, factory resolution, and a descriptor class. Nesting: Mostly shallow, with straightforward loops and conditional branches. Clarity of intent: Descriptive names, assertions, and Javadoc clearly explain endpoint registration and factory selection. Code length: Methods are generally concise; documentation adds length but provides useful context. Action granularity: Multiple imports, fields, assignments, and method statements share lines, making individual actions harder to distinguish. Reading flow: Inconsistent brace placement, compressed declarations, comments attached to closing braces, and irregular line breaks disrupt scanning. Overall, the underlying design is readable, but poor formatting significantly reduces accessibility.

Run 2

Code Structure: Logically organized into configuration accessors, registration methods, factory resolution, and a small descriptor class, but compressed formatting obscures those boundaries. Nesting: Shallow loops and conditionals are easy to follow; there is no excessive nesting. Clarity of intent: Descriptive names, Javadoc, assertions, and comments clearly explain endpoint registration and factory fallback behavior. Code length: Methods are generally concise, and documentation is useful, though long signatures and exception text increase visual density. Action granularity: Multiple imports, field declarations, assignments, and method statements share lines, making individual actions harder to distinguish. Reading flow: Inconsistent brace placement, comments attached to closing braces, and methods beginning on documentation-ending lines interrupt scanning. The underlying design is readable, but inconsistent formatting substantially reduces accessibility.

Run 3

Code Structure: Responsibilities are logically separated into configuration, registration, factory resolution, and a descriptor class, but compressed formatting obscures these boundaries. Nesting: Shallow loops and conditionals keep complexity manageable. Clarity of intent: Descriptive names, assertions, and detailed Javadoc clearly explain endpoint registration and factory fallback behavior. Code length: Methods are generally concise; documentation adds useful context, though long signatures and error messages increase visual density. Action granularity: Multiple imports, fields, assignments, and statements share lines, making individual actions harder to scan. Reading flow: The overall method order is sensible, but inconsistent brace placement, comments attached to closing braces, and uneven line breaks repeatedly interrupt reading. The underlying design is readable, while presentation substantially reduces accessibility.