Daniel Stenberg discusses reducing code complexity in the curl project by measuring cyclomatic complexity scores and systematically refactoring functions. He implemented tracking graphs, set a complexity limit of 100, and added CI checks to prevent regression. The effort successfully eliminated all functions with complexity over 100 and more than halved the average complexity since 2022, demonstrating how measurement-driven approaches can improve code maintainability and security.
Table of contents
ComplexitycurlThe worstA goalGraph complexity distributionGraph average complexityAnalyzers like it tooRefactors could shake things upFunction lengthA CI job to keep us honestTowards the goalEverything is publicSort: