high ncss method 方法有效代碼行太高
某個代碼塊中代碼行數(shù)過多(只統(tǒng)計有效的語句),查看代碼塊中代碼是否能拆分,公共功能能否提供一個公共接口??照Z句,空塊,右括號或分號后的右括號會被忽略。(default value is 30)
void example() // 1
{
if (1) // 2
{
} else // 3
{
}
}
Long method 太長的方法
方法太長,影響閱讀,應(yīng)該實現(xiàn)單一職責。(default value is 50)
void example() {
cout << "hello world";
cout << "hello world";
// repeat 48 times
}
unnecessary default statement in covered switch statement
如果switch覆蓋了所有的條件,default是不需要的應(yīng)該被移除。如果不是default還是需要的
typedef enum {
value1 = 0,
value2 = 1
} eValues;
//
void aMethod(eValues a)
{
switch(a)
{
case value1:
break;
case value2:
break;
default: // this break is obsolete because all
break; // values of variable a are already covered.
}
}