OCLint的部分规则(Empty 部分)

40 篇文章 0 订阅
17 篇文章 0 订阅

OCLint的部分规则(Empty 部分)

对OCLint的部分规则进行简单翻译解释,有部分进行了验证以及进一步分析、测试。OCLint其他相关内容如下:

--
OCLint-iOS-OC项目几种简单使用OCLint的部分规则(Basic 部分)
OCLint的部分规则(Unuseed 部分)OCLint的部分规则(Size 部分)
OCLint的部分规则(Redundant 部分)OCLint的部分规则(Naming 部分)
OCLint的部分规则(Migration 部分)OCLint的部分规则(Empty 部分)
OCLint的部分规则(Design 部分)OCLint的部分规则(Convention 部分)
OCLint的部分规则(CoCoa 部分)



1、empty catch statement

      Since:0.6 定义类传送门~点击

This rule detects instances where an exception is caught, but nothing is done about it.

简单解释:捕获了异常,在Catch中什么都没有做的情况。

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

      Since:0.6 定义类传送门~点击

This rule detects instances where do-while statement does nothing.

简单解释:空的do-while检查。

    void example() {
        do
        {                           // empty do-while statement
        } while(1);
    }
3、empty else block

      Since:0.6 定义类传送门~点击

This rule detects instances where a else statement does nothing.

简单解释:空的else检查。

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

      Since:0.6 定义类传送门~点击

This rule detects instances where a finally statement does nothing.

简单解释:空的finally检查。

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

      Since:0.6 定义类传送门~点击

This rule detects instances where a for statement does nothing.

简单解释:空的for语句检查。

    void example(NSArray *array) {
        for (;;)                // empty for statement
        {
        }
        for (id it in array)    // empty for-each statement
        {
        }
    }
6、empty if statement

      Since:0.2 定义类传送门~点击

This rule detects instances where a condition is checked, but nothing is done about it.

简单解释:空的if检查。

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

      Since:0.6 定义类传送门~点击

This rule detects instances where a switch statement does nothing.

简单解释:空的switch检查。

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

      Since:0.6 定义类传送门~点击

This rule detects instances where a try statement is empty.

简单解释:空的try检查。

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

      Since:0.6 定义类传送门~点击

This rule detects instances where a while statement does nothing.

简单解释:空的while检查。

    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、付费专栏及课程。

余额充值