Sample
pyint-778e6459b9ee-SRC
Unmodified source class
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 | 15 | 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 generally clear and well-structured, using type hints and a dataclass-like attrs pattern. It is concise and each action is on its own line. The class has a single responsibility and the __call__ method handles the Optional validation logic cleanly. However, readability is reduced by unused imports (operator, re, Pattern, contextmanager, get_run_validators, set_run_validators, _AndValidator, and_, default_if_none, NotCallableError), which clutter the top of the file and obscure the actual dependencies. The __repr__ method's f-string is somewhat dense. Overall, the core logic is easy to follow, but the import block and minor string formatting prevent a higher score.
Run 2
The code is generally readable with clear imports, a focused class definition, and sensible method naming. Structure is logical: the _OptionalValidator class has a single responsibility and uses attrs decorators cleanly. Nesting is minimal, with only one conditional inside __call__. Clarity of intent is good — the class purpose is evident from its name and docstring-like repr. Code length is concise and avoids unnecessary verbosity. Action granularity is mostly one action per line, though the return statement and method call are combined in __call__ (still acceptable). Reading flow is natural: import block, then class definition, then methods in logical order. Minor deductions: the import of Pattern and contextmanager appear unused, and the conditional return could be slightly more explicit. Overall, a clean, maintainable snippet.
Run 3
The code is well-structured and follows clean patterns. It uses clear imports, a contextmanager import though unused, and a focused class with a single responsibility. The `_OptionalValidator` class is flat, with no deep nesting, and the `__call__` method handles the None case early, keeping the flow natural. However, there are minor readability issues: an unused import (`contextmanager`) and unused imported names (`get_run_validators`, `set_run_validators`, `and_`, `_AndValidator`, `default_if_none`, `NotCallableError`, `operator`, `re`, `Pattern`) add visual noise and ambiguity. The class-level `validator = attrib()` is concise but may require knowledge of the attrs library. The `__repr__` is clear. Overall, the core logic is simple and readable, but the unused imports and potential confusion from library-specific syntax slightly reduce clarity.
Run 1
Code Structure: The small class cleanly separates initialization metadata, validation behavior, and representation. Nesting: A single conditional with an early return keeps control flow flat. Clarity of intent: The class name and methods clearly convey optional validation, although 'inst' and 'attr' are abbreviated and the decorator requires framework familiarity. Code length: The implementation is concise, but numerous imports are unused in the supplied snippet and add clutter. Action granularity: Each statement performs one action, with no compressed compound operations. Reading flow: Imports precede the class, and methods follow a natural order; an additional blank line before the decorated class would improve visual separation.
Run 2
Code Structure: The small class is logically organized, with a validator field followed by validation and representation methods. Nesting: Minimal nesting and an early return keep execution easy to follow. Clarity of intent: The class name, explicit None check, and representation clearly convey optional validation, though the attrs-generated behavior requires library familiarity. Code length: The implementation is concise, but several imports are unused in the shown snippet and add clutter. Action granularity: Each statement performs one clear action. Reading flow: Validation reads naturally from the None guard to delegation, with appropriate whitespace separating steps.
Run 3
Code Structure: Imports and a compact validator class are logically organized, though several imports are unused in this snippet. Nesting: Minimal nesting and an early return keep execution simple. Clarity of intent: The class name, delegation, and descriptive repr clearly convey validation of optional values; framework-specific decorators and attrib require some familiarity. Code length: The implementation is concise without unnecessary logic, but unused imports add clutter. Action granularity: Each statement performs one action, with no compressed or compound lines. Reading flow: Execution reads naturally from the None check to delegated validation, followed by representation formatting. An extra blank line between imports and the class would improve conventional formatting.