Select Moodle version:

General plugins (Local): Code-checker

local_codechecker
A tool for developers that helps them follow Moodle's coding style.
Maintained by: Tim at Lone Pine Koala Sanctuary Tim Hunt, One poor developer... Eloy Lafuente (stronk7)

The code checker tool is based on the Zend PHP CodeSniffer library. It implements a set of 'sniffs' that check for many parts of the Moodle coding style. They also present a nice web interface for viewing the results.

Contributors

One poor developer...
Eloy Lafuente (stronk7)
Tim at Lone Pine Koala Sanctuary
Tim Hunt (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of German Valero
    Fri, Sep 28, 2012, 8:44 AM
    Hi,

    Is it normal to have 92 errors and 23 warnings in the local/codechecker folder?
    It seems odd to me (a non-programmer).

    Thanks in advance,
    German Valero
  • Tim at Lone Pine Koala Sanctuary
    Fri, Sep 28, 2012, 3:47 PM
    Well, I am not sure about normal, but it is unavoidable, because the codechecker plugin contains the third-party codesniffer library which comes from PEAR, and so does not follow the Moodle coding rules.
  • One poor developer...
    Fri, Sep 28, 2012, 4:36 PM
    Yeah, surely all the "errors" are upper / lower case one in the moodle/Sniffs dir. We use codechecker style rules there.

    About the warning... I bet we still have a bunch of them... not fulfilling the "Inline comments must start with upper and end with dot". Next release will fix them (though they are not critical at all).

    Thanks for code-checking the code-checker, btw!
  • Gareth J Barnard
    Fri, Feb 8, 2013, 7:49 PM
    Hi Eloy and Tim,

    Please can 'Inline comments must end in full-stops, exclamation marks, or question marks' be changed to include colons? As it is possible to write '// The following code does something awesome:'

    Cheers,

    Gareth
  • Tim at Lone Pine Koala Sanctuary
    Fri, Feb 8, 2013, 7:51 PM
    It could. It is more likely to happen if:
    1. You file a but in the tracker: CONTRIB / local_codechecker component exists.
    2. You code the change yourself, and submit it as a pull request through github.
  • Picture of Joseph Rézeau
    Thu, Jun 6, 2013, 1:13 AM
    Just downloaded and installed codechecker.

    It's ironical that the codechecker should throw an error re its own code:

    Did you remember to call setType() for 'exclude'? Defaulting to PARAM_RAW cleaning.

    line 1303 of \lib\formslib.php: call to debugging()
    line 281 of \lib\formslib.php: call to moodleform->detectMissingSetType()
    line 202 of \lib\formslib.php: call to moodleform->_process_submission()
    line 46 of \local\codechecker\index.php: call to moodleform->moodleform()
  • One poor developer...
    Thu, Jun 6, 2013, 2:53 AM
    haha, funny! thanks for the report, I'll roll a new minor version soon.
  • One poor developer...
    Thu, Jun 6, 2013, 3:02 AM
    Seems it was already fixed but the new release, planned for the end of April was never rolled. Doing...
  • Picture of Oleg Sychev
    Tue, Jun 25, 2013, 9:26 PM
    When using local_codechecker on our files I found some strange messages from it: some are just overlooked, other may be bugs.

    error
    ························'backtracking_matcher'·=>·'backtracking_matcher'*/
    46: Line indented incorrectly; expected at least 8 spaces, found 0
    It's quite obvious, that there is more than 0 spaces on that line. There is some problem in spaces counting in lines with multiline comments.

    warning
    ····public·function·__construct()·{
    81: Useless method overriding detected
    AFAIK PHP don't call parent constructor automatically, so overriding __construct() just to call parent ones isn't useless at all. This warning may mislead someone.

    error
    ····················foreach·($ranges·as·&$tmp)
    440: Inline control structures are not allowed
    That's totally strange. & in foreach is a common method to change elements of array inside foreach loop. What's wrong with it and what "inline control structures" have to do with such code?


    warning
    ····//·"What·is"·hint·is·obviously·response·based,·since·it·used·to·better·understand·mistake·message.
    68: Inline comments must start with a capital letter, digit or 3-dots sequence
    I suggest adding some punctuation marks, from which a sentence could start: double and single quotes, $ in case comment start from variable names.
    I have also some problematic strings, when comment starts from function or class name, which should be lowercase.
  • Tim at Lone Pine Koala Sanctuary
    Tue, Jun 25, 2013, 9:49 PM
    The indent problem seems to be getting confused by some commented out code, but you should not leave commented out code around. (It should be saved in git history.

    If a PHP class does not have a constructor at all, then the parent constructor is automatically used, so that warning is correct

    The foreach does not have a { after the ). It is nothing to do with the &.

    Comment starting with uppercase is just a pain. Blame Eloy wink
  • One poor developer...
    Tue, Jun 25, 2013, 10:06 PM
    Oleg:

    1) yup, looks like commented code mix. More context lines would help to confirm it.

    2) yup, any method only having a call to its parent is useless. Just allow inheritance to work, constructors included.

    3) yup, curly brace is expected.

    4) no, don't blame me. Blame code style guidelines, I'm not the inventor, just the implementor (in fact I think it was Tim the inventor). Easy to replace with: The "What is" hint... anyway. Have been attempts to open the hand a bit with this, but all them have been rejected.

    Ciao smile
  • Picture of Marina Glancy
    Wed, Jul 10, 2013, 10:36 AM
    upon MDLSITE-2339 I changed the description to include words "code checker" smile
Please login to post comments