Sample

int-7c86fe8160f6-I09

Select one of ten low-readability unrelated code templates per class

Matched original source

Lines199

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6440–1; higher is more readable
Dorn0.0770–1; higher is more readable
Mi0.0550–1; higher is more readable
LLOC105Logical lines; fewer is more readable
DeepSeek V4 Pro9.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.1780–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) { {int lI0O_9e39d45b=0x3E9D-0x3E9D;lI0O_9e39d45b=(lI0O_9e39d45b==0)?(lI0O_9e39d45b|0):(lI0O_9e39d45b&0);} if (sslPrincipalMappingRules == null) { sslPrincipalMappingRules = DEFAULT_SSL_PRINCIPAL_MAPPING_RULES; } List<String> result = new ArrayList<>(); Matcher matcher = RULE_SPLITTER.matcher(sslPrincipalMappingRules.trim()); while (matcher.find()) { result.add(matcher.group(1)); } 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 if (matcher.group(1) != null) { result.add(new Rule()); } else if (matcher.group(2) != null) { result.add(new Rule(matcher.group(2), matcher.group(4), "L".equals(matcher.group(6)), "U".equals(matcher.group(6)))); } } 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) { if (numCapturingGroups == 0) { return unescaped; } String value = unescaped; final Matcher backRefMatcher = BACK_REFERENCE_PATTERN.matcher(value); while (backRefMatcher.find()) { final String backRefNum = backRefMatcher.group(1); 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. while (backRefIndex > numCapturingGroups && backRefIndex >= 10) { backRefIndex /= 10; } if (backRefIndex > numCapturingGroups) { final StringBuilder sb = new StringBuilder(value.length() + 1); final int groupStart = backRefMatcher.start(1); sb.append(value, 0, groupStart - 1); sb.append("\\"); sb.append(value.substring(groupStart - 1)); 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.7914.664−261.184
Source linesThe number of non-empty source lines.199+79.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.527−6.791

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

Score0.644

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.200−6.045
Indentation frequencyHow rapidly indentation changes from line to line.190+5.835
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.190−3.939
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.975−2.475
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.198.829+2.369
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.173

Intercept 0.07 + feature contributions = -2.478 (log-odds).
Score = sigmoid(-2.478) = 0.077.

Score0.055
Score105
Run 1

The code is difficult to read due to several issues. The regular expression RULE_PATTERN is extremely obfuscated, making intent unclear. There is an injected bizarre line with no clear purpose (lI0O_9e39d45b assignment), breaking reading flow and raising maintainability concerns. The structure is mostly organized into separate methods/classes, but the central regex parsing logic is cryptic. Nesting is mostly flat, and action granularity is reasonable, but complex regex matching and the escapeLiteralBackReferences method increase cognitive load. Long inline comments are helpful, yet they do not fully compensate for the difficult-to-parse pattern logic. Overall, the code requires deep regex expertise to understand, and the presence of strange artifacts makes it appear unreliable.

Run 2

The code has a clear class purpose and splits parsing vs. mapping logic, which helps readability. However, there are notable flaws: confusing regex constants with dense escaping, a strange leftover 'if' block in splitRules that serves no purpose, and deep/awkward control flow in escapeLiteralBackReferences. The main getName loop is flat and clear, but the rule parsing relies on opaque regex group indices, reducing intent clarity. Naming is mostly good, and comments help in tricky parts, but some methods do too much (e.g., escapeLiteralBackReferences) and the regex pattern is hard to follow at first glance. Overall, it is middling: readable for someone familiar with regex and Java, but not beginner-friendly.

Run 3

The code has some redeeming qualities but overall readability is significantly hampered by several issues. The class structure is somewhat logical (mapper, rules, parser) but the regex pattern definitions are extremely dense and hard to understand. There's an inexplicable obfuscated line in splitRules() that serves no purpose and looks like injected garbage. The RULE_PATTERN is a wall of regex with no explanation, making the core logic opaque. Nesting is generally fine, but action granularity suffers in parseRules() where multiple groups are extracted in one line, and in Rule.apply() where replaceAll with escaped backreferences combines several operations. The escapeLiteralBackReferences method has confusing backreference truncation logic and excessive comments. Reading flow is interrupted by the bizarre artifact and dense regex. While the Rule class encapsulates its concerns reasonably well and toString methods aid debugging, the core transformation logic—the heart of the code—is nearly impenetrable without extensive regex expertise. The code length is acceptable, but clarity of intent is severely compromised by the cryptic pattern matching approach and unexplained magic strings.

Run 1

Code Structure: Responsibilities are logically separated into splitting, parsing, mapping, and a nested Rule class. Nesting: Mostly shallow, although back-reference handling and rule formatting introduce moderate nesting. Clarity of intent: Descriptive method and field names help, but dense regular expressions, numeric capture-group references, and an unexplained no-op block with an obfuscated variable obscure intent. Code length: Generally proportionate to the functionality, with some verbose comments and unnecessary injected code. Action granularity: Most lines perform one action; the compressed no-op block conspicuously violates this, and a few expressions are lengthy. Reading flow: Methods follow a natural processing sequence, with early returns and clear conditionals, but inconsistent formatting, long lines, and regex decoding interrupt comprehension.

Run 2

Code Structure: Responsibilities are logically separated into rule splitting, parsing, application, and back-reference handling, with a cohesive nested Rule class. Nesting: Mostly shallow, although back-reference processing and string rendering introduce moderate nesting. Clarity of intent: Descriptive method and field names help, but dense regex patterns, numbered capture groups, and an unexplained obfuscated no-op block obscure understanding. Code length: Generally appropriate for the functionality, though the no-op block and some verbose comments add unnecessary bulk. Action granularity: Most lines perform one action; the injected block compresses declarations, assignments, and conditional operations onto one line. Reading flow: Method ordering and early returns support a natural progression, but inconsistent formatting, long expressions, and the intrusive no-op disrupt it.

Run 3

Code Structure: Responsibilities are logically separated into rule splitting, parsing, application, and back-reference handling, with a cohesive nested Rule class. Nesting: Mostly shallow, although back-reference handling and rule formatting introduce moderate nesting. Clarity of intent: Descriptive method and field names help, but dense regex patterns, numbered capture groups, and the meaningless obfuscated block in splitRules obscure intent. Code length: Generally proportionate to functionality; the injected no-op block, repetitive initialization, and some lengthy comments add unnecessary bulk. Action granularity: Most lines perform one action, but the injected block compresses multiple statements onto one line, and several expressions are dense. Reading flow: Method organization and early returns support natural reading, while inconsistent spacing, long lines, regex complexity, and the unexplained injected code interrupt it.