Sample
pyint-58a6b4b00288-I01
Remove comments and docstrings
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.586 | 0–1; higher is more readable |
| Mi | 0.301 | 0–1; higher is more readable |
| LLOC | 18 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 14.67 | 0–20; mean of three runs |
| GPT-6.1 Sol | 18 | 0–20; mean of three runs |
| BTTF | 0.545 | 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. | 646.656 | −21.34 |
| Source linesThe number of non-empty source lines. | 23 | +9.2 |
| 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.58 | −6.869 |
Intercept 8.87 + feature contributions = -10.139 (log-odds).
Score = sigmoid(-10.139) = 0.
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 |
| 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.062 | +0.34 |
| 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. | 82 | +0.192 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 24 | +0.187 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 22.747 | −0.092 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 23 | +0.058 |
Intercept 0.07 + feature contributions = 0.348 (log-odds).
Score = sigmoid(0.348) = 0.586.
| Score | 0.301 |
|---|
| Score | 18 |
|---|
Run 1
The code is generally readable with clear intent. The class has a logical structure with frozen/slots attributes, and the validator's purpose is evident. Nesting is minimal - only one conditional check inside __call__. Action granularity is good, with one logical action per line. However, there are minor issues: the blank line after the __call__ definition is unnecessary, and the import section contains unused imports (operator, re, Pattern, contextmanager, get_run_validators, set_run_validators, _AndValidator, and_, default_if_none, NotCallableError) which adds noise. The __repr__ uses 'x' as a placeholder rather than showing the actual attribute name, making debugging slightly less clear. The error message construction could be more descriptive by including the attribute type. Overall, the code is concise and follows good practices, but could benefit from cleanup of unused imports and minor clarity improvements.
Run 2
The code is generally readable but has some clarity issues. The class structure is logical with clear separation of attributes and methods, and the nesting is minimal. However, several elements reduce readability: unused imports (operator, re, Pattern, contextmanager, get_run_validators, set_run_validators, _AndValidator, and_, default_if_none, NotCallableError) add noise and suggest disorganization. The `__call__` method's blank line after the signature is unnecessary, and attribute names like `compare_op` versus `compare_func` could be clearer about their distinct purposes (one stores an operator symbol for messages, the other stores the comparison function). The f-string in the error message effectively conveys intent, but the repr string is confusing—using 'x' as a placeholder may be ambiguous. The action granularity is appropriate with one main operation per line, though the error raising could be consolidated. Overall, the code demonstrates decent structure but would benefit from removing unused imports and clarifying variable naming.
Run 3
The code has reasonable structure with a single class definition and clear imports, but it lacks documentation and has some readability issues. The _NumberValidator class is logically organized with the __call__ method checking validity, but the purpose of bound, compare_op, and compare_func attributes is ambiguous without docstrings. The code is relatively flat with minimal nesting (single if statement), which is good. However, the error message formatting is unclear - using f-string with 'must be' and 'compare_op' doesn't read naturally. The repr method is helpful but the overall intent could be clearer with docstrings explaining the validator's purpose and parameters. Code length is concise and action granularity is appropriate with one main operation per line. The reading flow is acceptable but could be improved with better variable naming and documentation.
Run 1
Code Structure: Imports and a compact validator class are logically organized, though several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: Descriptive field names, a direct comparison, and informative error and representation messages make the validator's purpose clear; abbreviated parameters such as inst and attr are slightly less explicit. Code length: The implementation is concise, with minor clutter from unused imports and an unnecessary blank line. Action granularity: Each statement performs one clear action. Reading flow: Fields, validation logic, and representation appear in a natural order, although additional spacing between imports and the class would improve visual separation.
Run 2
Code Structure: The validator is logically organized into attributes, validation behavior, and representation, though several imports are unused in this snippet. Nesting: A single conditional keeps nesting minimal. Clarity of intent: The class name, comparison attributes, and descriptive error message clearly communicate numeric-bound validation; abbreviated parameter names slightly reduce clarity. Code length: The implementation is concise, with only an unnecessary blank line and unused imports adding clutter. Action granularity: Each statement performs one clear action, and constructing the error message separately aids readability. Reading flow: Imports followed by class configuration, validation, and representation provide a natural sequence; additional spacing between imports and the class would improve presentation.
Run 3
Code Structure: The validator is logically organized into fields, validation behavior, and representation. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: Descriptive names and informative error messages make the numeric-bound validation clear, though the unused inst parameter and lack of documentation leave minor context implicit. Code length: The class is concise, but several imports are unused in the provided snippet. Action granularity: Each line performs one clear action, including separate message construction and exception raising. Reading flow: Fields precede methods in a natural order; an unnecessary blank line inside __call__ and limited spacing between imports and the class slightly reduce polish.