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

被返回的表达式不应为相同的常量

8.33 ID_returnSameConst
目录 › next › previous

被返回的表达式均为相同的常量是没有意义的。

示例:

bool foo(int a) {
    if (a > 100) {
        return true;
    }
    if (a > 50) {
        return true;
    }
    return true;   // Non-compliant, all the values returned are the same
}
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.