Sample

int-35c843334bc9-I04

Replace method, parameter, and local names with deterministic ProGuard-style short identifiers

Matched original source

Lines134

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8910–1; higher is more readable
Dorn0.2730–1; higher is more readable
Mi0.5080–1; higher is more readable
LLOC31Logical lines; fewer is more readable
DeepSeek V4 Pro100–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.5420–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> a, char b, char d) { this(ArrayBasedEscaperMap.create(a), b, d); } /** * 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 e, char f, char g) { checkNotNull(e); // GWT specific check (do not optimize) this.replacements = e.getReplacementArray(); this.replacementsLength = replacements.length; if (g < f) { // 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. g = Character.MIN_VALUE; f = Character.MAX_VALUE; } this.safeMin = f; this.safeMax = g; } /* * 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 a(String h) { checkNotNull(h); // GWT specific check (do not optimize). for (int i = 0; i < h.length(); i++) { char c = h.charAt(i); if ((c < replacementsLength && replacements[c] != null) || c > safeMax || c < safeMin) { return escapeSlow(h, i); } } return h; } /** * 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 [] a(char c) { if (c < replacementsLength) { char[] j = replacements[c]; if (j != null) { return j; } } if (c >= safeMin && c <= safeMax) { return null; } return b(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 [] b(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.2155.893−71.144
Source linesThe number of non-empty source lines.134+53.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.613−6.919

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

Score0.891

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.135−3.744
Indentation frequencyHow rapidly indentation changes from line to line.64+1.477
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.133.802+1.46
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.64−1.048
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.96.296+0.749
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.033+0.624
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.993−0.57

Intercept 0.07 + feature contributions = -0.981 (log-odds).
Score = sigmoid(-0.981) = 0.273.

Score0.508
Score31
Run 1

The code has reasonably clear documentation and logical structure, but parameter names like 'a', 'b', 'd', 'e', 'f', 'g', and method names like 'a(String h)' or 'b(char c)' severely undermine readability. These non-descriptive names obscure intent despite the Javadoc. The overall organization is clean, with flat nesting and one action per line, but the generic naming makes the reading flow disjointed. The safe-range logic is understandable but would benefit from clearer variable naming. The class is concise overall, but the obfuscated identifiers require mental mapping that increases cognitive load.

Run 2

The code has good structural elements like clear field declarations, useful comments, and logical separation of methods. However, readability is severely undermined by the use of meaningless parameter and method names (a, b, d, f, g, h, c, j). The public API method names have been obfuscated, obscuring intent. The constructor parameter names do not match the documented parameters (replacementMap, safeMin, safeMax), creating confusion. Several lines combine multiple actions, such as the condition in escape(String) which mixes array lookup, null check, and range comparison in one expression. The nested logic in escape(char) adds some complexity but remains manageable. While the class-level Javadoc is excellent, the mismatch between documentation and actual identifiers breaks reading flow and clarity of intent. The code structure is reasonable but the naming choices and action density drop the score significantly.

Run 3

The code has clear documentation and logical structure, but variable names like 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', and 'j' completely obscure intent. Method names 'a', 'b', and 'escapeSlow' are unhelpful. The one-letter parameter names make the constructor and methods extremely hard to understand without reading the doc comments carefully. Comments are helpful but cannot compensate for poor naming. Nesting is reasonable and actions are mostly one per line, keeping structure flat. However, the use of renamed identifiers (likely stripped/deobfuscated) destroys clarity and readability. Overall, the code structure is okay but readability is severely hurt by ambiguous naming.

Run 1

Code Structure: Fields, constructors, and escaping methods are logically organized with clear separation of responsibilities. Nesting: Shallow loops and conditionals, aided by early returns, keep control flow manageable. Clarity of intent: Descriptive field names and extensive documentation explain the algorithm, but opaque names such as a, b, and j obscure method and parameter roles. Documentation references escapeUnsafe and parameter names that do not match the declarations, making navigation confusing. Code length: Implementation is concise; documentation is useful but somewhat repetitive. Action granularity: Nearly every statement performs one action, with no compressed multi-statement lines. Reading flow: Constructor delegation and sequential replacement/safety checks create a natural progression, although inconsistent naming, mismatched documentation, and the compound scanning condition require extra interpretation.

Run 2

Code Structure: Constructors, fields, and escaping methods are logically organized with clear separation of responsibilities. Nesting: Control flow is shallow, with at most two nested conditionals and helpful early returns. Clarity of intent: Descriptive field names and extensive documentation explain the algorithm, but arbitrary names such as a, b, e, and j obscure parameters and methods. Documentation references escapeUnsafe and parameter names that do not match the declarations, further reducing clarity. Code length: Executable code is concise, although repeated constructor documentation and obvious field comments add bulk. Action granularity: Statements generally perform one action per line; the compound escape condition is dense but manageable. Reading flow: Initialization followed by string scanning and character handling provides a natural progression, but ambiguous method names and inconsistent documentation interrupt comprehension.

Run 3

Code Structure: Fields, constructors, and escaping methods are logically organized with clear separation of responsibilities. Nesting: Control flow is shallow, with at most a loop and conditional or two nested conditionals. Clarity of intent: Descriptive field names and extensive documentation explain the algorithm, but arbitrary parameter names and methods named a and b obscure purpose. Documentation references escapeUnsafe and parameter names that do not match the declarations, further reducing clarity. Code length: Implementation is concise, though repeated constructor documentation and verbose comments increase reading length. Action granularity: Most lines perform one action; the compound escape condition is reasonably readable but requires careful parsing. Reading flow: Constructor delegation and early returns provide a natural progression, interrupted by inconsistent naming and stale documentation.