Skip to content

refactor: simplify complex methods to reduce cyclomatic complexity - #10

Open
deepsource-dev-autofix[bot] wants to merge 1 commit into
masterfrom
deepsource-autofix-09c24838
Open

refactor: simplify complex methods to reduce cyclomatic complexity#10
deepsource-dev-autofix[bot] wants to merge 1 commit into
masterfrom
deepsource-autofix-09c24838

Conversation

@deepsource-dev-autofix

Copy link
Copy Markdown

This PR refactors several large methods in the resolver to break down deeply nested logic into smaller helper functions, reducing cyclomatic complexity and improving readability and maintainability.

  • Function with cyclomatic complexity higher than threshold: The original complete_package, get_locked, and debug methods contained multiple nested branches and repeated patterns, making them hard to follow and maintain. We extracted the package resolution logic into an inner _fetch helper and introduced dedicated formatting functions (_format_fact, _format_selecting, _format_derived, and _format_conflict) for the debug output. By consolidating shared behavior and flattening conditional structures, the overall complexity of these methods has been significantly reduced.

This Autofix was generated by AI. Please review the change before merging.

This PR refactors several large methods in the resolver to break down deeply nested logic into smaller helper functions, reducing cyclomatic complexity and improving readability and maintainability.

- Function with cyclomatic complexity higher than threshold: The original `complete_package`, `get_locked`, and `debug` methods contained multiple nested branches and repeated patterns, making them hard to follow and maintain. We extracted the package resolution logic into an inner `_fetch` helper and introduced dedicated formatting functions (`_format_fact`, `_format_selecting`, `_format_derived`, and `_format_conflict`) for the debug output. By consolidating shared behavior and flattening conditional structures, the overall complexity of these methods has been significantly reduced.

> This Autofix was generated by AI. Please review the change before merging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants