Sample
pyint-402161046648-I13
Lower every eligible synchronous for loop to a while loop
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.891 | 0–1; higher is more readable |
| Mi | 0.398 | 0–1; higher is more readable |
| LLOC | 43 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 15 | 0–20; mean of three runs |
| GPT-6.1 Sol | 17 | 0–20; mean of three runs |
| BTTF | 0.535 | 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. | 1694.374 | −55.914 |
| Source linesThe number of non-empty source lines. | 69 | +27.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.394 | −6.59 |
Intercept 8.87 + feature contributions = -26.035 (log-odds).
Score = sigmoid(-26.035) = 0.
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 70 | −1.442 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 63 | +1.442 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 86.971 | +0.599 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 68.864 | +0.553 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.045 | +0.502 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| 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. | 86.929 | −0.017 |
Intercept 0.07 + feature contributions = 2.104 (log-odds).
Score = sigmoid(2.104) = 0.891.
| Score | 0.398 |
|---|
| Score | 43 |
|---|
Run 1
The code is generally readable with clear imports, type hints, and logical organization. The CertParamType class has a focused purpose and the convert method follows a coherent flow. However, there are some issues: the nested try/except blocks create moderate complexity, and the final raise statement without context could be confusing - it re-raises the original BadParameter exception from the path_type call, which isn't immediately obvious. The import ssl inside the method could be at module level for clarity. Type ignores and conditional imports add minor noise. Variable naming is clear, and line lengths are reasonable. Overall structure is good but the error handling flow could be more explicit, and the exception re-raise pattern requires careful reading to understand.
Run 2
The code is generally readable with clear class and method naming, decent type hints, and logical grouping of imports. The CertParamType class has a clear purpose and the convert method follows a mostly linear flow. However, there are some issues: the nested try/except blocks create moderate nesting depth, the convert method mixes multiple responsibilities (SSL import, path validation, adhoc handling, object import), and the raise statement without a specific exception type reduces clarity. The type: ignore comments add visual noise. While the code is not deeply tangled, flattening nested exceptions and extracting helper methods would improve readability.
Run 3
The code is moderately readable. It has a logical class structure and clear intent, with reasonable action granularity. However, there are issues: nested try-except blocks create some depth, the except ImportError blocks add complexity, and the re-raising of exceptions without context ('raise') can be ambiguous. Type hints and docstrings improve clarity, but the overall flow is somewhat disrupted by the exception handling. The code is not excessively long but could be flatter.
Run 1
Code Structure: A focused parameter-type class separates initialization from conversion, with logically grouped validation paths. Nesting: Mostly manageable, although nested exception handling and the ad-hoc certificate branch require extra attention. Clarity of intent: The docstring, descriptive names, type annotations, and explicit error messages clearly explain supported certificate inputs. The final bare raise is less immediately obvious because it re-raises the earlier path-validation error. Code length: The implementation is concise, but numerous imports unused in this snippet add visual clutter. Action granularity: Statements generally perform one action per line, with readable multiline calls. Reading flow: Processing proceeds naturally from SSL availability to file paths, ad-hoc certificates, and imported SSL contexts; exception-driven fallback slightly interrupts the linear flow.
Run 2
Code Structure: The class cleanly groups certificate validation, with initialization separated from conversion, although numerous unused imports clutter this excerpt. Nesting: Several nested try/except and conditional blocks add complexity, but the method remains manageable. Clarity of intent: The docstring, type annotations, descriptive names, and actionable error messages clearly explain the accepted inputs. The final bare raise requires understanding the enclosing exception handler. Code length: The implementation is reasonably concise, though the import list is disproportionately long for the shown functionality. Action granularity: Statements generally perform one action per line; multiline calls improve legibility. Reading flow: Validation proceeds logically from SSL availability to file paths, ad-hoc certificates, and imported SSL contexts. Using exception handling to switch between input interpretations slightly interrupts the otherwise natural flow.
Run 3
Code Structure: The class cleanly separates initialization from conversion, with logically organized validation and fallback handling. Nesting: Mostly moderate, but nested exception handling and the 'adhoc' branch increase indentation. Clarity of intent: The docstring, descriptive names, type annotations, and explicit error messages make the accepted certificate inputs clear; the final bare raise requires tracking the enclosing exception handler. Code length: The implementation is reasonably concise, although many imports are unused in this excerpt and add visual clutter. Action granularity: Statements generally perform one action per line, with readable multiline calls. Reading flow: Processing naturally moves from SSL availability to file validation, ad-hoc certificates, and imported SSL contexts, though exceptions used as fallback control flow slightly interrupt linear reading.