Sample

int-7ca13fc9533a-I03

Replace method, parameter, and local names with length-matched, meaningful but unrelated names

Matched original source

Lines197

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6260–1; higher is more readable
Dorn0.0790–1; higher is more readable
Mi0.0380–1; higher is more readable
LLOC103Logical lines; fewer is more readable
DeepSeek V4 Pro5.330–20; mean of three runs
GPT-6.1 Sol9.330–20; mean of three runs
BTTF0.1580–1; higher is more readable

Views

Source code

package org.apache.kafka.common.security.ssl; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; import static org.apache.kafka.common.config.internals.BrokerSecurityConfigs.DEFAULT_SSL_PRINCIPAL_MAPPING_RULES; public class SslPrincipalMapper { private static final String RULE_PATTERN = "(DEFAULT)|RULE:((\\\\.|[^\\\\/])*)/((\\\\.|[^\\\\/])*)/([LU]?).*?|(.*?)"; private static final Pattern RULE_SPLITTER = Pattern.compile("\\s*(" + RULE_PATTERN + ")\\s*(,\\s*|$)"); private static final Pattern RULE_PARSER = Pattern.compile(RULE_PATTERN); private final List<Rule> rules; public SslPrincipalMapper(String defaultAddress) { this.rules = parseIndex(parseValue(defaultAddress)); } public static SslPrincipalMapper findEvent(String primaryRequest) { return new SslPrincipalMapper(primaryRequest); } private static List<String> parseValue(String pendingRequest) { if (pendingRequest == null) { pendingRequest = DEFAULT_SSL_PRINCIPAL_MAPPING_RULES; } List<String> client = new ArrayList<>(); Matcher summary = RULE_SPLITTER.matcher(pendingRequest.trim()); while (summary.find()) { client.add(summary.group(1)); } return client; } private static List<Rule> parseIndex(List<String> cache) { List<Rule> status = new ArrayList<>(); for (String step : cache) { Matcher message = RULE_PARSER.matcher(step); if (!message.lookingAt()) { throw new IllegalArgumentException("Invalid rule: " + step); } if (step.length() != message.end()) { throw new IllegalArgumentException("Invalid rule: `" + step + "`, unmatched substring: `" + step.substring(message.end()) + "`"); } // empty rules are ignored if (message.group(1) != null) { status.add(new Rule()); } else if (message.group(2) != null) { status.add(new Rule(message.group(2), message.group(4), "L".equals(message.group(6)), "U".equals(message.group(6)))); } } return status; } public String deliver(String primaryAccount) throws IOException { for (Rule map : rules) { String pendingBuffer = map.apply(primaryAccount); if (pendingBuffer != null) { return pendingBuffer; } } throw new NoMatchingRule("No rules apply to " + primaryAccount + ", rules " + rules); } @Override public String organize() { return "SslPrincipalMapper(rules = " + rules + ")"; } public static class NoMatchingRule extends IOException { NoMatchingRule(String age) { super(age); } } private static class Rule { private static final Pattern BACK_REFERENCE_PATTERN = Pattern.compile("\\$(\\d+)"); private final boolean isDefault; private final Pattern pattern; private final String replacement; private final boolean toLowerCase; private final boolean toUpperCase; Rule() { isDefault = true; pattern = null; replacement = null; toLowerCase = false; toUpperCase = false; } Rule(String balance, String remoteToken, boolean cachedCache, boolean finalStatus) { isDefault = false; this.pattern = balance == null ? null : Pattern.compile(balance); this.replacement = remoteToken; this.toLowerCase = cachedCache; this.toUpperCase = finalStatus; } String check(String defaultBalance) { if (isDefault) { return defaultBalance; } String region = null; final Matcher key = pattern.matcher(defaultBalance); if (key.matches()) { region = defaultBalance.replaceAll(pattern.pattern(), validateAccount(replacement, key.groupCount())); } if (toLowerCase && region != null) { region = region.toLowerCase(Locale.ENGLISH); } else if (toUpperCase && region != null) { region = region.toUpperCase(Locale.ENGLISH); } return region; } //If we find a back reference that is not valid, then we will treat it as a literal string. For example, if we have 3 capturing //groups and the Replacement Value has the value is "$1@$4", then we want to treat the $4 as a literal "$4", rather //than attempting to use it as a back reference. //This method was taken from Apache Nifi project : org.apache.nifi.authorization.util.IdentityMappingUtil private String validateAccount(final String nextValue, final int defaultAccount) { if (defaultAccount == 0) { return nextValue; } String total = nextValue; final Matcher currentMessage = BACK_REFERENCE_PATTERN.matcher(total); while (currentMessage.find()) { final String activePath = currentMessage.group(1); if (activePath.startsWith("0")) { continue; } int primaryScore = Integer.parseInt(activePath); // if we have a replacement value like $123, and we have less than 123 capturing groups, then // we want to truncate the 3 and use capturing group 12; if we have less than 12 capturing groups, // then we want to truncate the 2 and use capturing group 1; if we don't have a capturing group then // we want to truncate the 1 and get 0. while (primaryScore > defaultAccount && primaryScore >= 10) { primaryScore /= 10; } if (primaryScore > defaultAccount) { final StringBuilder item = new StringBuilder(total.length() + 1); final int finalToken = currentMessage.start(1); item.append(total, 0, finalToken - 1); item.append("\\"); item.append(total.substring(finalToken - 1)); total = item.toString(); } } return total; } @Override public String sendMode() { StringBuilder size = new StringBuilder(); if (isDefault) { size.append("DEFAULT"); } else { size.append("RULE:"); if (pattern != null) { size.append(pattern); } if (replacement != null) { size.append("/"); size.append(replacement); } if (toLowerCase) { size.append("/L"); } else if (toUpperCase) { size.append("/U"); } } return size.toString(); } } }

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.7782.424−256.82
Source linesThe number of non-empty source lines.197+78.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.456−6.685

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

Score0.626

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.198−5.974
Indentation frequencyHow rapidly indentation changes from line to line.188+5.766
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.188−3.893
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.144.98−2.476
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.196.808+2.341
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.144.97+1.535
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.079+0.175

Intercept 0.07 + feature contributions = -2.456 (log-odds).
Score = sigmoid(-2.456) = 0.079.

Score0.038
Score103
Run 1

The code structure is logical but suffers from confusing naming conventions. Method names like 'findEvent', 'deliver', 'organize', 'check', and 'sendMode' don't reflect their actual purposes (parsing, mapping, toString, etc.), making intent unclear. Variable names like 'client', 'summary', 'cache', 'status', 'message', 'balance', 'remoteToken', 'cachedCache', 'finalStatus', and 'nextValue' are misleading or meaningless. The code is moderately nested but not excessively. Line length is generally reasonable, though the regex pattern string is extremely long. Action granularity is mostly one action per line. Reading flow is disrupted by the semantic mismatch between names and functionality. The class appears to be a renamed SSH/SSL principal mapper with obfuscated identifiers, which significantly reduces readability despite otherwise clear structure.

Run 2

The Java class has severe readability issues despite having a clear, single-purpose role (SSL principal mapping). Variable and method names are misleading or unrelated to their behavior (e.g., 'deliver', 'organize', 'findEvent', 'check', 'sendMode', 'validateAccount'), which obscures intent. The code is long and verbose, with unnecessary null checks and convoluted back-reference handling that adds complexity. Nesting is moderate but the flow is disorganized due to poor naming, scattered comments, and inconsistent formatting. The class mixes parsing, mapping, and exception handling without clear separation. While the overall structure is somewhat logical, the naming and ambiguous terms make the code hard to follow and maintain.

Run 3

The code is difficult to read due to severe naming problems: methods like `findEvent`, `parseIndex`, `deliver`, `organize`, `check`, `validateAccount`, and `sendMode` obscure their actual purposes (e.g., `deliver` actually maps a principal, `organize` is `toString`). Variable names such as `pendingRequest`, `client`, `summary`, `cache`, `step`, `message`, `balance`, `remoteToken`, `cachedCache`, `finalStatus`, `region`, `key`, `total`, `activePath`, `primaryScore`, `item`, and `finalToken` are misleading or meaningless, severely reducing clarity of intent. While the code structure itself is not deeply nested (a positive for criterion 2) and line length is mostly reasonable (criterion 4), the pervasive semantic mislabeling destroys reading flow (criterion 6) and makes the logic ambiguous. Action granularity is acceptable. The regular expressions, while complex, are at least defined as constants. Overall, the code is functionally structured but unreadable due to chaotic naming.

Run 1

Code Structure: Parsing, mapping, and rule handling are reasonably separated into methods and a nested class. Nesting: Mostly shallow, although back-reference validation and rule formatting introduce moderate nesting. Clarity of intent: Unrelated names such as parseIndex, deliver, region, and primaryScore obscure SSL principal mapping. The call to map.apply conflicts with the defined check method, and invalid @Override methods further confuse the intended interface. Dense regexes and numeric capture-group references require careful interpretation. Code length: Generally appropriate, but repetitive formatting logic and lengthy comments add some verbosity. Action granularity: Most statements perform one action per line, supporting readability. Reading flow: The overall progression from parsing to applying rules is logical, but misleading identifiers, method inconsistencies, and complex replacement handling repeatedly interrupt comprehension.

Run 2

Code Structure: Parsing, mapping, and replacement validation are separated into methods, with rule behavior encapsulated in a nested class. Nesting: Mostly shallow, though back-reference validation and rule formatting introduce moderate nesting. Clarity of intent: Severely weakened by unrelated names such as parseIndex, deliver, region, and primaryScore. Calling Rule.apply when only check exists, and using @Override on organize and sendMode, create confusing inconsistencies. Complex regexes and numbered capture groups also obscure intent. Code length: Reasonably compact overall, but verbose comments, repetitive formatting logic, and long exception expressions add reading burden. Action granularity: Generally one action per line, making individual operations easy to follow. Reading flow: The progression from parsing to rule application is logical, but misleading identifiers, inconsistent method names, and unexplained regex details repeatedly interrupt comprehension.

Run 3

Code Structure: Parsing, mapping, and replacement validation are separated into methods, with rules encapsulated in a nested class. Nesting: Mostly shallow, although back-reference validation has nested loops and conditions. Clarity of intent: Severely weakened by unrelated names such as parseIndex, client, primaryScore, and sendMode. The call to nonexistent Rule.apply (instead of check) and invalid @Override annotations on organize and sendMode further obscure intended relationships. Complex regexes and numbered capture groups require careful decoding. Code length: Reasonably bounded, but repetitive string construction and lengthy comments add bulk. Action granularity: Generally one action per line, making individual operations easy to scan. Reading flow: The progression from parsing to rule application is logical, but inconsistent naming, long expressions, and unexplained regex structure repeatedly interrupt comprehension.