Sample
pyint-16f356fa18d8-I11
Split eligible integer literals into pairs of short-named intermediate variables
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0.001 | 0–1; higher is more readable |
| Dorn | 0.711 | 0–1; higher is more readable |
| Mi | 0.508 | 0–1; higher is more readable |
| LLOC | 16 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 18 | 0–20; mean of three runs |
| BTTF | 0.636 | 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. | 546.833 | −18.045 |
| 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.502 | −6.753 |
Intercept 8.87 + feature contributions = -7.529 (log-odds).
Score = sigmoid(-7.529) = 0.001.
Feature contributions
| Feature | Value | Contribution (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 | +0.743 |
| 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.059 | +0.364 |
| 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.886 | −0.118 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 21 | −0.011 |
Intercept 0.07 + feature contributions = 0.899 (log-odds).
Score = sigmoid(0.899) = 0.711.
| Score | 0.508 |
|---|
| Score | 16 |
|---|
Run 1
The code is well-structured with clear logical organization: imports are grouped (standard library, typing, then project-specific), and the class uses the attrs decorator idiomatically. Nesting is minimal—only one level of indentation inside the method, with an early return for the None case that improves readability. Intent is clear: this is a validator wrapper that skips validation for None values and delegates otherwise. The __repr__ method is concise and informative. Code length is appropriate; every line serves a purpose. Action granularity is good—each statement is a single logical action. The early return avoids an else block, making the flow natural and easy to follow. Minor deductions: the `_OptionalValidator` name is slightly redundant with the module context, and `self.validator(inst, attr, value)` relies on background knowledge of attrs validator signatures, but this is idiomatic and acceptable in the attrs ecosystem.
Run 2
The code is highly readable with clear imports, a well-structured class using the attrs decorator, and concise methods. The `_OptionalValidator` class has a clear purpose: to allow None values while deferring validation otherwise. Nesting is minimal, with a single if-statement in the `__call__` method. The `__repr__` is informative and concise. Minor deductions: the class is internal (underscore prefix), which limits context, and there is a slight ambiguity in why `unsafe_hash` is True; also, the `operator` and `re` imports appear unused in this snippet, which could affect overall clarity if this is the entire file.
Run 3
The code is generally readable with clear intent: it defines an optional validator wrapper. Structure is logical, with imports organized and a single class definition. The class uses the attrs decorator concisely. Nesting is flat and action granularity is appropriate—one meaningful operation per line in the __call__ method. However, some elements slightly reduce clarity: the import of Pattern is unused, and the imported contextmanager, get_run_validators, set_run_validators, _AndValidator, and_, default_if_none, and NotCallableError are not used in this snippet, which could confuse readers about their relevance. The __call__ method is straightforward and handles the None case early, improving flow. Overall, it is concise and readable, but the unused imports add unnecessary noise.
Run 1
Code Structure: The small validator class is logically organized, with separate methods for validation and representation. Nesting: A single conditional and early return keep control flow flat. Clarity of intent: The class name, method behavior, and representation clearly communicate that None is accepted and other values are delegated to the wrapped validator. Code length: The implementation is concise, though numerous imports are unused in the provided snippet and add clutter. Action granularity: Each statement performs one clear action. Reading flow: The methods follow a natural order, and blank lines separate operations appropriately; a blank line between imports and the class decorator would improve formatting.
Run 2
Code Structure: The class is logically organized with a declared attribute and short, focused methods, though several unused imports add clutter. Nesting: Minimal nesting and an early return keep control flow flat. Clarity of intent: The class name, None check, delegated validation, and descriptive representation clearly communicate optional validation; the framework-specific decorators require some background knowledge. Code length: The implementation is concise without unnecessary logic. Action granularity: Each statement performs one clear action. Reading flow: Imports, class configuration, attribute declaration, and methods follow a natural order, with whitespace separating meaningful steps.
Run 3
Code Structure: The class is logically organized, with separate methods for validation and representation, although several imports are unused in the snippet. Nesting: Minimal nesting and an early return keep the validation path flat. Clarity of intent: The class name, validator attribute, and representation clearly communicate optional validation, though the attrs framework requires some familiarity. Code length: The implementation is concise without unnecessary method logic; unused imports add clutter. Action granularity: Each statement performs a single clear action. Reading flow: Execution naturally proceeds from the None check to delegated validation, and whitespace separates steps effectively.