Sample
pyint-1704db9b7cd5-I06
Invert eligible conditions and exchange their branches
Scores
| Method | Score | Scale |
|---|---|---|
| Posnett | 0 | 0–1; higher is more readable |
| Dorn | 0.896 | 0–1; higher is more readable |
| Mi | 0.398 | 0–1; higher is more readable |
| LLOC | 45 | Logical lines; fewer is more readable |
| DeepSeek V4 Pro | 10 | 0–20; mean of three runs |
| GPT-6.1 Sol | 14 | 0–20; mean of three runs |
| BTTF | 0.522 | 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. | 1785.19 | −58.911 |
| Source linesThe number of non-empty source lines. | 73 | +29.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.337 | −6.505 |
Intercept 8.87 + feature contributions = -27.347 (log-odds).
Score = sigmoid(-27.347) = 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. | 74 | −1.584 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 67 | +1.58 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 72.932 | +0.61 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 86.959 | +0.599 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.046 | +0.492 |
| 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.905 | −0.016 |
Intercept 0.07 + feature contributions = 2.149 (log-odds).
Score = sigmoid(2.149) = 0.896.
| Score | 0.398 |
|---|
| Score | 45 |
|---|
Run 1
The code has moderate structure with a clear class definition and docstring. However, readability suffers due to unnecessary nesting (the `try` block wrapping the `ssl` import, and the convoluted `if not ... pass else ...` patterns that reverse normal conditional logic). The reversed conditionals create unnatural reading flow and make intent ambiguous. Multiple actions are sometimes packed into single lines (e.g., `value = click.STRING(value, param, ctx).lower()`), reducing action granularity. Variable names like `ctx` and `param` are clear enough, but the error handling flow lacks clarity. The repeated `raise click.BadParameter` blocks are verbose but acceptable. Overall, the code would benefit from flattened logic, standard `if` conditions, and clearer separation of validation steps.
Run 2
The code is moderately readable but has several issues. The class structure is clear with a logical import order, but the convert method suffers from poor organization and awkward control flow. The if/else blocks with `pass` statements and inverted conditions ('if not (value == "adhoc")') make the intent confusing and disrupt reading flow. Multiple nested exception handlers create deeper nesting than necessary. The error handling logic is tangled - the final `raise` statement is ambiguous and could raise various exceptions. Action granularity is mostly good with one operation per line, and the code length is reasonable for the functionality. However, the negative conditionals and pass statements should be refactored to positive logic with early returns, which would significantly improve clarity. The type hints are good, but the flow from validation to return values is not straightforward. The logic could be flattened and made more explicit about what conditions lead to what outcomes.
Run 3
The code has clear imports and a well-documented class, but shows mixed readability. The CertParamType structure is logical with a clear purpose, yet the convert method has problematic nesting (3 levels) and redundant conditional checks like 'if not (value == "adhoc"): pass else:' that obscure intent. These incomplete conditionals are ambiguous—likely placeholders—but as written they add confusion. The method contains one primary action per line mostly, which helps, but the control flow twists the reading experience. The exception handling adds depth and some paths are unclear. Overall, it's partially readable: structure and documentation are good, but nesting and unclear conditional logic hurt clarity significantly.
Run 1
Code Structure: The class and conversion method are logically organized, although numerous unused imports clutter this excerpt. Nesting: Nested exception handling and conditionals require extra effort to follow. Clarity of intent: The docstring, descriptive names, and explicit error messages clearly explain supported certificate inputs. However, negated conditions with pass branches obscure straightforward checks, and the final bare raise requires tracking the enclosing exception handler. Code length: Generally compact, but redundant branches and imports add unnecessary length. Action granularity: Statements typically perform one action per line, with readable formatting for calls and signatures. Reading flow: The progression from SSL availability to file validation, ad-hoc certificates, and imported contexts is sensible, but inverted conditionals interrupt the natural flow.
Run 2
Code Structure: The class and conversion method are logically organized, though numerous unused imports distract from this snippet. Nesting: Nested exception handling and conditional branches add complexity, particularly within the fallback path. Clarity of intent: The docstring, descriptive names, type annotations, and specific error messages clearly explain supported certificate inputs. However, inverted conditions with pass branches obscure straightforward checks. Code length: The implementation is reasonably compact, but unnecessary conditional scaffolding and imports increase its length. Action granularity: Most lines perform a single action, making individual operations easy to follow. Reading flow: Validation proceeds naturally from SSL availability to file paths, ad-hoc certificates, and imported contexts. Nevertheless, the inverted branches interrupt that flow, and the final bare raise requires readers to track the enclosing exception handler.
Run 3
Code Structure: Imports, class definition, initialization, and conversion logic are logically organized, although many imports are unused in this snippet. Nesting: Nested exception handlers and conditionals add moderate complexity. Clarity of intent: The docstring, descriptive names, and explicit error messages clearly explain accepted certificate inputs. However, inverted conditions with pass branches obscure straightforward checks, and the final bare raise requires tracking the enclosing exception handler. Code length: Mostly concise, but redundant pass branches and unrelated imports add noise. Action granularity: Statements generally perform one action per line; multiline calls are cleanly formatted. Reading flow: The progression from file path to ad-hoc certificate to SSLContext is coherent, but unnecessary else blocks and negated predicates interrupt the flow.