Sample
pyint-7034e73c7c32-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.166 | 0–1; higher is more readable |
| Mi | 0.29 | 0–1; higher is more readable |
| LLOC | 49 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 15 | 0–20; mean of three runs |
| GPT-6.1 Sol | 16 | 0–20; mean of three runs |
| BTTF | 0.412 | 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. | 2677.348 | −88.352 |
| Source linesThe number of non-empty source lines. | 104 | +41.6 |
| 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 = -44.636 (log-odds).
Score = sigmoid(-44.636) = 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. | 151.99 | −2.773 |
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 105 | −2.681 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 151.99 | +1.648 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 65 | +1.511 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 65 | −1.071 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 103.869 | +1.042 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.031 | +0.639 |
Intercept 0.07 + feature contributions = -1.614 (log-odds).
Score = sigmoid(-1.614) = 0.166.
| Score | 0.29 |
|---|
| Score | 49 |
|---|
Run 1
The code is generally well-structured and follows Django middleware conventions, with clear docstrings explaining purpose. It scores 15/20 due to relatively flat nesting and logical organization. However, readability is reduced by a few issues: the long string in get_full_path_with_slash has awkward line breaks and concatenation, making it hard to read; several lines contain multiple actions (e.g., nested conditionals with return statements); and the process_request method mixes concerns (User-Agent check and URL rewriting) without clear separation. The overall reading flow is adequate, and action granularity is mostly reasonable, but the string formatting and dense conditionals prevent a higher score.
Run 2
The code is generally readable with clear docstrings and logical organization. However, it loses points due to several issues: inconsistent spacing between classes and methods, some overly long lines with awkward string concatenation in get_full_path_with_slash(), and multiple actions packed into single lines (e.g., the redirect construction in process_request). The nesting depth is acceptable but could be improved in should_redirect_with_slash(). The docstrings are helpful for clarity, but the broken string literals with poor formatting reduce readability. Import statements are clean and well-organized. The code would benefit from consistent blank lines between methods and more careful line wrapping.
Run 3
The code is generally well-structured with clear docstrings and comments explaining purpose. Class organization follows logical middleware flow. However, readability is impacted by several long strings with awkward line continuations (e.g., RuntimeError message), scattered indentation, and inconsistent blank lines between methods. Nesting is mostly flat except for minor nested conditionals. Action granularity is acceptable but not always one action per line. Overall intent is clear, but formatting issues reduce polish.
Run 1
Code Structure: Responsibilities are logically separated into request processing, slash validation, path construction, and response processing. Nesting: Most code is shallow, but user-agent checks and slash validation reach three nested levels. Clarity of intent: Descriptive method names, docstrings, and comments clearly explain behavior and redirect constraints. Code length: Methods are reasonably concise, though extensive documentation and unused imports add some clutter. Action granularity: Statements generally perform one action per line; awkwardly combined string literals and dictionary formatting in the RuntimeError message reduce readability. Reading flow: Methods follow a natural request-to-response sequence, with useful helper extraction. However, missing blank lines around some class members and inconsistent spacing interrupt the flow. Overall, readable and well organized, with modest nesting and formatting issues.
Run 2
Code Structure: Methods separate request checks, slash validation, path construction, and response handling logically; unused imports and inconsistent spacing slightly weaken organization. Nesting: Generally manageable, though user-agent checks and slash validation reach three nested levels. Clarity of intent: Descriptive method names, docstrings, and explanatory comments make behavior clear. Code length: Implementation is reasonably concise, but documentation is somewhat verbose and some comments repeat obvious operations. Action granularity: Most lines perform one action; crowded string literals and a poorly formatted dictionary in the RuntimeError construction reduce readability. Reading flow: The request-to-helper-to-response progression is natural, but missing blank lines between some methods and irregular formatting interrupt scanning.
Run 3
Code Structure: Well organized into focused middleware hooks and helper methods, though unused imports and inconsistent spacing add clutter. Nesting: Moderate, with three nested conditional levels in redirect validation and user-agent checks; still manageable. Clarity of intent: Descriptive method names, docstrings, and comments clearly explain URL rewriting, access restrictions, and response handling. Code length: Reasonably concise for its responsibilities, although some comments repeat the code and the main docstring is lengthy. Action granularity: Most lines perform one action; awkwardly joined string literals and a compressed dictionary closing brace reduce visual clarity. Reading flow: Request processing, redirect helpers, and response processing follow a logical sequence, but missing blank lines between some definitions and malformed-looking error-message formatting interrupt readability.