在「decomplexification continued」這邊看到很久前有讀過,但已經忘記又重新看到的東西:「Cyclomatic complexity」。
cURL 這邊拿來當作目標,但看起來應該不是直接 optimize 這個指標,而是透過這個指標來找哪些 function 過於複雜的問題 (這邊有個經典的 Goodhart's law 可以參考)。
去年開始看 Cyclomatic complexity 的時候有超過 100 的 function:
In May 2025 I had just managed to get the worst function in curl down to complexity 100, and the average score of all curl production source code (179,000 lines of code) was at 20.8. We had 15 functions still scoring over 70.
十個月的努力,最大的降到 59,然後平均也降下來了:
Almost ten months later we have reduced the most complex function in curl from 100 to 59. Meaning that we have simplified a vast number of functions. Done by splitting them up into smaller pieces and by refactoring logic. Reviewed by humans, verified by lots of test cases, checked by analyzers and fuzzers,
The current 171,000 lines of code now has an average complexity of 15.9.
翻了一下好像可以掛到 CI 裡面去過濾真的太大的 function?

