☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

函数的行数应在规定范围之内

8.40 ID_tooManyLines
目录 › next › previous

函数体过大违反模块化编程理念,使人难以阅读,更不便于维护,应适当重构。

示例:

int main()
{
    // ... 3000 lines ...
    // Who has the courage to read?
}

建议函数体不超过 60 行,以不需要拖拽滚动条就可以在屏幕上完整显示为宜。

配置

maxLineCount: 函数行数上限,超过则报出

参考

C++ Core Guidelines F.2 C++ Core Guidelines F.3
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.