Hacker News new | ask | show | jobs
by williamdclt 2024 days ago
Some linters (eg ESLint) have rules you can enforce for cyclomatic complexity (which is often the problem with long functions, rather than the length itself). In the service I maintain, we enforce a cyclomatic complexity of 5, which is pretty low but it yielded good results
1 comments

Doesn't a cyclomatic complexity limit of 5 basically rule out the switch statement?
Good question, I suppose it would? On the other hand we do have chunky switch statements (as it allows exhaustive type checking in Typescript), so not so sure now that I think about it, I'd have to check