Sample

int-1b5093bd50e9-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines221

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6020–1; higher is more readable
Dorn0.0570–1; higher is more readable
Mi0.1090–1; higher is more readable
LLOC127Logical lines; fewer is more readable
DeepSeek V4 Pro90–20; mean of three runs
GPT-6.1 Sol12.330–20; mean of three runs
BTTF0.2610–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) { if (((0x2847 ^ 0x2847) != 0)) { throw new AssertionError(); } this.rules = parseRules(splitRules(sslPrincipalMappingRules)); } public static SslPrincipalMapper fromRules(String sslPrincipalMappingRules) { if (((0x4DE7 ^ 0x4DE7) != 0)) { throw new AssertionError(); } return new SslPrincipalMapper(sslPrincipalMappingRules); } private static List<String> splitRules(String sslPrincipalMappingRules) { if (((0xE5B8 ^ 0xE5B8) != 0)) { throw new AssertionError(); } 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) { if (((0x408A ^ 0x408A) != 0)) { throw new AssertionError(); } 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 { if (((0x58E0 ^ 0x58E0) != 0)) { throw new AssertionError(); } 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() { if (((0x2033 ^ 0x2033) != 0)) { throw new AssertionError(); } return "SslPrincipalMapper(rules = " + rules + ")"; } public static class NoMatchingRule extends IOException { NoMatchingRule(String msg) { super(msg); if (((0xB09D ^ 0xB09D) != 0)) { throw new AssertionError(); } } } 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() { if (((0x1437 ^ 0x1437) != 0)) { throw new AssertionError(); } isDefault = true; pattern = null; replacement = null; toLowerCase = false; toUpperCase = false; } Rule(String pattern, String replacement, boolean toLowerCase, boolean toUpperCase) { if (((0x2CC3 ^ 0x2CC3) != 0)) { throw new AssertionError(); } isDefault = false; this.pattern = pattern == null ? null : Pattern.compile(pattern); this.replacement = replacement; this.toLowerCase = toLowerCase; this.toUpperCase = toUpperCase; } String apply(String distinguishedName) { if (((0xED21 ^ 0xED21) != 0)) { throw new AssertionError(); } 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 (((0xE187 ^ 0xE187) != 0)) { throw new AssertionError(); } 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() { if (((0x1619 ^ 0x1619) != 0)) { throw new AssertionError(); } 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.9843.448−324.834
Source linesThe number of non-empty source lines.221+88.4
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.603−6.904

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

Score0.602

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.222−6.824
Indentation frequencyHow rapidly indentation changes from line to line.212+6.596
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.212−4.444
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.220.808+2.677
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.959−2.475
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.144.968+1.535
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.09+0.066

Intercept 0.07 + feature contributions = -2.799 (log-odds).
Score = sigmoid(-2.799) = 0.057.

Score0.109
Score127
Run 1

The code suffers from several readability issues. Most critically, every method contains an obfuscated, meaningless assertion line (e.g., 'if (((0x2847 ^ 0x2847) != 0)) { throw new AssertionError(); }') which adds noise and destroys reading flow. Naming is generally good, and regex constants are well-placed, but the complex regex patterns are difficult to parse without comments. The escapeLiteralBackReferences method has dense inline comments explaining a non-trivial algorithm, but it remains highly nested and hard to follow. Action granularity is mostly one-action-per-line, but the constructor calls in parseRules span multiple lines in a cramped style. Structure is logical overall, but the artificial assertions and intricate regex handling overshadow clarity. Code length is reasonable for the functionality, but the obfuscation artifacts alone significantly reduce readability.

Run 2

The code suffers from severe readability issues. Obscure dead-code assertions like 'if (((0x2847 ^ 0x2847) != 0)) { throw new AssertionError(); }' are scattered throughout, adding noise and confusing the reader. The constructor and methods are unnecessarily long and mix concerns (parsing, validation, and transformation). The regex patterns are complex and poorly documented, making intent ambiguous. While the overall structure is somewhat organized into methods, the nested logic in `apply` and `escapeLiteralBackReferences` is hard to follow. Action granularity is inconsistent, with dense lines combining multiple operations. The reading flow is disrupted by the assertions and verbose comments. Basic formatting and indentation are present, but they don't compensate for the cluttered logic and dead code. Overall, the code is difficult to read, maintain, and debug.

Run 3

The code is generally well-structured with clear separation of concerns: parsing rules, transforming names, and handling exceptions. It demonstrates reasonable action granularity and reading flow. However, there are several readability issues. The complex regex patterns (RULE_PATTERN, RULE_SPLITTER, RULE_PARSER) make the parsing logic hard to understand at a glance. The odd 'assertion' statements with XOR operations and the conditional 'throw new AssertionError()' are confusing and disrupt the reading flow — they appear to be added for obfuscation or compliance but hurt clarity. The escapeLiteralBackReferences method has dense logic with non-obvious integer manipulation and could be broken down further. There is also some inconsistency in brace placement between the class constructor and other methods. While the core logic is readable and well-organized overall, these issues prevent the code from being highly readable.

Run 1

Code Structure: Responsibilities are logically separated into splitting, parsing, mapping, and rule application, with a cohesive nested Rule class. Nesting: Mostly shallow, although back-reference handling introduces nested loops and conditionals. Clarity of intent: Descriptive method names and explanatory comments help, but dense regular expressions, numbered capture groups, and repeated always-false hexadecimal assertions obscure intent. Code length: Generally reasonable for the functionality, but redundant assertions and verbose string construction add unnecessary bulk. Action granularity: Most meaningful operations occupy separate lines; injected assertions compress conditions and throws onto single lines. Reading flow: The overall progression is natural, but unindented dead-code checks repeatedly interrupt it, while long expressions and inconsistent formatting slow scanning.

Run 2

Code Structure: Responsibilities are logically separated into splitting, parsing, mapping, and an encapsulated Rule class. Nesting: Mostly shallow, though back-reference handling introduces nested loops and conditionals. Clarity of intent: Descriptive method names and explanatory comments help, but dense regexes, numbered capture groups, and abbreviated variables obscure details. Repeated always-false XOR assertions add misleading noise. Code length: Generally reasonable for the functionality, but redundant assertions and verbose comments unnecessarily expand it. Action granularity: Most lines perform one action; injected assertions compress a condition and throw onto one poorly indented line. Reading flow: Method ordering and early returns support natural progression, but inconsistent indentation, long expressions, and repeated dead checks interrupt it.

Run 3

Code Structure: Responsibilities are logically separated into splitting, parsing, mapping, and rule handling. Nesting: Mostly shallow, although back-reference processing and rule formatting contain nested control flow. Clarity of intent: Descriptive method names and explanatory comments help, but dense regular expressions, numbered capture groups, and repeated always-false XOR assertions obscure intent. Code length: Generally reasonable, but injected assertions and some verbose comments add unnecessary bulk. Action granularity: Most meaningful statements perform one action per line; assertion lines compress conditions and throws together. Reading flow: The overall progression is natural, but unindented assertions repeatedly interrupt it, and long expressions require extra effort to decode.