Hacker News new | ask | show | jobs
by amirkdv 1764 days ago
> Lots of code metrics have been proposed ... But nothing works better than counting lines of code [with citations]

Here's an anecdoate, not to dispute the empirical finding.

I recently discovered McCabe (cyclomatic) complexity and found it remarkably good! In a tiny experiment, I ran it on a 50k Python code base with a threshold of 8, and the output almost exactly matched all of the already existing `FIXME: refactor this` comments. According to McCabe the threshold to look out for is 10.

---

p.s: if you write Python, you already probably have the mccabe package installed through flake8. Use it like so:

    $ python -m mccabe --min 8 foo.py