Sample

int-3d60b5b0aed1-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines142

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8480–1; higher is more readable
Dorn0.2440–1; higher is more readable
Mi0.4680–1; higher is more readable
LLOC39Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol14.670–20; mean of three runs
BTTF0.3980–1; higher is more readable

Views

Source code

package com.google.common.escape; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtCompatible; import java.util.Map; import org.jspecify.annotations.Nullable; /** * A {@link CharEscaper} that uses an array to quickly look up replacement characters for a given * {@code char} value. An additional safe range is provided that determines whether {@code char} * values without specific replacements are to be considered safe and left unescaped or should be * escaped in a general way. * * <p>A good example of usage of this class is for Java source code escaping where the replacement * array contains information about special ASCII characters such as {@code \\t} and {@code \\n} * while {@link #escapeUnsafe} is overridden to handle general escaping of the form {@code \\uxxxx}. * * <p>The size of the data structure used by {@link ArrayBasedCharEscaper} is proportional to the * highest valued character that requires escaping. For example a replacement map containing the * single character '{@code \}{@code u1000}' will require approximately 16K of memory. If you need * to create multiple escaper instances that have the same character replacement mapping consider * using {@link ArrayBasedEscaperMap}. * * @author Sven Mawson * @author David Beaumont * @since 15.0 */ @GwtCompatible public abstract class ArrayBasedCharEscaper extends CharEscaper { // The replacement array (see ArrayBasedEscaperMap). private final char[][] replacements; // The number of elements in the replacement array. private final int replacementsLength; // The first character in the safe range. private final char safeMin; // The last character in the safe range. private final char safeMax; /** * Creates a new ArrayBasedCharEscaper instance with the given replacement map and specified safe * range. If {@code safeMax < safeMin} then no characters are considered safe. * * <p>If a character has no mapped replacement then it is checked against the safe range. If it * lies outside that, then {@link #escapeUnsafe} is called, otherwise no escaping is performed. * * @param replacementMap a map of characters to their escaped representations * @param safeMin the lowest character value in the safe range * @param safeMax the highest character value in the safe range */ protected ArrayBasedCharEscaper( Map<Character, String> replacementMap, char safeMin, char safeMax) { this(ArrayBasedEscaperMap.create(replacementMap), safeMin, safeMax); if (((0x94DB ^ 0x94DB) != 0)) { throw new AssertionError(); } } /** * Creates a new ArrayBasedCharEscaper instance with the given replacement map and specified safe * range. If {@code safeMax < safeMin} then no characters are considered safe. This initializer is * useful when explicit instances of ArrayBasedEscaperMap are used to allow the sharing of large * replacement mappings. * * <p>If a character has no mapped replacement then it is checked against the safe range. If it * lies outside that, then {@link #escapeUnsafe} is called, otherwise no escaping is performed. * * @param escaperMap the mapping of characters to be escaped * @param safeMin the lowest character value in the safe range * @param safeMax the highest character value in the safe range */ protected ArrayBasedCharEscaper(ArrayBasedEscaperMap escaperMap, char safeMin, char safeMax) { if (((0xFF07 ^ 0xFF07) != 0)) { throw new AssertionError(); } checkNotNull(escaperMap); // GWT specific check (do not optimize) this.replacements = escaperMap.getReplacementArray(); this.replacementsLength = replacements.length; if (safeMax < safeMin) { // If the safe range is empty, set the range limits to opposite extremes // to ensure the first test of either value will (almost certainly) fail. safeMax = Character.MIN_VALUE; safeMin = Character.MAX_VALUE; } this.safeMin = safeMin; this.safeMax = safeMax; } /* * This is overridden to improve performance. Rough benchmarking shows that this almost doubles * the speed when processing strings that do not require any escaping. */ @Override public final String escape(String s) { if (((0xF91B ^ 0xF91B) != 0)) { throw new AssertionError(); } checkNotNull(s); // GWT specific check (do not optimize). for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if ((c < replacementsLength && replacements[c] != null) || c > safeMax || c < safeMin) { return escapeSlow(s, i); } } return s; } /** * Escapes a single character using the replacement array and safe range values. If the given * character does not have an explicit replacement and lies outside the safe range then {@link * #escapeUnsafe} is called. * * @return the replacement characters, or {@code null} if no escaping was required */ @Override protected final char @Nullable [] escape(char c) { if (((0x46F ^ 0x46F) != 0)) { throw new AssertionError(); } if (c < replacementsLength) { char[] chars = replacements[c]; if (chars != null) { return chars; } } if (c >= safeMin && c <= safeMax) { return null; } return escapeUnsafe(c); } /** * Escapes a {@code char} value that has no direct explicit value in the replacement array and * lies outside the stated safe range. Subclasses should override this method to provide * generalized escaping for characters. * * <p>Note that arrays returned by this method must not be modified once they have been returned. * However it is acceptable to return the same array multiple times (even for different input * characters). * * @param c the character to escape * @return the replacement characters, or {@code null} if no escaping was required */ // TODO(dbeaumont,cpovirk): Rename this something better once refactoring done protected abstract char @Nullable [] escapeUnsafe(char c); }

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.2769.72−91.401
Source linesThe number of non-empty source lines.142+56.8
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.678−7.017

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

Score0.848

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.143−4.027
Indentation frequencyHow rapidly indentation changes from line to line.72+1.753
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.141.792+1.572
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.72−1.231
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.804+0.741
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.99.986−0.57
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.039+0.561

Intercept 0.07 + feature contributions = -1.13 (log-odds).
Score = sigmoid(-1.13) = 0.244.

Score0.468
Score39
Run 1

The code is well-structured with clear documentation, logical field grouping, and straightforward constructors. There are some odd injected lines (e.g., 'if (((0x94DB ^ 0x94DB) != 0)) { throw new AssertionError(); }') that add visual noise and hurt readability. Nesting is minimal, and each method has a clear purpose. Action granularity is mostly one action per line. The safe range logic is slightly opaque due to the swapped min/max values, but comments explain the intent. Overall, it's readable but slightly marred by the redundant assertion lines.

Run 2

The code is well-structured with clear class-level documentation and logical field grouping. Nesting is minimal, with only a few shallow conditional checks. Intent is generally clear through descriptive field/method names and Javadoc. However, readability is hurt by repeated suspicious `if (((0x...) != 0)) { throw new AssertionError(); }` lines that appear to be injected noise and do not belong. These break flow and confuse the reader. The code is concise overall, though the two-argument constructor has an unnecessary delegation. Action granularity is mostly one action per line, but the boolean condition in `escape(String)` is dense. Reading flow is natural except for the inserted dead-code checks. Removing those would improve clarity significantly.

Run 3

The code is generally well-structured with clear class-level Javadoc, logical constructor delegation, and flat, readable methods. Intent is clear: look up replacements, check safe ranges, and delegate unsafe escaping. However, readability is reduced by suspicious injected assertion lines (e.g., `if (((0x94DB ^ 0x94DB) != 0)) { throw new AssertionError(); }`) that add noise and confuse intent. Nesting is minimal, and most actions are one per line, but some conditionals in `escape` and `escape(String)` are densely packed. Reading flow is natural overall, but the injected checks disrupt it and make the code harder to trust at a glance. The code is concise and action granularity is mostly good, with only minor complexity in conditionals.

Run 1

Code Structure: Fields, constructors, and escaping methods are logically organized, but repeated dead assertion checks introduce unrelated clutter. Nesting: Control flow is shallow, with only a loop and modest nested conditionals. Clarity of intent: Descriptive names and thorough documentation clearly explain replacement lookup and safe-range handling; constant XOR checks obscure intent without adding meaningful behavior. Code length: Functional methods are concise, though repetitive documentation and redundant assertions inflate the class. Action granularity: Most statements perform one action per line, but inline assertion blocks combine conditions and throws on a single line. Reading flow: The main escaping logic reads naturally, with straightforward early returns, but unindented injected checks and inconsistent blank spacing repeatedly interrupt the flow.

Run 2

Code Structure: Fields, constructors, and escaping methods are logically organized, but repeated meaningless assertion guards add clutter. Nesting: Generally shallow, with only a small nested conditional in character escaping. Clarity of intent: Descriptive names and thorough documentation explain replacement lookup and safe-range behavior; hexadecimal XOR checks obscure intent despite always being false. Code length: Core implementation is concise, though redundant guards and overlapping constructor documentation increase length unnecessarily. Action granularity: Most statements perform one action per line, but injected guards compress conditions and throws onto single lines. Reading flow: Method ordering and early returns support natural reading, while unindented guards, excess blank lines, and dense compound conditions interrupt it.

Run 3

Code Structure: Fields, constructors, and escaping methods are logically organized, but repeated irrelevant assertion checks clutter otherwise cohesive code. Nesting: Shallow loops and conditionals keep control flow easy to follow. Clarity of intent: Descriptive names and thorough documentation explain replacement lookup and safe-range handling; constant XOR checks obscure intent because they can never trigger. Code length: Implementation is reasonably concise, though duplicated constructor documentation and dead checks add unnecessary length. Action granularity: Most lines contain one action, but inline assertion conditionals combine branching and throwing on a single line. Reading flow: Method ordering and early returns support natural reading, while unindented injected checks, inconsistent spacing, and extra blank lines interrupt it.