Topic on Talk:Continuous integration/Codehealth Pipeline

"Remove this redundant jump" giving bad advice

3
Daimona Eaytoy (talkcontribs)

See here. Simplified example:

foreach ( $foo as $bar ) {
   if ( foo1() ) {
      doSomething1();
   } elseif ( foo2() ) {
      continue; // <-- faulty line
   } else {
      doSomething2();
   }
}

The continue line is reported by SonarQube as being non-compliant with message "Remove this redundant jump.". On sonarcloud.io there's an interesting description for this issue: "jump statements that direct the control flow to the original direction are just a waste of keystrokes."

I have a very different idea of "waste of keystrokes". Jump statements make code like that more resilient and reliable. Without the continue, some day I might add some instructions after the conditional (but inside the loop) without any tool telling me of my mistake. So no, this is not a waste of keystrokes.

DKinzler (WMF) (talkcontribs)

Yes, indeed.

This post was hidden by Daimona Eaytoy (history)
Reply to ""Remove this redundant jump" giving bad advice"