![]() |
![]() |
2004 | ![]() |
||||
![]() | |||||||
| Control flow | |||||||
No 'else' clause has been encountered following this 'if' ... 'else if' construct. This style is not permitted in some programming standards. An 'else' is considered important in the interests of logical completeness. Notice that message 2004 is only generated for an if statement without an 'else' clause, when the if is immediately preceded by the else keyword; otherwise, message 2000 is generated. For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 2000, 2004 --*/
extern int gx;
extern int gy;
extern void foo1(int n)
{
if (n < 10)
{
++gx;
}
else if (n < 20) /* OK */
{
++gy;
}
else
{
}
}
extern void foo2(int n)
{
if (n < 10)
{
++gx;
}
else
{
if (n < 20) /* Message 2000 */
{
++gy;
}
}
}
extern void foo3(int n)
{
if (n < 10)
{
++gx;
}
else if (n < 20) /* Message 2004 */
{
++gy;
}
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |