Sample

pyint-c7fbebcac5f1-I11

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

Matched original source

Lines44

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8450–1; higher is more readable
Mi0.5260–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.4860–1; higher is more readable

Views

Source code

from django.db.backends.postgresql.psycopg_any import is_psycopg3 from django.db.models import ( CharField, Expression, Field, FloatField, Func, Lookup, TextField, Value, ) from django.db.models.expressions import CombinedExpression, register_combinable_fields from django.db.models.functions import Cast, Coalesce from django.utils.regex_helper import _lazy_re_compile from .utils import CheckPostgresInstalledMixin class LexemeCombinable: BITAND = "&" BITOR = "|" def _combine(self, other, connector, reversed): if not isinstance(other, LexemeCombinable): raise TypeError( "A Lexeme can only be combined with another Lexeme, " f"got {other.__class__.__name__}." ) if reversed: return CombinedLexeme(other, connector, self) return CombinedLexeme(self, connector, other) # On Combinable, these are not implemented to reduce confusion with Q. In # this case we are actually (ab)using them to do logical combination so # it's consistent with other usage in Django. def __or__(self, other): return self._combine(other, self.BITOR, False) def __ror__(self, other): return self._combine(other, self.BITOR, True) def __and__(self, other): return self._combine(other, self.BITAND, False) def __rand__(self, other): return self._combine(other, self.BITAND, True)

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.1269.981−41.909
Source linesThe number of non-empty source lines.44+17.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.639−6.959

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.41+0.681
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.911+0.598
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.45−0.557
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.064+0.317
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.43.852+0.203
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.86.956−0.018

Intercept 0.07 + feature contributions = 1.693 (log-odds).
Score = sigmoid(1.693) = 0.845.

Score0.526
Score23
Run 1

The code demonstrates good structure with clear class organization and logical method grouping. Nesting is minimal, with only a single level inside _combine for validation. Intent is evident: implementing bitwise combinable lexemes for PostgreSQL full-text search. The code is appropriately concise — helper methods reuse _combine to avoid duplication. Each action is separated per line, maintaining granularity. Reading flow follows a natural pattern: constants, core logic, then operator overloads. The type check and error message are clear. Minor deductions: no type hints, and the comment about abusing operators could be slightly clearer for readers unfamiliar with Django internals. Overall, readable code with strong maintainability.

Run 2

The code is generally readable and well-structured. It defines a clear base class for combinable lexemes with logical operators. The structure is logical, with constants defined at the top and a private helper method to handle combination logic. Nesting is minimal, and the `_combine` method is flat with a clear type check and early raise. Intent is mostly clear: the class enables bitwise-like logical combination. Code length is concise and appropriate. Action granularity is good, with one action per line. Reading flow is natural, though the comment about 'abusing' operators adds slight ambiguity but provides useful context. Minor deductions for reliance on internal knowledge of `CombinedLexeme` and lack of docstrings, but overall readability is strong.

Run 3

The code is well-structured and readable. It clearly defines a mixin class with two class constants and a private helper method, followed by four dunder methods that use it. Nesting is minimal—only one level in _combine. Intent is explicit: enabling bitwise operators for Lexeme combination, with a helpful comment explaining the design choice. The code is concise, with each action on its own line and consistent formatting. Reading flow is natural: constants, helper, then public API. Minor deductions: the comment is slightly dense and the reversed-argument logic in __ror__/__rand__ could be clearer, but overall comprehension is straightforward for developers familiar with Python operator overloading.

Run 1

Code Structure: The class is logically organized, with operator constants, a shared combination helper, and grouped operator overloads. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Descriptive names, a precise error message, and a contextual comment explain lexeme combination, though BITAND/BITOR suggest bitwise operations rather than logical composition, and reversed shadows a built-in. Code length: Methods are concise and reuse the helper effectively; several imports are unused in this snippet and add visual clutter. Action granularity: Each statement performs one clear action, with multiline formatting improving readability. Reading flow: The helper precedes its callers, and paired normal/reverse operators follow a predictable order. Minor spacing improvements between imports and the class would enhance presentation.

Run 2

Code Structure: The class logically groups combination validation and operator overloads, with shared behavior centralized in _combine. Nesting: Shallow conditionals and early returns make control flow easy to follow. Clarity of intent: Method names, connector constants, a descriptive error, and the explanatory comment communicate the purpose well, although the parameter name reversed shadows a built-in and CombinedLexeme is not defined in the excerpt. Code length: Methods are concise; numerous imports unused in this excerpt add visual overhead. Action granularity: Each line performs a single clear action, with multiline formatting improving readability. Reading flow: Constants precede the helper, followed by consistently ordered operator methods, producing a natural progression. Framework-specific operator semantics require some Django knowledge.

Run 3

Code Structure: The class logically groups connector constants, shared combination logic, and operator overloads. Nesting: Shallow conditionals and early returns keep control flow straightforward. Clarity of intent: Descriptive class and method names, an explicit error message, and a contextual comment explain logical lexeme combination; however, the parameter name 'reversed' shadows a built-in, and boolean arguments require checking the helper signature. Code length: The implementation is concise, though many imports are unused in this excerpt. Action granularity: Each statement performs a single clear action. Reading flow: Constants lead naturally into validation and combination logic, followed by thin operator wrappers. Framework-specific types and overloaded operators add modest cognitive overhead.