The main() function in src/client/client_cli.c (lines 65–341) is a 277-line god function that mixes at least four distinct responsibilities:
Environment variable parsing (lines 66–73)
Config creation (lines 76–82)
Argument parsing — a 32-branch if-else chain (lines 87–249)
Business-logic validation — 8 sequential checks for flag incompatibilities (lines 271–319)
TLS initialization and dispatch (lines 321–335)
Cleanup (lines 337–341)
The McCabe cyclomatic complexity of the argument-parsing loop alone exceeds 30.
Additionally:
Port validation for --server-port and -p is duplicate code — both parse with strtol then check range 1-65535.
The error-handling pattern (fprintf + exit_code = 1 + goto cleanup) is repeated 12+ times verbatim.
Location
src/client/client_cli.c:65-341
Suggested Fix
Extract argument parsing into a dedicated function.
Factor port validation into a shared helper: static int parse_port(const char* str).
Extract validation into: static int validate_config(const Config* config).
Replace the repetitive error-handling pattern with a helper macro.
Severity
Medium
Category
Quality / Maintainability
## Description
The `main()` function in `src/client/client_cli.c` (lines 65–341) is a 277-line god function that mixes at least four distinct responsibilities:
1. **Environment variable parsing** (lines 66–73)
2. **Config creation** (lines 76–82)
3. **Argument parsing** — a 32-branch if-else chain (lines 87–249)
4. **Business-logic validation** — 8 sequential checks for flag incompatibilities (lines 271–319)
5. **TLS initialization and dispatch** (lines 321–335)
6. **Cleanup** (lines 337–341)
The McCabe cyclomatic complexity of the argument-parsing loop alone exceeds 30.
Additionally:
- Port validation for `--server-port` and `-p` is duplicate code — both parse with strtol then check range 1-65535.
- The error-handling pattern (fprintf + exit_code = 1 + goto cleanup) is repeated 12+ times verbatim.
## Location
`src/client/client_cli.c:65-341`
## Suggested Fix
1. Extract argument parsing into a dedicated function.
2. Factor port validation into a shared helper: `static int parse_port(const char* str)`.
3. Extract validation into: `static int validate_config(const Config* config)`.
4. Replace the repetitive error-handling pattern with a helper macro.
## Severity
Medium
## Category
Quality / Maintainability
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
The
main()function insrc/client/client_cli.c(lines 65–341) is a 277-line god function that mixes at least four distinct responsibilities:The McCabe cyclomatic complexity of the argument-parsing loop alone exceeds 30.
Additionally:
--server-portand-pis duplicate code — both parse with strtol then check range 1-65535.Location
src/client/client_cli.c:65-341Suggested Fix
static int parse_port(const char* str).static int validate_config(const Config* config).Severity
Medium
Category
Quality / Maintainability