Overview
Automated complexity analysis of the httpie/ package ranked httpie/cli/argparser.py as the highest-complexity module. The findings below expand on what the existing developer TODO comments already acknowledge.
Findings
_process_auth — cyclomatic complexity ~20, max nesting 5 levels
# TODO: refactor & simplify this method. (line 283)
The method (74 lines) handles six distinct concerns in sequence:
- Extracting embedded URL credentials (
user:pass@host)
- Looking up
.netrc credentials
- Resolving the auth plugin
- Validating
--auth required
- Parsing / prompting for credentials
- Calling
plugin.get_auth()
Three nearly-identical AuthCredentials(key=…, value=…, sep=…, orig=…) blocks are copy-pasted rather than shared.
_process_output_options — nested closure
A check_options function is defined inside the method body and called twice immediately after — a straightforward candidate for extraction to class level.
Class-level TODO (line 79)
# TODO: refactor and design type-annotated data structures
# for raw args + parsed args and keep things immutable.
HTTPieArgumentParser has no return type annotations on its 14 methods.
Metrics (automated scan)
| Metric |
Value |
| Module cyclomatic complexity |
~104 |
if/elif count |
75 |
| Max nesting depth |
9 levels |
| Longest single method |
75 lines (_process_auth) |
| Methods with type annotations |
0 / 14 |
Suggestion
A PR (#1827) is open that addresses _process_auth specifically — decomposing it into four focused helpers and adding return-type annotations. Happy to discuss scope or approach if this direction is welcome.
Found via automated codebase complexity scan.
Overview
Automated complexity analysis of the
httpie/package rankedhttpie/cli/argparser.pyas the highest-complexity module. The findings below expand on what the existing developer TODO comments already acknowledge.Findings
_process_auth— cyclomatic complexity ~20, max nesting 5 levelsThe method (74 lines) handles six distinct concerns in sequence:
user:pass@host).netrccredentials--auth requiredplugin.get_auth()Three nearly-identical
AuthCredentials(key=…, value=…, sep=…, orig=…)blocks are copy-pasted rather than shared._process_output_options— nested closureA
check_optionsfunction is defined inside the method body and called twice immediately after — a straightforward candidate for extraction to class level.Class-level TODO (line 79)
HTTPieArgumentParserhas no return type annotations on its 14 methods.Metrics (automated scan)
if/elifcount_process_auth)Suggestion
A PR (#1827) is open that addresses
_process_authspecifically — decomposing it into four focused helpers and adding return-type annotations. Happy to discuss scope or approach if this direction is welcome.Found via automated codebase complexity scan.