Skip to content

Fix #1828: Reduce cyclomatic complexity in argparser.py - #1930

Open
vinayK34 wants to merge 1 commit into
httpie:masterfrom
vinayK34:fix/argparser-complexity
Open

Fix #1828: Reduce cyclomatic complexity in argparser.py#1930
vinayK34 wants to merge 1 commit into
httpie:masterfrom
vinayK34:fix/argparser-complexity

Conversation

@vinayK34

Copy link
Copy Markdown

This PR addresses issue #1828 by reducing the cyclomatic complexity in httpie/cli/argparser.py:

Changes Made

  1. Decomposed _process_auth method into 5 focused helper methods:

    • _handle_embedded_url_credentials
    • _get_auth_plugin
    • _process_auth_with_plugin
    • _process_netrc_credentials
    • _finalize_authentication
  2. Moved check_options function from _process_output_options to class level as _check_options

  3. Added type annotations to method signatures

  4. Reduced cyclomatic complexity from ~20 to ~5 per method

  5. Eliminated duplicated code patterns

Impact

  • Significantly improves code maintainability
  • Reduces cognitive complexity for developers
  • Makes the authentication processing flow clearer and more modular
  • Addresses the TODO comments in the original code about refactoring and simplification

The changes are backward compatible and don't alter any public APIs.

- Decomposed _process_auth method into 5 focused helper methods
- Moved check_options function to class level
- Added type annotations to methods
- Reduced cyclomatic complexity from ~20 to ~5 per method
- Eliminated duplicated code patterns
@vinayK34
vinayK34 marked this pull request as ready for review August 11, 2026 12:11
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.

1 participant