• Icon: Sub-task Sub-task
    • Resolution: Unresolved
    • Icon: Low Low
    • Coding style
    • None

      https://docs.moodle.org/dev/Coding_style#Wrapping_lines

      if (a_long_condition() &&
              a_nother_long_condition()) {
          do_something();
      }
      

      https://docs.moodle.org/dev/Coding_style#Wrapping_Control_Structures

      $coursecategory = ($element['object']->is_course_item() or $element['object']->is_category_item());
      $scalevalue = in_array($element['object']->gradetype, array(GRADE_TYPE_SCALE, GRADE_TYPE_VALUE));
       
      if ($coursecategory and $scalevalue) {
      

      So do we add to new line with extra spaces, or do we break it into variable assignments with tests?

      My preference is a variation on the latter:

      $dosomething = a_long_condition();
      $dosomething = $dosomething && a_nother_long_condition();
       
      if ($dosomething) {
          do_something();
      }
      

      Either way, the examples offer opposing advice - the 'good' example in wrapping control structure is basically the 'bad' example in wrapping lines.

            poltawski Dan Poltawski
            dobedobedoh Andrew Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.