Sample
pyint-fd13d5520964-I10
Deterministically remove some optional blank lines and bracketed line breaks
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.802 | 0–1; higher is more readable |
| Mi | 0.16 | 0–1; higher is more readable |
| LLOC | 18 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 13.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 16 | 0–20; mean of three runs |
| BTTF | 0.558 | 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. | 652.329 | −21.527 |
| Source linesThe number of non-empty source lines. | 26 | +10.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.383 | −6.575 |
Intercept 8.87 + feature contributions = -8.832 (log-odds).
Score = sigmoid(-8.832) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 96 | +0.744 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.05 | +0.46 |
| 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. | 95.963 | −0.399 |
| 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. | 24 | +0.093 |
| 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. | 25.794 | −0.049 |
Intercept 0.07 + feature contributions = 1.397 (log-odds).
Score = sigmoid(1.397) = 0.802.
| Score | 0.16 |
|---|
| Score | 18 |
|---|
Run 1
The code is generally readable with clear intent and good structure. The class definition is clean, and the use of attributes/frozen slots is standard. The main issue is the ValueError raising with multiple arguments and odd indentation, which obscures the error structure. Nesting is shallow, and action granularity is mostly one per line. However, the 'misaligned' arguments in the raise statement disrupt reading flow. Imports are somewhat verbose but acceptable. Overall, it's understandable but has minor formatting and clarity issues.
Run 2
The code is moderately readable but has some issues. The structure is logical with a single validator class, but the __call__ method contains an awkward multi-line raise statement with oddly aligned arguments (attr, self.pattern, value) that appears misindented. Nesting is minimal and flat, which is good. Intent is mostly clear—validating regex matches—but the unused imports (operator, re, Pattern, contextmanager, get_run_validators, etc.) create ambiguity about dependencies. Code length is concise but could benefit from minor formatting cleanup. Action granularity is acceptable; each line performs one logical action. Reading flow is natural for the class definition, but the raise statement's argument alignment disrupts visual rhythm. The docstring helps explain the class pattern choice. Overall, functional but could be improved by removing unused imports and reformatting the raise statement for better visual consistency.
Run 3
The code has a clear overall purpose—a regex validator class—and uses modern attrs features like frozen and slots, which aid clarity. However, readability suffers in several ways. The import block mixes standard library, typing, and internal modules without grouping, slightly obscuring intent. The class name is descriptive but long. The main method `__call__` constructs a multi-line error message and raises ValueError with inconsistent indentation and alignment in the argument list, which harms reading flow and action granularity. The use of a callable class is explained but the docstring is minimal. The `__repr__` is concise. Overall, the code is understandable but would benefit from cleaner exception construction, better import organization, and more consistent formatting to improve readability.
Run 1
Code Structure: The validator is logically organized into attributes, validation behavior, and representation, though several unused imports add clutter. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: Class and attribute names clearly convey regex validation, but the __call__ docstring explains the class design rather than the method's behavior. Code length: The implementation is concise, with little unnecessary logic. Action granularity: Most lines perform one action, although placing msg and attr on the same argument line with excessive spacing hurts readability. Reading flow: The sequence is natural, but missing blank lines between imports, the class declaration, attributes, and methods makes the layout cramped.
Run 2
Code Structure: The small validator class logically separates validation from representation, but unused imports clutter the snippet. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: Class and attribute names clearly convey regex validation, although the __call__ docstring explains the callable-class design rather than the method's behavior, and inst is unused. Code length: The implementation is concise, with little unnecessary logic. Action granularity: Most lines contain one action, but placing msg and attr on the same line in the exception arguments disrupts consistency. Reading flow: Validation followed by __repr__ is natural, but missing blank lines between imports, the class, attributes, and methods, plus irregular spacing in the ValueError call, reduce readability.
Run 3
Code Structure: The validator class is logically organized, but numerous unused imports and missing blank lines between sections add clutter. Nesting: A single conditional keeps the implementation shallow and easy to follow. Clarity of intent: Class and attribute names clearly convey regex validation; however, the __call__ docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, though unused imports unnecessarily lengthen the snippet. Action granularity: Statements generally perform one action each, but placing msg and attr on the same line in the exception arguments reduces visual clarity. Reading flow: Validation followed by an error and a custom representation is natural, but inconsistent spacing and the long error-message line interrupt scanning.