Sample

int-3cd53ba7978f-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines229

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6120–1; higher is more readable
Dorn0.0580–1; higher is more readable
Mi0.0530–1; higher is more readable
LLOC135Logical lines; fewer is more readable
DeepSeek V4 Pro3.670–20; mean of three runs
GPT-6.1 Sol9.670–20; mean of three runs
BTTF0.10–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 sslPrincipalMappingRules) { this.rules = parseRules(splitRules(sslPrincipalMappingRules)); } public static SslPrincipalMapper fromRules(String sslPrincipalMappingRules) { return new SslPrincipalMapper(sslPrincipalMappingRules); } private static List<String> splitRules(String sslPrincipalMappingRules) { if (sslPrincipalMappingRules == null) { sslPrincipalMappingRules = DEFAULT_SSL_PRINCIPAL_MAPPING_RULES; } List<String> result = new ArrayList<>(); Matcher matcher = RULE_SPLITTER.matcher(sslPrincipalMappingRules.trim()); while (matcher.find()) { final int a = 2; final int b = -1; result.add(matcher.group((a + b))); } return result; } private static List<Rule> parseRules(List<String> rules) { List<Rule> result = new ArrayList<>(); for (String rule : rules) { Matcher matcher = RULE_PARSER.matcher(rule); if (!matcher.lookingAt()) { throw new IllegalArgumentException("Invalid rule: " + rule); } if (rule.length() != matcher.end()) { throw new IllegalArgumentException("Invalid rule: `" + rule + "`, unmatched substring: `" + rule.substring(matcher.end()) + "`"); } // empty rules are ignored final int c = 2; final int d = -1; final int e = 1; final int f = 1; if (matcher.group((c + d)) != null) { result.add(new Rule()); } else if (matcher.group((e + f)) != null) { final int g = 1; final int h = 1; final int i = 2; final int j = 2; final int k = 3; final int l = 3; final int n = 3; final int o = 3; result.add(new Rule(matcher.group((g + h)), matcher.group((i + j)), "L".equals(matcher.group((k + l))), "U".equals(matcher.group((n + o))))); } } return result; } public String getName(String distinguishedName) throws IOException { for (Rule r : rules) { String principalName = r.apply(distinguishedName); if (principalName != null) { return principalName; } } throw new NoMatchingRule("No rules apply to " + distinguishedName + ", rules " + rules); } @Override public String toString() { return "SslPrincipalMapper(rules = " + rules + ")"; } public static class NoMatchingRule extends IOException { NoMatchingRule(String msg) { super(msg); } } 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 pattern, String replacement, boolean toLowerCase, boolean toUpperCase) { isDefault = false; this.pattern = pattern == null ? null : Pattern.compile(pattern); this.replacement = replacement; this.toLowerCase = toLowerCase; this.toUpperCase = toUpperCase; } String apply(String distinguishedName) { if (isDefault) { return distinguishedName; } String result = null; final Matcher m = pattern.matcher(distinguishedName); if (m.matches()) { result = distinguishedName.replaceAll(pattern.pattern(), escapeLiteralBackReferences(replacement, m.groupCount())); } if (toLowerCase && result != null) { result = result.toLowerCase(Locale.ENGLISH); } else if (toUpperCase && result != null) { result = result.toUpperCase(Locale.ENGLISH); } return result; } //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 escapeLiteralBackReferences(final String unescaped, final int numCapturingGroups) { final int p = 1; final int q = -1; if (numCapturingGroups == (p + q)) { return unescaped; } String value = unescaped; final Matcher backRefMatcher = BACK_REFERENCE_PATTERN.matcher(value); while (backRefMatcher.find()) { final int s = 2; final int t = -1; final String backRefNum = backRefMatcher.group((s + t)); if (backRefNum.startsWith("0")) { continue; } int backRefIndex = Integer.parseInt(backRefNum); // 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. final int u = 5; final int v = 5; while (backRefIndex > numCapturingGroups && backRefIndex >= (u + v)) { final int w = 5; final int x = 5; backRefIndex /= (w + x); } if (backRefIndex > numCapturingGroups) { final int y = 2; final int z = -1; final StringBuilder sb = new StringBuilder(value.length() + (y + z)); final int aa = 2; final int ab = -1; final int groupStart = backRefMatcher.start((aa + ab)); final int ac = 1; final int ad = -1; final int ae = 2; final int af = -1; sb.append(value, (ac + ad), groupStart - (ae + af)); sb.append("\\"); final int ag = 2; final int ah = -1; sb.append(value.substring(groupStart - (ag + ah))); value = sb.toString(); } } return value; } @Override public String toString() { StringBuilder buf = new StringBuilder(); if (isDefault) { buf.append("DEFAULT"); } else { buf.append("RULE:"); if (pattern != null) { buf.append(pattern); } if (replacement != null) { buf.append("/"); buf.append(replacement); } if (toLowerCase) { buf.append("/L"); } else if (toUpperCase) { buf.append("/U"); } } return buf.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.9902.781−326.792
Source linesThe number of non-empty source lines.229+91.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.318−6.477

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

Score0.612

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.230−7.107
Indentation frequencyHow rapidly indentation changes from line to line.220+6.872
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.220−4.627
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.228.788+2.788
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.974−2.475
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.081+0.151

Intercept 0.07 + feature contributions = -2.793 (log-odds).
Score = sigmoid(-2.793) = 0.058.

Score0.053
Score135
Run 1

This code is nearly unreadable due to deliberate obfuscation. Critical logic uses meaningless variable names (a, b, c, d, etc.) with arithmetic to compute array indices, obscuring intent. Regex patterns are dense and lack comments. Methods like escapeLiteralBackReferences are extremely convoluted with unexplained magic numbers (e.g., final int u = 5; v = 5). Nesting is not excessive but action granularity is poor; each line attempts to hide simple operations through arithmetic. Code length is unnecessarily long due to obfuscated index calculations. Reading flow is severely disrupted. Although the class has a logical structure overall, the implementation details are hostile to readability. This appears intentionally sabotaged or severely neglected.

Run 2

This code is severely unreadable due to multiple severe issues. The most critical problem is the deliberate obfuscation of array indices using meaningless arithmetic operations like `(a + b)` instead of simply using `1`, making the code extremely difficult to understand and maintain. The regex patterns are complex and cryptic without explanation. Variable names like `a, b, c, d, e, f` provide no semantic meaning about their purpose. The nested while loops and conditionals create unnecessary complexity. Magic numbers appear throughout without constants or documentation. The code violates nearly every readability principle: poor structure, confusing nesting, unclear intent, unnecessary length through repetition, multiple actions per line in regex patterns, and completely unnatural reading flow. While the original logic might be sound, the implementation choices make it nearly impossible to comprehend without extensive reverse-engineering.

Run 3

This code is extremely unreadable due to deliberate obfuscation. The regex patterns are complex but acceptable; however, the variable naming (e.g., 'a + b', 'c + d', 'g + h') destroys clarity of intent, making arithmetic on meaningless constants appear magical. Action granularity is poor, as multiple operations are crammed into single lines. The heavy nesting in escapeLiteralBackReferences and cryptic magic numbers violate structure and nesting criteria. Code length is unnecessarily inflated by these obfuscations. Reading flow is disorganized, forcing readers to decode trivial offsets instead of understanding logic. While the original Apache Kafka source may be readable, this modified version intentionally sacrifices readability.

Run 1

Code Structure: Responsibilities are logically separated into splitting, parsing, mapping, and back-reference handling, with an appropriate nested Rule class. Nesting: Most methods have shallow control flow, although back-reference handling introduces several nested loops and conditions. Clarity of intent: Descriptive method names and explanatory comments help, but dense regexes, unnamed capture groups, and arbitrary variables such as a, b, and aa obscure otherwise simple constants. Code length: Numerous unnecessary declarations and arithmetic expressions substantially inflate the implementation. Action granularity: Most lines perform a single action, though some rule construction and replacement expressions require considerable unpacking. Reading flow: The overall progression is natural, but repeated constant arithmetic, verbose comments, and inconsistent whitespace interrupt comprehension. The architecture is readable, while local obfuscation makes implementation details unnecessarily difficult to follow.

Run 2

Code Structure: Sensibly divided into rule splitting, parsing, application, and a nested Rule class. Nesting: Mostly moderate, although back-reference handling introduces nested loops and conditionals. Clarity of intent: Descriptive method names and explanatory comments help, but the dense regex and numerous meaningless variables used to calculate simple constants substantially obscure intent. Code length: Unnecessarily inflated by arithmetic expressions and temporary constants that could be replaced with direct values or meaningful named constants. Action granularity: Generally one action per line, though some constructor calls and replacement expressions require considerable mental unpacking. Reading flow: The overall parse-and-apply sequence is natural, but repeated constant declarations interrupt it, particularly in parseRules and escapeLiteralBackReferences. Overall, the architecture is readable, while deliberate-looking arithmetic indirection makes implementation details cumbersome to follow.

Run 3

Code Structure: Responsibilities are logically separated into splitting, parsing, mapping, and replacement handling, with a cohesive Rule class. Nesting: Mostly shallow, although back-reference handling introduces several nested loops and conditionals. Clarity of intent: Descriptive method names and explanatory comments help, but cryptic variables (a through ah), arithmetic disguising simple constants, and dense regex patterns substantially obscure intent. Code length: Numerous unnecessary constant declarations and redundant parentheses inflate otherwise manageable code. Action granularity: Most statements perform one action per line, though complex constructor arguments and chained replacement operations require extra effort to interpret. Reading flow: The overall progression is natural, but repeated arithmetic indirection interrupts comprehension, especially in parsing and string-index manipulation.