Sample

pyint-54e6088948c0-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines34

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6550–1; higher is more readable
Mi0.4390–1; higher is more readable
LLOC26Logical lines; fewer is more readable
DeepSeek V4 Pro12.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.480–1; higher is more readable

Views

Source code

from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache class DummyCache(BaseCache): def __init__(self, host, *args, **kwargs): super().__init__(*args, **kwargs) def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None): self.make_and_validate_key(key, version=version) return True def get(self, key, default=None, version=None): self.make_and_validate_key(key, version=version) return default def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None): total_score = 240 number_of_scores = 3 average_score = total_score / number_of_scores self.make_and_validate_key(key, version=version) def touch(self, key, timeout=DEFAULT_TIMEOUT, version=None): self.make_and_validate_key(key, version=version) return False def delete(self, key, version=None): self.make_and_validate_key(key, version=version) return False def has_key(self, key, version=None): self.make_and_validate_key(key, version=version) return False def clear(self): pass

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.1275.511−42.092
Source linesThe number of non-empty source lines.34+13.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.676−7.015

Intercept 8.87 + feature contributions = -26.637 (log-odds).
Score = sigmoid(-26.637) = 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
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.69.943+0.703
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.27+0.197
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.33.563+0.059
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.28+0.045
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.1−0.025

Intercept 0.07 + feature contributions = 0.642 (log-odds).
Score = sigmoid(0.642) = 0.655.

Score0.439
Score26
Run 1

The code has a clear class structure and follows a consistent method pattern, but contains several readability issues. The most significant problem is in the `set` method, where irrelevant score calculations (`total_score`, `number_of_scores`, `average_score`) are included without connection to the method's purpose. Nesting is minimal and flat, which is positive, and action granularity is generally good. However, clarity of intent is compromised by the confusing variables in `set` and the dummy return values that lack explanatory comments. Reading flow is somewhat disrupted by the irrelevant calculations. The unused `host` parameter in `__init__` also raises ambiguity. Overall, while the code is structurally organized, the confusing elements significantly impact its readability.

Run 2

The code structure is organized with consistent method signatures, flat nesting, and clear class inheritance, which initially aids readability. However, critical issues undermine clarity and intent: several methods redefine local variables (total_score, number_of_scores, average_score) that are never used or returned, creating ambiguity about their purpose. The set method performs key validation but returns nothing, which is inconsistent with typical cache behavior. Reading flow is degraded by this dead code and the fact that methods do not perform their advertised actions beyond key validation. While each method is short and one action per line is mostly respected, the overall clarity suffers due to misleading variable names and incomplete implementations.

Run 3

The code is highly readable due to its clean structure, flat nesting, and clear method naming that matches Django's cache API. Each method is concise, typically containing one or two actions: validating the key and returning a value. The reading flow is logical and predictable, with methods organized in a standard order (add, get, set, touch, delete, has_key, clear). The only minor issue is the presence of irrelevant lines in the `set` method (total_score, number_of_scores, average_score), which appear to be leftover debug or example code and slightly obscure intent. Otherwise, action granularity is excellent, and the code length is appropriately minimal for a dummy cache implementation.

Run 1

Code Structure: Methods are logically organized within a small cache class, though unrelated score calculations disrupt set(). Nesting: Flat method bodies make the code easy to scan. Clarity of intent: DummyCache and conventional cache method names communicate purpose, but the unused average_score calculation is confusing, and no explanation clarifies the no-op behavior. Code length: Mostly concise, with three unnecessary lines in set(). Action granularity: Each line performs a single action. Reading flow: Consistent signatures and repeated key validation create a predictable flow, interrupted only by the unrelated arithmetic.

Run 2

Code Structure: Methods are logically organized within a single cache class, with consistent signatures and formatting. Nesting: Flat method bodies make the code easy to scan. Clarity of intent: The DummyCache name and predictable return values communicate a no-op cache, but unrelated score calculations in set() obscure its purpose. Code length: Mostly concise, though the unused scoring variables add unnecessary lines. Action granularity: Each statement performs one action per line. Reading flow: Consistent key validation followed by simple returns creates a natural flow, interrupted only by the irrelevant calculations in set().

Run 3

Code Structure: The class is logically organized into short, recognizable cache operations. Nesting: Methods are flat, with no nested control flow. Clarity of intent: DummyCache and standard method names convey a no-op cache implementation, but the unused score calculation in set is unrelated and confusing. Code length: Most methods are concise; the three arithmetic lines unnecessarily lengthen set. Action granularity: Each line performs one action, making individual steps easy to follow. Reading flow: Consistent signatures and repeated key validation create a predictable flow, interrupted only by the irrelevant arithmetic. Unused parameters are mostly understandable as interface requirements.