Sample

int-440989a2fa4e-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines171

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5930–1; higher is more readable
Dorn0.0430–1; higher is more readable
Mi0.6850–1; higher is more readable
LLOC56Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.4590–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; 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() { } @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), 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.171+68.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.5.101−7.652

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

Score0.593

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.171+5.178
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.172−5.054
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.171−3.503
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.170.832+1.978
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.105.948−0.822
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.111−0.14

Intercept 0.07 + feature contributions = -3.098 (log-odds).
Score = sigmoid(-3.098) = 0.043.

Score0.685
Score56
Run 1

The code is highly readable and follows clear structural patterns. The class has a single responsibility: making HttpHeaders read-only. Methods are short, flat, and use early returns in the caching checks, avoiding deep nesting. Intent is explicit—mutating methods throw UnsupportedOperationException, while read methods return unmodifiable views. The use of annotations and whitespace improves clarity. Action granularity is mostly one action per line, though the headerSet() method has a slightly complex stream chain that could be simplified for readability. The forEach method contains a ternary that is understandable but slightly dense. Overall, the code is concise, well-organized, and follows a natural reading flow typical of Spring Framework style.

Run 2

The code is highly readable with clear structure and purpose. It follows a consistent pattern: read-only overrides throw UnsupportedOperationException while getters return unmodifiable wrappers. The class is flat with minimal nesting, using simple if-else blocks for caching. Method names clearly communicate intent (clearContentHeaders, toSingleValueMap, etc.). The code is concise without unnecessary verbosity, though the headerSet() method could benefit from being split for clarity. The forEach method has slightly higher complexity with a conditional expression in one line, but still remains one action per line overall. Reading flow is natural, grouping related methods together and preserving the original HttpHeaders method order. The only minor drawback is the excessive blank lines in the imports section and the somewhat dense headerSet() stream operation. Overall, this is excellent production-quality code that balances immutability requirements with readability.

Run 3

The code is highly readable due to its clear structure, consistent formatting, and straightforward intent. Each method has a single responsibility, and the class purpose—providing an immutable view of HTTP headers—is evident. Nesting is minimal, with simple if-else blocks for caching and no deeply indented logic. The use of descriptive method names and standard Java collections aligns with typical readability expectations. While some methods (e.g., headerSet) use streams with multiple operations, the formatting keeps them understandable. The repetition of UnsupportedOperationException is intentional and clear for immutability. Overall, the code is concise, well-organized, and easy to follow, with only minor verbosity in deprecated overrides preventing a perfect score.

Run 1

Code Structure: Small, focused overrides logically implement a read-only headers wrapper, though accessors and mutators are somewhat interspersed. Nesting: Mostly flat, with only simple conditionals and one loop; the collector expression is slightly harder to scan. Clarity of intent: Descriptive names, unmodifiable wrappers, and consistent exceptions clearly communicate the purpose, but the empty clearContentHeaders override lacks an explanation. Code length: Reasonably concise given the required overrides, although repeated exception methods and excessive blank lines add visual bulk. Action granularity: Statements generally perform one action per line; stream chaining combines several transformations but remains manageable. Reading flow: Consistent formatting and straightforward methods support natural reading, while unnecessary else blocks after returns, uneven whitespace, and the dense headerSet pipeline introduce minor friction.

Run 2

Code Structure: The class is logically organized around read-only header access and blocked mutations, though related read and mutation methods could be grouped more consistently. Nesting: Mostly flat methods with only shallow conditionals and one loop; the collector expression is somewhat denser. Clarity of intent: The class name, descriptive methods, and unmodifiable wrappers communicate purpose clearly, but the unexplained empty clearContentHeaders override is ambiguous. Code length: Most methods are concise; repeated exception-throwing overrides are understandable API boilerplate, while excessive blank lines add unnecessary length. Action granularity: Statements generally perform one action per line, although stream chaining and the conditional argument in forEach require more parsing. Reading flow: Consistent formatting and override annotations make scanning easy, but scattered method categories, redundant else blocks after returns, and the compact headerSet pipeline slightly interrupt the flow.

Run 3

Code Structure: Clearly organized as a read-only HttpHeaders subclass, although read accessors and mutation overrides could be grouped more consistently. Nesting: Shallow conditionals and a single loop make control flow easy to follow; the headerSet collector is somewhat denser. Clarity of intent: Descriptive names, overrides, and unmodifiable wrappers communicate the purpose well, but the unexplained empty clearContentHeaders method is ambiguous. Code length: Most methods are concise; repeated exception-throwing overrides are understandable API boilerplate, while excessive blank lines add unnecessary length. Action granularity: Statements generally perform one action per line, with some complexity concentrated in chained stream operations. Reading flow: Consistent formatting and predictable methods support natural reading, though redundant else branches after returns, uneven spacing, and interspersed method categories slightly disrupt it.