1

I have this statement:

return ++$maxContratNum;

SonarQube display this message:

Extract this increment or decrement operator into a dedicated statement

what's meaning this message ??

Thank you

fatma_wings
  • 113
  • 1
  • 15
  • try to increment the number before returning it rather than returning as incrementing. example: `$return_value = ++$maxContratNum;return $return_value;` – coderodour Nov 27 '17 at 17:08

1 Answers1

1

The message is trying to tell you to write like this:

++$maxContratNum;
return $maxContratNum;

Written this way, it's perfectly clear that the value of $maxContratNum is incremented, and the function returns that incremented value.

If you write return ++$maxContratNum;, that may be confusing to some readers.

janos
  • 120,954
  • 29
  • 226
  • 236