[previous] 2005 [next] A 'continue' statement has been used.
Miscellaneous

A 'continue' statement has been used to junp to the end of a control loop.

Many coding standards recommend that 'continue' statements should be avoided. This can usually be achieved by some simple recoding:
while ( ... )
{
    ...
    if ( condition )
    {
        continue;
    }
    ...
}
can be replaced with ...
while ( ... )
{
    ...
    if ( ! condition )
    {
       ...
    }
}

For example:


/*PRQA S 2017,3408 ++*/

#define VALUE 1000

extern void foo1(int gi)
{
  while (gi != 0)
  {
    gi--;
    if (gi == VALUE)
    {
      continue;                         /* Message 0770 and 2005 */
    }
  }
}

extern void foo2(int gi)
{
  while (gi != 0)
  {
    gi--;
    if (gi != VALUE)
    {
        /* SOME CODE */
    }
  }
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents