oclint规则 Empty

12 篇文章 0 订阅
11 篇文章 0 订阅

Empty

空Catch语句EmptyCatchStatement

Since: 0.6

检测捕获了异常,却在Catch中什么都没有做的情况。

定义类: oclint-rules/rules/empty/EmptyCatchStatementRule.cpp

Example:

void example()
{
    try
    {
        int* m= new int[1000];
    }
    catch(...)                  // empty catch statement, this swallows an exception
    {
    }
}

空Do While 语句 EmptyDoWhileStatement

Since: 0.6

检测什么都没有做的do While语句.

定义类: oclint-rules/rules/empty/EmptyDoWhileStatementRule.cpp

Example:

void example()
{
    do
    {                           // empty do-while statement
    } while(1);
}

空else语句 EmptyElseBlock

Since: 0.6

空else语句检测

定义类: oclint-rules/rules/empty/EmptyElseBlockRule.cpp

Example:

int example(int a)
{
    if (1)
    {
        return a + 1;
    }
    else                // empty else statement, can be safely removed
    {
    }
}

空Finally语句 EmptyFinallyStatement

Since: 0.6

Finally空语句检测.

定义类: oclint-rules/rules/empty/EmptyFinallyStatementRule.cpp

Example:

void example()
{
    Foo *foo;
    @try
    {
        [foo bar];
    }
    @catch(NSException *e)
    {
        NSLog(@"Exception occurred: %@", [e description]);
    }
    @finally            // empty finally statement, probably forget to clean up?
    {
    }
}

空for语句 EmptyForStatement

Since: 0.6

检测什么都没有做的for语句.

定义类: oclint-rules/rules/empty/EmptyForStatementRule.cpp

Example:

void example(NSArray *array)
{
    for (;;)                // empty for statement
    {
    }

    for (id it in array)    // empty for-each statement
    {
    }
}

空IF语句 EmptyIfStatement

Since: 0.2

检测if判断中什么都没有做.

定义类: oclint-rules/rules/empty/EmptyIfStatementRule.cpp

Example:

void example(int a)
{
    if (a == 1)                  // empty if statement
    {
    }
}

空Switch语句 EmptySwitchStatement

Since: 0.6

检测空的Switch语句。.

定义类: oclint-rules/rules/empty/EmptySwitchStatementRule.cpp

Example:

void example(int i)
{
    switch (i)              // empty switch statement
    {
    }
}

空Try语句 EmptyTryStatement

Since: 0.6

空Try语句检测.

定义类: oclint-rules/rules/empty/EmptyTryStatementRule.cpp

Example:

void example()
{
    try                     // but this try statement is empty
    {
    }
    catch(...)
    {
        cout << "Exception is caught!";
    }
}

空While语句 EmptyWhileStatement

Since: 0.6

检测空的While语句.

定义类: oclint-rules/rules/empty/EmptyWhileStatementRule.cpp

Example:

void example(int a)
{
    while(a--)              // empty while statement
    {
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值