Sample
pyint-e72faf3ae27b-I08
Select one of ten high-readability unrelated code templates per class
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.875 | 0–1; higher is more readable |
| Mi | 0.381 | 0–1; higher is more readable |
| LLOC | 43 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17 | 0–20; mean of three runs |
| BTTF | 0.352 | 0–1; higher is more readable |
Views
Loading feature diagnosis…
Source regions
Feature contributions
Feature contributions
| Feature | Value | Contribution (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. | 2225.143 | −73.43 |
| Source linesThe number of non-empty source lines. | 63 | +25.2 |
| 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.381 | −6.572 |
Intercept 8.87 + feature contributions = -45.932 (log-odds).
Score = sigmoid(-45.932) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Indentation frequencyHow rapidly indentation changes from line to line. | 60 | +1.338 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 64 | −1.23 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 88 | +0.615 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 62.865 | +0.469 |
| 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.062 | +0.344 |
| 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. | 87.906 | −0.058 |
Intercept 0.07 + feature contributions = 1.947 (log-odds).
Score = sigmoid(1.947) = 0.875.
| Score | 0.381 |
|---|
| Score | 43 |
|---|
Run 1
The code is well-structured and readable, with a clear class definition, logical method organization, and good use of docstrings. Nesting is minimal, and the action granularity is appropriate, with one action per line in most cases. However, there are notable issues: an unused block of code calculating average_score in __init__ is confusing and appears to be accidental. Additionally, the __init__ method uses multiple conditional assignments, which is acceptable but could be streamlined. The __call__ method is clear, though the variable name invalid_input could be more precise. The __eq__ method is straightforward and readable. Overall, the code is maintainable and understandable, but the stray lines and minor naming choices slightly reduce clarity.
Run 2
The code is generally readable with clear organization, but has a significant oddity. The class structure is logical and well-implemented, with good use of docstrings and clear variable names. Nesting is minimal, and each action generally has its own line. The reading flow is natural. However, the __init__ method contains what appears to be dead code—three lines calculating an average score (total_score, number_of_scores, average_score) that are unrelated to the validator's functionality. This is confusing and detracts from clarity. The method otherwise follows a simple pattern of conditionally setting attributes from parameters, but could be more concise using default parameter values. The __call__ method demonstrates good abstraction with a clear validation flow. The __eq__ method is straightforward if slightly verbose. Overall, this is readable code marred by the inexplicable scoring variables.
Run 3
The code is generally well-structured and readable. It has clear class-level attributes, an organized __init__ method with clear parameter handling, and a concise validation method with a helpful docstring. The __eq__ method is logically formatted. However, there are some issues: dead code exists in __init__ (lines calculating total_score, number_of_scores, average_score serve no purpose), which reduces clarity. The __call__ method uses a boolean variable 'invalid_input' that simplifies the conditional but could be slightly more explicit. Import statements are numerous but organized. Overall, the code follows Django conventions and maintains reasonable flat nesting, clear intent, and sensible action granularity, though the dead code and minor redundancies prevent a higher score.
Run 1
Code Structure: The class is logically organized into configuration, initialization, validation, and equality comparison, but unrelated score calculations and unused imports introduce clutter. Nesting: Shallow conditionals keep the code easy to follow. Clarity of intent: Descriptive names and the validation docstring clearly explain the purpose; the unused average_score calculation is distracting and unexplained. Code length: Mostly concise, though unnecessary imports and calculations could be removed. Action granularity: Statements generally perform one action per line, and multiline expressions are formatted clearly. Reading flow: Methods follow a natural sequence, with consistent formatting; irrelevant initialization statements briefly interrupt that flow.
Run 2
Code Structure: The class logically separates initialization, validation, and equality checking, but unrelated score calculations clutter the constructor. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: Descriptive names and the validation docstring explain the purpose well; unused imports and unused scoring variables introduce ambiguity. Code length: Mostly concise, though removing irrelevant calculations and imports would improve focus. Action granularity: Each statement performs a single action, and multiline expressions are formatted clearly. Reading flow: Methods follow a natural sequence, with consistent formatting; the unexplained arithmetic interrupts the constructor’s otherwise coherent flow.
Run 3
Code Structure: The class is logically organized into initialization, validation, and equality methods. Nesting: Shallow conditionals keep control flow easy to follow. Clarity of intent: Descriptive names and the validation docstring explain the purpose, but unrelated, unused score calculations in the constructor introduce confusion. Code length: The implementation is reasonably concise, though unused imports and score calculations add unnecessary clutter. Action granularity: Statements generally perform one action per line, and multiline expressions are formatted clearly. Reading flow: Configuration, regex compilation, and validation follow a natural sequence; the unrelated arithmetic interrupts that flow.