Sample

pyint-821a89e515be-I11

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

Matched original source

Lines25

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4610–1; higher is more readable
Mi0.6070–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro4.670–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.3130–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): a = 1 b = 1 c = 2 d = -1 spheroid = ( len(self.rhs_params) == (a + b) and self.rhs_params[-(c + d)] == "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.1248.1−41.187
Source linesThe number of non-empty source lines.25+10
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.607−6.91

Intercept 8.87 + feature contributions = -29.227 (log-odds).
Score = sigmoid(-29.227) = 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
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Indentation frequencyHow rapidly indentation changes from line to line.25+0.128
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.26+0.116
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.24.876−0.062
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
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.091+0.059

Intercept 0.07 + feature contributions = -0.158 (log-odds).
Score = sigmoid(-0.158) = 0.461.

Score0.607
Score17
Run 1

This code is essentially unreadable due to deeply obfuscated logic, poor naming, and non-standard constructs. The variables a, b, c, and d are assigned single-character names containing arbitrary numeric values (1, 1, 2, -1) and then combined in an expression to compute an index: len(self.rhs_params) == (a + b) and self.rhs_params[-(c + d)] — which effectively checks length == 2 and index -1. This is needlessly indirect. The boolean assignment with 'or None' adds further confusion. The method's purpose is buried under cryptically structured expressions and repetitive variable allocation. There is no separation of concerns: SQL generation, parameter handling, and conditional logic are all interleaved. The code mixes one action per line in some places but obscures overall reading flow by forcing the reader to decode magic numbers and artificial variable names. The lack of comments or contextual hints compounds the problem. It is highly unmaintainable and would likely fail even basic readability standards.

Run 2

The code is moderately readable but has significant clarity issues. The structure is logical but overly cryptic in variable naming: a, b, c, d are used as magic numbers without explanation, making intent unclear. The spheroid detection logic is particularly confusing due to the arithmetic (a + b, -(c + d)) instead of using plain constants. Nesting is relatively flat, and the reading flow is natural for the SQL compilation sequence. However, the one-line spheroid expression packs too many operations, reducing action granularity. Code length is concise, but at the expense of readability. The method itself handles multiple responsibilities—resolving the distance expression, computing distance SQL, and assembling the final string—which could be separated for better clarity. Overall, the code is maintainable only by someone familiar with Django's spatial lookup internals; it fails to communicate its intent clearly to a general reader.

Run 3

This code is extremely difficult to read. The structure is tangled, with unclear variable names like 'a', 'b', 'c', 'd' used to compute magic numbers, obscuring intent. The nesting is moderate but the logic is convoluted, especially the calculation of 'spheroid'. The code length is short but unnecessarily cryptic; the action granularity is poor as multiple operations are crammed into single lines. The reading flow is disorganized, jumping from variable assignment to boolean logic to SQL compilation without clear separation or comments. Overall, it fails to communicate its purpose effectively.

Run 1

Code Structure: The method is logically organized into spheroid selection, expression compilation, distance processing, and SQL assembly, though several imports appear unused and the base class is not shown. Nesting: The code is flat, with no nested control flow. Clarity of intent: Descriptive method and variable names convey the SQL-generation purpose, but a, b, c, and d obscure simple constants through unnecessary arithmetic. The use of 'or None' also makes the spheroid flag less immediately obvious. Code length: The method is reasonably concise, but the four temporary variables add avoidable length. Action granularity: Most lines perform one clear operation; chained expression resolution and compilation require slightly more effort to parse. Reading flow: Operations follow a natural sequence, but the arbitrary variable setup interrupts that flow, and dictionary-based SQL formatting adds visual complexity.

Run 2

Code Structure: The method is logically organized into spheroid selection, distance-expression compilation, and SQL assembly, though several imports appear unused in this snippet. Nesting: Minimal nesting makes control flow easy to follow. Clarity of intent: Descriptive method and variable names communicate the SQL-generation purpose, but arbitrary variables a, b, c, and d obscure simple constants and indexing. DistanceLookupBase is not defined or imported in the snippet, reducing standalone clarity. Code length: Mostly concise, but the four constant assignments and arithmetic add unnecessary length. Action granularity: Each statement performs a focused action, with sensible tuple unpacking. Reading flow: Processing proceeds naturally toward the return value, although the artificial arithmetic interrupts comprehension and the spheroid expression's use of 'or None' requires extra interpretation.

Run 3

Code Structure: The method is logically organized into spheroid detection, distance-expression construction, compilation, and SQL assembly, though several imports are unused in this snippet. Nesting: The code is flat, with no nested control flow; multiline expressions add only modest visual complexity. Clarity of intent: Descriptive method and variable names convey SQL-generation intent, but a, b, c, and d unnecessarily obscure simple constants and indexing. The 'or None' behavior is compact but less explicit than a conditional. Code length: The method is reasonably short, yet four temporary assignments and arithmetic expressions introduce avoidable length. Action granularity: Each statement generally performs one action, although compilation combines expression resolution and compilation. Reading flow: Execution proceeds naturally toward the return value, but the artificial arithmetic interrupts comprehension, and the base class is not defined or imported in the shown code.