General plugins (Local): Code-checker

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

The code checker tool is based on the 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.


Screenshot #0
Screenshot #1


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

Comments RSS

Show comments
  • Picture of Urs Hunkler
    Tue, 4 Aug 2015, 10:40 PM
    Eloy, in the case you read the comments - please consider to remove the »Inline comments must end in full-stops, exclamation marks, or question marks« errors.
  • Picture of Urs Hunkler
    Tue, 4 Aug 2015, 10:50 PM
    Yep, »the point of coding style is readability«. But I have difficulties to read $uniqueperformanceinfotoken - $unique_performance_info_token is much easier to read. But with the info from the coding style page you had linked to »keep them short as possible« the varianble may have been named something like $perfinfotoken.

    I don't complain - it's just a complex field and I am just starting dig deeper into Moodle coding style.
  • One poor developer...
    Mon, 10 Aug 2015, 5:12 PM
    Hi Urs,

    sorry for the delay, I've been out last weeks and has been long to catch up with everything on return.

    Mimicking (and joking) Tim: The comment style is really not important. I don't know why Tim proposed it. It was proposed, voted and agreed, so I don't think we are going to vote it again soon. I just implemented it.

    In any case, it's only a warning. If anything you should be looking for errors only, warnings are recommendations, basically.

    Ciao smile
  • One poor developer...
    Mon, 10 Aug 2015, 5:25 PM
    Hi Gareth,

    somehow I missed your comment above about some operators not being detected properly when looking for whitespace around them. I've create CONTRIB-5862 about that, for reference.

    Ciao smile
  • Picture of Urs Hunkler
    Mon, 10 Aug 2015, 11:41 PM
    Thanks for your feedback Eloy. You recommend to »ignore« warnings - I can turn off PHP Code Sniffer warnings in the IDE to avoid the not relevant PHP Code Sniffer feedback. Great and thanks.
  • One poor developer...
    Tue, 11 Aug 2015, 12:27 AM
    LOL, Urs.

    I don't recommend to ignore warnings. In fact, I do recommend to check both errors and warnings. More yet, I do check both always.

    I only say that, while errors are clear violations, warnings can be understood as recommendations. If you decide to follow or ignore them it's up to you. Personally I follow them, it's not so hard, really. But your choice, anyway.

    Ciao smile
  • Picture of Nguyễn Tuấn Anh
    Tue, 1 Dec 2015, 10:30 PM
    I don't understand, used plugins like?
  • Picture of Ruslan Kabalin
    Tue, 1 Mar 2016, 10:50 PM
    "More documentation" link above should probably point to rather than style documentation. Not sure though.
  • Picture of Derek Henderson
    Wed, 5 Oct 2016, 11:16 PM
    Would it be possible to include the latest version of the PHPCompatibility sniff and also add in the ability to pass in versions, so the code can be tested against different versions?
  • One poor developer...
    Mon, 21 Nov 2016, 5:19 AM
    Hi Derek, just for reference, there is about that. It's old, but any movement towards that feature should happen there.
  • Picture of Dasu Gunathunga
    Tue, 1 Aug 2017, 10:59 AM
    Hi Tim,
    This doesn't check the column names in install.xml file. There is a coding standard for the column names as well. "Column names should be always lowercase, simple and short, following the same rules as for variable names. (".
  • Tim at Lone Pine Koala Sanctuary
    Tue, 1 Aug 2017, 3:28 PM
    You should be using the XMLDB editor built in to Moodle, to edit your database definitions (Admin -> Development -> XMLDB editor). That checks the rules for you. I agree it would be nice to have the same checks in codechecker, but not essential.
  • This is a picture of me
    Tue, 26 Jun 2018, 3:38 AM
    Hi there,

    What are the thoughts of having the code checker ignore code folding? Does code folding need to be defined in the Moodle coding style before being allowed in the code checker?

    /// <editor-fold desc="This is a bunch of code that does stuff">
    /// </editor-fold>
  • Tim at Lone Pine Koala Sanctuary
    Tue, 26 Jun 2018, 5:43 AM
    If you want a 'bunch of code that does stuff' (with documentation, code folding, etc.) surely that is a function, and refactoring Moodle code to make it more understandable is encouraged.

    I don't know which editor you are using for that syntax to work. I have never seen it before, but doing something just for one editor is less likely to be a sensible decision.

    So, given we want to encourage well-factored code, not long sprawling blocks of code, and we want to be editor-neutral, I am not enthusiastic about your suggestion.
1 2 3

Commenting temporarily disabled