Sample

pyint-782e6c4aa7fa-SRC

Unmodified source class

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 Pro16.330–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 well-structured, organized, and concise. Imports are logical and grouped. The class has a clear single responsibility: wrapping extra WHERE clauses. Nesting is minimal—just a list comprehension inside a method. Variable names like sqls, params, as_sql, compiler, connection clearly express intent. Action granularity is good, with one action per line in as_sql. Reading flow is natural: class docstring, static attributes, __init__, then as_sql. Some minor deductions: the comment about aggregates/windows is slightly cryptic without context, and the use of 'black box' could be more explicit. Also, type hints are absent, which slightly reduces readability for larger codebases. Overall, the code is clean, maintainable, and easy to follow.

Run 2

The code is concise and readable. The class has a clear purpose (encapsulating raw SQL for 'extra where' clauses) with an explanatory comment. The constructor and as_sql method are straightforward. Formatting is consistent and imports are reasonable. Minor deductions for lack of docstrings on methods and slightly terse class-level attributes. The unused Django imports could confuse intent if not needed elsewhere.

Run 3

The code is highly readable. It has a clear, focused purpose: representing an ExtraWhere SQL fragment. Structure is logical: imports are grouped and the class is concise with a clear docstring. Nesting is minimal—only a list comprehension inside as_sql. Clarity of intent is strong due to naming and the explanatory comment. Code length is appropriate; no unnecessary abstraction. Action granularity is good: list comprehension handles the per-item wrapping, then a single join and parameter list conversion. Reading flow is natural: class docstring, simple __init__, then as_sql. Minor deductions: the unused imports (operator, reduce, Case, When, Mod, Exact, tree, cached_property) are puzzling and could suggest incomplete refactoring; also, the comment 'black box' is informal but acceptable. No deep nesting or ambiguity otherwise.

Run 1

Code Structure: The small class logically groups its metadata, initialization, and SQL rendering, although several unused imports add clutter. Nesting: The code is flat, with no nested control flow. Clarity of intent: Class and method names, the explanatory comment, and straightforward SQL construction make its purpose clear; the abbreviated name 'sqls' is slightly less descriptive. Code length: The implementation is concise without unnecessary logic, though unused imports could be removed. Action granularity: Statements generally perform one clear action per line; the return expression combines joining SQL fragments and normalizing parameters without becoming difficult to read. Reading flow: Metadata, constructor, and rendering method follow a natural sequence. An additional blank line before the top-level class would improve conventional Python formatting.

Run 2

Code Structure: The small class logically groups SQL fragments, parameters, and SQL generation, though numerous unused imports add clutter. Nesting: Minimal nesting and a simple comprehension make it easy to follow. Clarity of intent: The class name, as_sql method, and explanatory comment communicate its role clearly; the boolean flags are understandable in Django context. Code length: The implementation is concise without unnecessary logic. Action granularity: Each statement performs one clear operation, with only straightforward transformations combined in the return expression. Reading flow: Initialization naturally precedes SQL generation, and naming is consistent. Additional spacing between imports and the class, and removing unused imports, would improve presentation.

Run 3

Code Structure: The small class is logically organized, separating metadata, initialization, and SQL rendering. Nesting: The code is flat, with only a straightforward list comprehension. Clarity of intent: Names such as sqls, params, and as_sql communicate purpose, and the comment explains the aggregate/window assumptions. Code length: The implementation is concise, though numerous unused imports add clutter to this snippet. Action granularity: Each statement performs a clear, focused action; the return expression combines related output preparation without becoming difficult to read. Reading flow: The class reads naturally from configuration to initialization to behavior. Additional spacing between imports and the class would slightly improve presentation.