Sample

pyint-2ba8c85c3fb1-I11

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

Matched original source

Lines21

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6040–1; higher is more readable
Mi0.6690–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol18.330–20; mean of three runs
BTTF0.5720–1; higher is more readable

Views

Source code

import operator from functools import reduce from django.core.exceptions import EmptyResultSet, FullResultSet from django.db.models.expressions import Case, When from django.db.models.functions import Mod from django.db.models.lookups import Exact from django.utils import tree from django.utils.functional import cached_property class ExtraWhere: # The contents are a black box - assume no aggregates or windows are used. contains_aggregate = False contains_over_clause = False def __init__(self, sqls, params): self.sqls = sqls self.params = params def as_sql(self, compiler=None, connection=None): sqls = ["(%s)" % sql for sql in self.sqls] return " AND ".join(sqls), list(self.params or ())

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.780.484−25.756
Source linesThe number of non-empty source lines.21+8.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.653−6.979

Intercept 8.87 + feature contributions = -15.465 (log-odds).
Score = sigmoid(-15.465) = 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
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.78+0.361
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.066+0.303
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.22+0.257
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.20.797−0.119
Indentation frequencyHow rapidly indentation changes from line to line.20−0.045

Intercept 0.07 + feature contributions = 0.421 (log-odds).
Score = sigmoid(0.421) = 0.604.

Score0.669
Score17
Run 1

The code is clean and readable. Structure is logical: a simple class encapsulates two data attributes and one rendering method. Nesting is flat, with only a list comprehension. Intent is clear from descriptive names ('ExtraWhere', 'sqls', 'params') and a helpful comment explaining constraints. The code is concise without unnecessary boilerplate. Action granularity is fine, with each step in 'as_sql' separated. Reading flow is natural. Minor deductions: the 'compiler' and 'connection' parameters are unused, and the comprehension could be split for clarity, but overall readability is high.

Run 2

The code is generally readable with a clear class name and straightforward method logic, but loses points due to unused imports and insufficient documentation. The class structure is logical, methods are flat with no nesting, and action granularity is appropriate with one operation per line. The reading flow is natural and the ExtraWhere class purpose is understandable. However, the imported modules (operator, reduce, Django ORM exceptions/expressions) are unused, creating ambiguity about intent and potential confusion. The docstring is minimal and doesn't explain why the class exists or how it should be used. The as_sql method is simple but could benefit from a brief parameter description. Overall, it's clear code that would be significantly improved by removing dead imports and adding slightly more context.

Run 3

The code is generally readable and well-structured. It imports only necessary modules and defines a single, clear class with a concise docstring. The `__init__` method is straightforward, with one assignment per line. `as_sql` has clear intent: it wraps each SQL fragment in parentheses, joins them with AND, and returns the combined SQL along with a flattened parameter list. The use of `list(self.params or ())` is a common Django idiom, though slightly terse. The class is short, flat, and avoids unnecessary nesting. The main weakness is the lack of explanation for why `compiler` and `connection` are unused parameters, and the comment could be more detailed about the 'black box' assumption. Overall, it is easy to follow, but a bit more context or docstring detail would push it higher.

Run 1

Code Structure: The small class logically groups metadata, initialization, and SQL rendering, although numerous unused imports add clutter. Nesting: Methods are flat, with no complex branching or deep nesting. Clarity of intent: The class name, descriptive attributes, and comment make its purpose understandable; as_sql clearly wraps SQL fragments and joins them with AND. Code length: The implementation is concise, but the unused imports are unnecessary in this snippet. Action granularity: Each statement performs a focused action; the return expression combines two closely related output preparations without becoming difficult to read. Reading flow: The progression from class metadata to initialization to rendering is natural. Additional blank-line separation between imports and the class would improve formatting slightly.

Run 2

1. Code Structure: The small class is logically organized, with class attributes followed by initialization and SQL rendering. Several unused imports add clutter. 2. Nesting: The code is flat, with no deeply nested control flow. 3. Clarity of intent: Names such as ExtraWhere, sqls, params, and as_sql clearly indicate SQL-condition handling; the comment explains assumptions about aggregates and windows. 4. Code length: The implementation is concise, though the unused imports unnecessarily lengthen the snippet. 5. Action granularity: Each statement performs a focused action; the list comprehension and return expression are compact without being overloaded. 6. Reading flow: The progression from configuration to stored inputs to formatted output is natural. Minor spacing improvements between imports and the class would improve presentation.

Run 3

Code Structure: The small class is logically organized, with class-level flags, initialization, and SQL generation clearly separated. Nesting: Minimal nesting and a straightforward list comprehension make the code easy to follow. Clarity of intent: Descriptive names and the comment explain the class's assumptions; as_sql clearly combines parenthesized SQL fragments with AND and returns parameters. Code length: The implementation is concise, although all imports are unused in the provided snippet and add clutter. Action granularity: Each statement performs a focused operation, with the return expression compact but readable. Reading flow: The progression from metadata to stored state to SQL output is natural. Minor drawbacks include missing spacing before the class and the slightly implicit handling of falsy parameters through self.params or ().