Infer bug types
写这个文档的人也是很粗心,总览说是OC/C的bug类型,但是在详细说明中,却说只有OC有,比如Parameter not null checked
总览
Java中捕捉的bug类型
- Resource leak
- Null dereference
C/OC中捕捉的bug类型
- Resource leak
- Memory leak
- Null dereference
- Premature nil termination argument
只在 OC中捕捉的bug类型
- Retain cycle
- Parameter not null checked
- Ivar not null checked
Resource leak
资源泄漏的问题在Java/C/OC都存在,资源代表文件,sockets,连接等等,使用后需要关闭。
Memory leak
内存泄漏的问题只在C/OC中报告
Retain cycle
内存死锁只存在OC中,A 创造B,B也创造了A,然后你等我,我等你,都无法释放
Null Dereference
Java/OC/C都会报告空引用的问题,当一个对象声明后,没有初始化,就被引用了,这个时候会报空指针错误。
Parameter not null checked
只在OC中报告,参数不能为空的检查,此类bug和空引用的错误是类似的,但是infer把这类问题单独出来了。
Ivar not null checked
本地变量不为空的检查
Premature nil termination argument
这类错误在C/OC中报告,有一些语句会在中途由于nil的出现造成了语句失败,比如:
NSArray *foo = [NSArray arrayWithObjects: @"aaa", str, @"bbb", nil];
如果str为nil,创建NSArray的字符串就失败了.