You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
argparser.py: HTTPieArgumentParser has high cyclomatic complexity and mixed responsibilities #1828
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:
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.
Activity
Fixes httpie#1828: Reduce cyclomatic complexity in argparser.py