Sample

int-c573c67d6dcd-I10

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

Matched original source

Lines109

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.4760–1; higher is more readable
Dorn0.0290–1; higher is more readable
Mi0.0070–1; higher is more readable
LLOC56Logical lines; fewer is more readable
DeepSeek V4 Pro4.670–20; mean of three runs
GPT-6.1 Sol110–20; mean of three runs
BTTF0.2970–1; higher is more readable

Views

Source code

package org.springframework.http; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.function.BiConsumer; import java.util.stream.Collectors; import org.jspecify.annotations.Nullable; import org.springframework.util.CollectionUtils; import org.springframework.util.MultiValueMap; /** * {@code HttpHeaders} variant that can only be read, not written to. * * <p>This caches the parsed representations of the "Accept" and "Content-Type" * headers and will get out of sync with the backing map if it is mutated at runtime. * * @author Brian Clozel * @author Sam Brannen * @since 5.1.1 */ class ReadOnlyHttpHeaders extends HttpHeaders { private static final long serialVersionUID = -8578554704772377436L; private @Nullable MediaType cachedContentType; @SuppressWarnings("serial") private @Nullable List<MediaType> cachedAccept; ReadOnlyHttpHeaders(MultiValueMap<String, String> headers) { super(headers); } @Override public @Nullable MediaType getContentType() { if (this.cachedContentType != null) { return this.cachedContentType; } else { MediaType contentType = super.getContentType(); this.cachedContentType = contentType; return contentType; } } @Override public List<MediaType> getAccept() { if (this.cachedAccept != null) { return this.cachedAccept; } else { List<MediaType> accept = super.getAccept(); this.cachedAccept = accept; return accept; } } @Override public void clearContentHeaders() { // No-op. } @Override public @Nullable List<String> get(String headerName) { List<String> values = this.headers.get(headerName); return (values != null ? Collections.unmodifiableList(values) : null); } @Override public void add(String headerName, @Nullable String headerValue) { throw new UnsupportedOperationException(); } @Override public void addAll(String key, List<? extends String> headerValues) { throw new UnsupportedOperationException(); } @Override public void addAll(HttpHeaders values) { throw new UnsupportedOperationException(); } @Override public void set(String headerName, @Nullable String headerValue) { throw new UnsupportedOperationException(); } @Override public void setAll(Map<String, String> values) { throw new UnsupportedOperationException(); } @Override public Map<String, String> toSingleValueMap() { return Collections.unmodifiableMap(this.headers.toSingleValueMap()); } @SuppressWarnings("removal") @Override @Deprecated(since = "7.0", forRemoval = true) public Map<String, String> asSingleValueMap() { return Collections.unmodifiableMap(this.headers.asSingleValueMap()); } @SuppressWarnings("removal") @Override @Deprecated(since = "7.0", forRemoval = true) public MultiValueMap<String, String> asMultiValueMap() { return CollectionUtils.unmodifiableMultiValueMap(this.headers); } @Override public Set<String> headerNames() { return Collections.unmodifiableSet(super.headerNames()); } @Override public List<String> put(String key, List<String> value) { throw new UnsupportedOperationException(); } @Override public @Nullable List<String> putIfAbsent(String headerName, List<String> headerValues) { throw new UnsupportedOperationException(); } @Override public void putAll(@Nullable HttpHeaders values) { throw new UnsupportedOperationException(); } @Override public void putAll(Map<? extends String, ? extends List<String>> headers) { throw new UnsupportedOperationException(); } @Override public List<String> remove(String key) { throw new UnsupportedOperationException(); } @Override public void clear() { throw new UnsupportedOperationException(); } @Override public Set<Entry<String, List<String>>> headerSet() { return super.headerSet().stream().map(SimpleImmutableEntry::new) .collect(Collectors.collectingAndThen( Collectors.toCollection(LinkedHashSet::new), // Retain original ordering of entries Collections::unmodifiableSet)); } @Override public void forEach(BiConsumer<? super String, ? super List<String>> action) { for (String name : this.headers.keySet()) { List<String> values = this.headers.get(name); action.accept(name, (values != null ? Collections.unmodifiableList(values) : Collections.emptyList())); } } }

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.5431.521−179.24
Source linesThe number of non-empty source lines.109+43.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.5.1−7.65

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

Score0.476

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.206.964−5.101
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.110−2.858
Indentation frequencyHow rapidly indentation changes from line to line.97+2.618
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.207+2.535
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.98−1.828
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.108.745+1.11
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.102−0.05

Intercept 0.07 + feature contributions = -3.504 (log-odds).
Score = sigmoid(-3.504) = 0.029.

Score0.007
Score56
Run 1

The code suffers from severe readability issues. The package and imports are compressed onto single lines, making them difficult to scan. Multiple method declarations are crammed together on the same lines, violating the 'one action per line' principle and disrupting reading flow. Nesting is inconsistent, with some methods using proper if-else blocks and others using inline conditionals. The class structure is logical (caching, unmodifiable wrappers), but the inconsistent formatting obscures intent. While the individual methods are relatively simple, the erratic line breaks and compressed declarations make the code feel tangled and unprofessional. The code length is acceptable, but the formatting choices dramatically reduce clarity.

Run 2

The code is a simple read-only wrapper over HttpHeaders, but readability suffers significantly from inconsistent formatting and compressed statements. Many method signatures and bodies are crammed onto single lines, making the code visually chaotic and harder to scan. Nesting is mostly flat, which is good, but the flow is broken by irregular line breaks and inconsistent brace placement. The intent is generally clear—most methods throw UnsupportedOperationException—but the presentation obscures it. Action granularity is poor in several places, with multiple statements or branched logic packed into one line (e.g., get(), forEach()). Imports are also compressed onto one line, further reducing clarity. The class itself is straightforward, but the lack of consistent formatting and occasional multi-action lines make it harder to read than necessary.

Run 3

This code is extremely difficult to read due to severe formatting issues. The imports are on a single line, multiple fields are declared on one line, and method signatures are run together with multiple overrides per line. There's no consistent indentation or spacing. The code violates almost every readability principle: it has multiple actions per line, no visual separation between methods, inconsistent brace placement, and no breathing room around operators. While the logic itself is straightforward (read-only wrapper for HTTP headers), the presentation makes it nearly unreadable. A developer would need to reformat the entire file to understand its structure. The class has a clear purpose and relatively simple logic, but the formatting completely obscures this. Even basic navigation is challenging as methods blur together, making it hard to identify where one method ends and another begins.

Run 1

Code Structure: The class logically groups cached getters, read-only views, and rejected mutations, but compressed method boundaries obscure that organization. Nesting: Mostly shallow, with simple conditionals and one loop; the collector expression adds modest complexity. Clarity of intent: The class name, documentation, descriptive identifiers, and repeated UnsupportedOperationException calls clearly communicate read-only behavior. Code length: Reasonably concise for the required overrides, although repetitive mutation methods add scanning overhead. Action granularity: Multiple imports, declarations, annotations, statements, and even methods share lines, substantially reducing readability. Reading flow: Inconsistent spacing, brace placement, and abrupt transitions between methods disrupt an otherwise straightforward implementation.

Run 2

Code Structure: The class logically groups read-only header behavior, caching, and prohibited mutations, but compressed method boundaries obscure organization. Nesting: Mostly shallow, with simple conditionals and one loop; the collector expression adds modest complexity. Clarity of intent: Descriptive names, documentation, unmodifiable wrappers, and consistent exceptions clearly communicate purpose. Code length: Methods are concise, and repetitive overrides are appropriate to the interface, though unnecessary else blocks add minor verbosity. Action granularity: Multiple imports, declarations, annotations, statements, and even methods share lines, making individual actions difficult to distinguish. Reading flow: Inconsistent spacing, abrupt transitions, and closing braces joined to subsequent declarations significantly disrupt scanning. Overall, understandable logic is undermined by poor formatting.

Run 3

Code Structure: The class logically groups read-only header behavior, caching, and rejected mutations, but compressed method boundaries obscure organization. Nesting: Generally shallow, with simple conditionals and one loop; the collector expression is moderately complex. Clarity of intent: Descriptive names, overrides, and class documentation clearly communicate the purpose and caching limitation. Code length: Methods are short and mostly necessary; repeated exception-throwing overrides add justified boilerplate. Action granularity: Multiple imports, declarations, statements, annotations, and even methods share lines, making individual actions harder to distinguish. Reading flow: Inconsistent spacing, crowded braces, and annotations attached to preceding methods repeatedly interrupt scanning. Overall, straightforward logic and meaningful naming preserve readability, but poor formatting substantially reduces it.