Sample

pyint-18e372e84c38-I12

Inline all eligible single-use intermediate local 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 Pro170–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 well-structured and readable. It defines a single class with clear class variables, a helper method, and operator overloads, all logically organized. Nesting is minimal, with only one level used for the type check and conditional return. Intent is explicit: combining lexeme objects with bitwise operators. Method names like _combine and clear error messaging make the purpose unambiguous. The code is concise, with each operator method following a consistent, compact pattern. Action granularity is appropriate, one logical action per line. Reading flow is natural, proceeding from helper method to operator implementations. Minor deductions: the comment is slightly lengthy, and the repeated dispatch through _combine could be seen as slightly indirect, but these are minor readability trade-offs for maintainability and consistency.

Run 3

The code demonstrates excellent readability with a clear, logical class structure and flat nesting. The LexemeCombinable class has a single focused responsibility: combining lexeme objects using bitwise operators. The _combine method handles type validation and operand ordering cleanly, with no nested conditionals beyond a simple type check. Variable names like 'connector' and 'reversed' clearly convey intent. The operator overloads (__or__, __and__, etc.) follow a consistent pattern, each being a single line with clear parameter passing. The comment explains the design decision to override operators, adding valuable context without clutter. Constants BITAND and BITOR improve semantic clarity over raw symbols. Code length is appropriate - no unnecessary verbosity. Action granularity is one operation per line, with error messages formatted for readability. The reading flow is natural, progressing from constants to helper method to operator implementations.

Run 1

Code Structure: The class is logically organized around a shared combination helper followed by operator overloads, although several imports are unused in this excerpt. Nesting: Minimal nesting and early error handling keep control flow straightforward. Clarity of intent: Descriptive names, an informative exception, and a contextual comment explain lexeme combination; the parameter name 'reversed' shadows a built-in, and positional Boolean arguments slightly obscure call intent. Code length: Concise, with necessary repetition for operator overloads rather than unnecessary verbosity. Action granularity: Each line generally performs one clear action, and multiline formatting improves readability. Reading flow: Constants, validation, operand ordering, and operator methods follow a natural progression. Minor spacing and comment wording could be polished.

Run 2

Code Structure: The class cleanly groups operator constants, shared combination logic, and operator overloads; several imports are unused in this excerpt. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Descriptive names, an informative error message, and a contextual comment explain logical lexeme combination, though the parameter name 'reversed' shadows a Python built-in. Code length: Concise, with shared logic avoiding duplication; the small overload methods are appropriate. Action granularity: Each statement performs a single clear action. Reading flow: Constants precede implementation, followed by consistently ordered operator pairs, making the code easy to scan. Minor spacing improvements between imports and the class would improve presentation.

Run 3

Code Structure: The class is logically organized, with operator constants, a shared combination helper, and related operator overloads grouped together. Nesting: Shallow conditionals and early returns keep control flow simple. Clarity of intent: Descriptive names, an informative error message, and a comment explaining logical operator usage make the purpose clear, although the parameter name 'reversed' shadows a built-in and positional booleans require interpretation. Code length: The implementation is concise and avoids duplication through _combine; many imports are unused in the provided snippet and add visual clutter. Action granularity: Each line generally performs one action, with multiline formatting improving readability. Reading flow: The helper precedes its callers, and the overloads follow a consistent pattern, making the code easy to scan.