Re: Goal: reduce overall function complexity

Dan Fandrich via curl-library <[email protected]>
Newsgroups gmane.comp.web.curl.library
Message-ID <[email protected]>
On Wed, May 14, 2025 at 11:28:48PM +0200, Daniel Stenberg via curl-library wrote:
> Wouldn't it be cool to set a cap and make a subsequent CI job that turns red if any single
> function in product code is too complex? As a way to make sure we keep the code clean and
> readable.

Sounds like a noble goal to me.

> If this number is 100 or less we are good. If not, one or more functions are too complex.

According to Wikipedia, McCabe suggested a limit of 10 and NIST later suggested
some situations where 15 might be appropriate. So, 100 seems like a good
starting point!

> Right now, the top-10 most complex functions in production code according to this tool are (score,
> filename, line number, function name):

If the current few known-bad offenders are added to a whitelist, it becomes
easier to ratchet this number down over time. In fact, depending on how many
high-value functions there currently are, it might be better to start out with
a larger whitelist and lower limit.

Dan
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.