Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-4144 META: Code checker 1Q 2014 round
  3. CONTRIB-3562

Code-checker reports HTML-inside-PHP indentation as incorrect, when it is correct

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.2
    • Fix Version/s: 2.3.5, 2.4.2
    • Component/s: Local: Code checker
    • Labels:
      None
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE

      Description

      I have been using the code-checker to help upgrade some previously-1.9 code to 2.x, and I have noticed that indentation is sometimes reported as incorrect when it is not (as far as I am aware).

      In the below (example) scenario, when breaking out of PHP to add a block of HTML, the codechecker suggests that lines 4 to 10 are incorrectly indented:

       
      01. <?php
      02. if (1=1) {
      03.     $somevar = true;
      04. ?>
      05. <div>
      06.     <p>
      07.         <span>some page content</span>
      08.     </p>
      09. </div>
      10. <?php
      11. }
      12. ?>

      The code-checker identifies line 3 as intented correctly, but then expects the PHP tags and HTML to be similarly indented, which I do not believe should be the case. Example error:

      <center>
      472: Line indented incorrectly; expected at least 4 spaces, found 0

      I don't think that when breaking out of PHP into HTML the indentation should be maintained. Certainly this is not the case from many chunks of code I have seen: HTML maintains its own intentation, sometimes using two spaces instead of four, sometimes using no indentation at all.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Mar/13