Sample
pyint-4df864e959a7-SRC
Unmodified source class
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.885 | 0–1; higher is more readable |
| Mi | 0.662 | 0–1; higher is more readable |
| LLOC | 20 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 16.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17.33 | 0–20; mean of three runs |
| BTTF | 0.67 | 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. | 664.856 | −21.94 |
| Source linesThe number of non-empty source lines. | 27 | +10.8 |
| 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.504 | −6.755 |
Intercept 8.87 + feature contributions = -9.026 (log-odds).
Score = sigmoid(-9.026) = 0.
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. | 73.929 | +0.534 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.051 | +0.446 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 74 | +0.39 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 26 | +0.162 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 27 | +0.08 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 26.773 | −0.036 |
Intercept 0.07 + feature contributions = 2.045 (log-odds).
Score = sigmoid(2.045) = 0.885.
| Score | 0.662 |
|---|
| Score | 20 |
|---|
Run 1
The code is well-structured and readable. The class has a clear single responsibility, and the validator loop is flat with minimal nesting. Clarity of intent is high: the `_OrValidator` tries each validator and raises only if all fail, which is easy to understand. Action granularity is good—each line performs one logical step. The use of `try/except/continue/else` is idiomatic for this pattern, though the `else: return` could be simplified by returning after the loop or using `with suppress`, but it remains readable. Naming is clear, and type hints are not needed for this short snippet. The `# noqa` comment is justified given the intentional broad exception handling for validator logic. The repr methods are concise and useful. Overall, the code is maintainable and readable with only minor opportunities for simplification.
Run 2
The code is generally well-structured and readable. It follows a clear class definition with a single responsibility (_OrValidator). The use of the attrs decorator reduces boilerplate. The __call__ method is relatively flat, with minimal nesting (just one try/except inside a for loop). Variable names are clear (inst, attr, value, v), and the error message is descriptive. The __repr__ is concise and useful for debugging. However, the silent exception handling with a generic 'except Exception' and no comment explaining why specific exceptions are swallowed slightly reduces clarity of intent. The import block includes several unused or contextually unexplained imports (operator, re, Pattern, contextmanager, etc.) which adds noise. Overall, the core logic is easy to follow, but the exception handling and extra imports prevent a higher score.
Run 3
The code is well-structured with a single, focused class, and follows a clear logical flow. Nesting is minimal, with only one level inside the __call__ method. Variable and method names clearly convey intent, and the error message is descriptive. The code is concise, avoids unnecessary length, and maintains one action per line in most places. The try/except/continue/else pattern is readable, though slightly unusual. The only minor readability concern is the non-standard error handling structure, which requires a moment to understand. The type annotations and repr method further enhance clarity, making this highly readable code.
Run 1
Code Structure: The class cleanly groups validator execution and representation, though numerous unused imports add clutter. Nesting: The loop and try/except/else introduce moderate nesting, but the method remains easy to follow. Clarity of intent: The class name, validators attribute, and descriptive error message clearly convey OR-style validation. The short names v, inst, and attr are less explicit, and catching every Exception obscures whether unexpected errors are intentionally treated as validation failures. Code length: The implementation is concise without unnecessary logic. Action granularity: Each line performs a single clear action. Reading flow: Validation attempts, early success, and final failure follow a natural sequence; an extra blank line before the decorated class would improve separation from imports.
Run 2
Code Structure: The validator is logically organized into initialization metadata, validation behavior, and representation, though several unused imports clutter the snippet. Nesting: The loop and try/except/else introduce moderate nesting, but the early return keeps control flow manageable. Clarity of intent: The class name, validators attribute, and error message clearly convey OR-style validation; the abbreviated variable v and broad exception handling slightly obscure details. Code length: The implementation is concise without unnecessary logic. Action granularity: Each line generally performs one action, with clear separation between message construction and raising the error. Reading flow: Validation proceeds naturally from trying alternatives to reporting failure, although the long suppression comment adds visual noise.
Run 3
Code Structure: The small class cleanly separates validation behavior from representation, though several unused imports add clutter. Nesting: The loop and try/except/else introduce moderate but manageable nesting. Clarity of intent: The class name, validators attribute, and error message clearly communicate that any successful validator is sufficient; the abbreviated name 'v' and broad exception handling slightly reduce clarity. Code length: The implementation is concise without sacrificing meaningful error reporting. Action granularity: Each line generally performs one action, making execution easy to follow. Reading flow: Validation proceeds naturally from trying alternatives to returning on success or raising after all fail. The lengthy suppression comment and unused imports mildly interrupt an otherwise straightforward reading experience.