Hacker News new | ask | show | jobs
by tstrimple 768 days ago
There's the cyclomatic complexity which I think gets close to your reference counting example.

https://en.wikipedia.org/wiki/Cyclomatic_complexity

But I don't think that captures most of the "too clever" stuff I typically see. That's usually some abomination of a one liner that does way too much. Those won't get picked up by cyclomatic complexity measurements. Furthermore, I find cyclomatic complexity tends to come from less experienced developers rather than experienced developers trying to be clever.

If you're genuinely wondering if something is too clever, ask that junior dev to explain it to you. After all, they will probably be the ones to end up maintaining it later.