Refactor: main() in client_cli.c is a 277-line god function #149
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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