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
{
}
}