CCN java 函数 - 是否有任何关于实际限制的指南
我正在使用 javancss 来检测方法的 CCN 。我们的源代码中有一些方法的值从 1 到 35 不等(甚至很大)。
是否有任何关于实际限制的指导方针?这里的文章给出了一些想法 - http://java-metrics.com/cyclomatic-complexity/cyclomatic-complexity-what-is-it-and-why-should-you-care
我认为 10 作为软限制,15作为硬限制..主要原因是测试随着值的增大而变得复杂..
我想听听SO社区的意见..
I am using javancss to detect CCN of methods. There are methods in our source code with values varying from 1 to 35 (are are even large).
Is there any guide line on what could be realistic limit? The article here gives some ideas -- http://java-metrics.com/cyclomatic-complexity/cyclomatic-complexity-what-is-it-and-why-should-you-care
I am thinking of 10 as soft limit and 15 as hard limit.. Main reason is that testing gets complicated with larger values..
I would like to hear from SO community..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用两种方法:
另一种使用的方法是在修复错误时非常严格 - 检查源代码控制以查看更改了哪些方法来修复错误。重构这些方法以降低其复杂性。
I have two methods I use:
Another method to use is to be very rigorous when fixing bugs - check back with source control to see which methods changed to fix the bug. Refactor those methods to reduce their complexity.
正如您的链接文件中也提到的,我认为最重要的方面是您不认为 10 或 15 的限制是硬性限制,但如果超出限制,请始终给出充分的理由。这样,您就“被迫”仔细检查关键方法,并检查它们是否真的有必要如此复杂。
As also mentioned in your link paper I think the most important aspect is that you don't see the limit of 10 or 15 as a hard limit, but always give a good justification if the limit is exceeded. In that way you're ''forced'' to carefully examine critical methods and check if is really necessary that they are this complex.