Sample
pyint-41befc93324c-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0.277 | 0–1; higher is more readable |
| Dorn | 0.853 | 0–1; higher is more readable |
| Mi | 0.751 | 0–1; higher is more readable |
| LLOC | 9 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16.33 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17.67 | 0–20; mean of three runs |
| BTTF | 0.782 | 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. | 242.899 | −8.016 |
| 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.411 | −6.616 |
| Source linesThe number of non-empty source lines. | 12 | +4.8 |
Intercept 8.87 + feature contributions = -0.961 (log-odds).
Score = sigmoid(-0.961) = 0.277.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| 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. | 40.846 | +1.935 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 0 | −0.804 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 13 | +0.576 |
| 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. | 12 | −0.322 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 11.786 | −0.245 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.082 | +0.148 |
Intercept 0.07 + feature contributions = 1.755 (log-odds).
Score = sigmoid(1.755) = 0.853.
| Score | 0.751 |
|---|
| Score | 9 |
|---|
Run 1
The code is highly readable due to its simplicity and clean structure. It demonstrates a clear, focused purpose: defining a single attrs class with an explicit initializer. The structure is logical, with imports grouped, followed by the class definition. Nesting is minimal, with only a single method inside the class. Intent is unambiguous; the class name and attribute type hint make the purpose clear. Code length is concise, with no unnecessary logic. Each action (import statements, decorator, attribute, method, assignment) is on its own line, improving granularity. The reading flow is natural, from imports to class to method. Minor deductions are for the redundant `@attr.s(auto_detect=True)` decorator when a manual `__init__` is provided, which could confuse intent slightly, and the import of `re`, `Any`, `Dict`, `List`, `Tuple`, and `attrs` are unused. These unused imports slightly reduce clarity but do not significantly impact readability.
Run 2
The code is generally readable due to short length, clear imports, and simple class definition. However, it has some ambiguities: it imports both `attr` and `attrs` but only uses `attr.s`, which may confuse intent. The class uses `auto_detect=True` with a manual `__init__`, which somewhat defeats the purpose of auto-detection and creates redundancy. Structure is flat and logical, nesting is absent, and actions are granular. Clarity of intent is moderate—the class purpose is unclear from its name (`AutoDetect`). Reading flow is natural, but the redundant initializer and unused import reduce overall readability.
Run 3
The code is highly readable. It has a clean, logical structure with clear imports and a single class definition. Nesting is minimal—only one level inside the class. The intent is clear: define a class using `attr.s` with auto-detection, explicitly declaring an `x` field and a simple constructor. Code length is concise and appropriate for the task. Action granularity is fine; each meaningful operation is on its own line. Reading flow is natural, starting with future import, then standard/third-party imports, then the class definition. Minor points: the class name 'AutoDetect' is slightly ambiguous without context, and the explicit `__init__` may be redundant with `attrs`, but this does not significantly harm readability.
Run 1
Code Structure: Imports and the class are logically organized, though several imports are unused and importing both attr and attrs adds clutter. Nesting: Minimal, with only a class and its initializer. Clarity of intent: The typed x field and straightforward assignment are clear, but the interaction between auto_detect=True and the explicit initializer requires familiarity with attr. Code length: Very concise, although unused imports are unnecessary. Action granularity: Each statement performs one action. Reading flow: Natural and easy to follow; grouping imports and adding another blank line before the top-level class would improve formatting.
Run 2
Code Structure: Imports, decorator, class, and initializer are logically organized, though a blank line before the decorator would improve separation. Nesting: Minimal and conventional, with only a class and method. Clarity of intent: The class clearly stores an integer, although the decorator's auto-detection behavior requires familiarity with attr. Code length: Very concise, but re, typing names, and attrs are unused imports that add clutter. Action granularity: Each line performs one clear action. Reading flow: Natural top-to-bottom progression from imports to class definition to initialization.
Run 3
Code Structure: Logically organized into imports, a decorator, and a small class, though several imports are unused. Nesting: Minimal, with only the class and constructor levels. Clarity of intent: The annotated field and straightforward constructor make initialization clear, although the generic class name and decorator-specific auto-detection behavior provide limited context. Code length: Concise overall; removing unused imports would reduce clutter. Action granularity: Each line performs a single action. Reading flow: Natural top-to-bottom progression, but an additional blank line before the class decorator and cleaner import grouping would improve presentation.