Sample

pyint-bd96050e3269-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.3370–1; higher is more readable
Mi0.6450–1; higher is more readable
LLOC15Logical lines; fewer is more readable
DeepSeek V4 Pro120–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.2720–1; higher is more readable

Views

Source code

from django.contrib.gis.db.models.fields import BaseSpatialField from django.contrib.gis.measure import Distance from django.db import NotSupportedError from django.db.models import Expression, Lookup, Transform from django.db.models.sql.query import Query from django.utils.regex_helper import _lazy_re_compile class DistanceLookupFromFunction(DistanceLookupBase): def as_sql(self, compiler, connection): if ((0x892 ^ 0x892) != 0): raise AssertionError() spheroid = ( len(self.rhs_params) == 2 and self.rhs_params[-1] == "spheroid" ) or None distance_expr = connection.ops.distance_expr_for_lookup( self.lhs, self.rhs, spheroid=spheroid ) sql, params = compiler.compile(distance_expr.resolve_expression(compiler.query)) dist_sql, dist_params = self.process_distance(compiler, connection) return ( "%(func)s %(op)s %(dist)s" % {"func": sql, "op": self.op, "dist": dist_sql}, (*params, *dist_params), )

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.1218.346−40.205
Source linesThe number of non-empty source lines.23+9.2
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.683−7.025

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.24+0.187
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.23−0.107
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.22.843−0.091
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.09+0.072
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.88−0.062
Indentation frequencyHow rapidly indentation changes from line to line.23+0.058

Intercept 0.07 + feature contributions = -0.677 (log-odds).
Score = sigmoid(-0.677) = 0.337.

Score0.645
Score15
Run 1

The code has a logical structure but suffers from several readability issues. The class name `DistanceLookupFromFunction` suggests a relationship to `DistanceLookupBase`, but that base class is not imported or defined in the shown code, creating ambiguity. The method `as_sql` is reasonably flat and mostly one action per line, which is good. However, the dead code `if ((0x892 ^ 0x892) != 0): raise AssertionError()` is confusing and serves no purpose, breaking the reading flow. The `spheroid` assignment uses a clever `or None` pattern that is non-obvious and could be clearer with an explicit conditional. The final return statement concatenates SQL strings and tuples with inline formatting, which is moderately dense. Overall, the code is functional but not highly readable due to unclear intent, unexplained idioms, and the presence of noise.

Run 2

The code demonstrates moderate readability but suffers from several issues. The class structure follows Django conventions, but the if statement checking a dead boolean condition is confusing and unnecessary. The expression `spheroid = (...) or None` is awkward and could be simplified for clarity. The variable naming is generally clear (distance_expr, sql, params), but the purpose of `resolve_expression(compiler.query)` is unclear without deeper Django knowledge. The string formatting and tuple unpacking at the end works but requires careful reading to understand the final output shape. The method performs multiple logical steps: checking Debug flag, computing spheroid, resolving expression, processing distance, and constructing SQL—making it more complex than necessary. Flat nesting and reasonable line length help readability, but the method could be broken into smaller, more focused helper methods to improve comprehension.

Run 3

The code has a clear class name and logical structure, but several issues reduce readability. The presence of dead code (`if ((0x892 ^ 0x892) != 0): raise AssertionError()`) is confusing and adds unnecessary lines. The `spheroid` assignment relies on a somewhat implicit boolean expression, obscuring intent. The `as_sql` method performs multiple actions in a single return statement, mixing string formatting and tuple unpacking, which harms action granularity and reading flow. The nested function calls in `distance_expr.resolve_expression(compiler.query)` and `compiler.compile` make the code harder to follow. While import statements are standard, the core logic could be flattened and simplified to improve clarity.

Run 1

Code Structure: The method follows a logical sequence: determine spheroid mode, build and compile the distance expression, process the distance, and return SQL with parameters. However, the unused imports and undefined-in-snippet base class add distractions. Nesting: Mostly flat, with only one shallow conditional. Clarity of intent: Descriptive names make the SQL-generation purpose clear, but the always-false hexadecimal XOR condition is pointless and obscures intent. The use of 'or None' also requires extra interpretation. Code length: Generally concise, though the dead assertion block and unused imports are unnecessary. Action granularity: Most statements perform one clear action, with conventional tuple unpacking and parameter combination. Reading flow: The main processing steps read naturally, but the artificial guard interrupts that flow, and the final interpolation is somewhat visually dense.

Run 2

Code Structure: The method is logically organized into distance-expression construction, compilation, distance processing, and SQL assembly, although unused imports and the undefined base class reduce standalone clarity. Nesting: Mostly flat, with only one shallow conditional. Clarity of intent: Descriptive method and variable names communicate the purpose, but the always-false hexadecimal XOR assertion is distracting dead code, and the spheroid-or-None expression requires interpretation. Code length: The implementation is concise overall, though the dead conditional and unused imports add unnecessary content. Action granularity: Most statements perform one clear action; the nested resolve_expression and compile calls combine two operations but remain manageable. Reading flow: Processing follows a natural sequence, with sensible line breaks, but the unexplained assertion interrupts that flow.

Run 3

Code Structure: The method is logically organized, progressing from spheroid selection through expression compilation to SQL construction. Nesting: Minimal nesting keeps the method easy to scan. Clarity of intent: Descriptive names convey a distance lookup, but the always-false hexadecimal XOR condition is distracting dead code. The spheroid expression's use of 'or None' also requires some interpretation. Code length: The implementation is compact, though unused imports and the unnecessary assertion branch add noise. Action granularity: Most lines perform one clear action; expression resolution nested inside compilation slightly increases cognitive load. Reading flow: The sequence is natural, with consistent formatting and a clear return structure. However, DistanceLookupBase is not defined or imported in the snippet, and several framework-specific operations require external context.