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

函数的标签数量应在规定范围之内

8.39 ID_tooManyLabels
目录 › next › previous

标签过多意味着函数内部的跳转逻辑过于复杂,违反结构化设计理念,应适当重构。

对于 C 代码,建议一个函数只用一个标签作为函数统一出口,对于 C++ 代码,不建议使用标签。

示例:

void foo()
{
L0:
    ....
L1:
    ....   // Lots of labels require lots of gotos
    ....   // Lots of gotos make functions terrible
L100:
    ....
}

配置

maxLabelCount: 标签数量上限,超过则报出

参考

CWE-1119
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.