## General plugins (Local): Code-checker

local_codechecker
Maintained by Tim Hunt, Eloy Lafuente (stronk7)
A tool for developers that helps them follow Moodle's coding style.
284 sites
18 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.

### Contributors

Eloy Lafuente (stronk7)

### Awards

• Tue, 4 Aug 2015, 9:14 PM
$uniqueperformanceinfotoken - as it says on https://docs.moodle.org/dev/Coding_style#Variables The comment style is really not important. I don't know why Eloy implemented it. (Eloy says he implemented it because I said he should, but I don't remember that.) Anyway, the point of coding style is readability, so that when you are trying to understand some code, there are as few irrelevant distractions as possible. • 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. • 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.
• 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
• 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
• 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.
• 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
• Tue, 1 Dec 2015, 10:30 PM
I don't understand, used plugins like?
• Tue, 1 Mar 2016, 10:50 PM
"More documentation" link above should probably point to https://docs.moodle.org/dev/CodeSniffer rather than style documentation. Not sure though.
• 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?
• Mon, 21 Nov 2016, 5:19 AM
Hi Derek, just for reference, there is https://tracker.moodle.org/browse/CONTRIB-5158 about that. It's old, but any movement towards that feature should happen there.
• 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. (https://docs.moodle.org/dev/Database)".
• 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.
• Sat, 12 Aug 2017, 1:26 AM
Hi,

I find it odd that while code checker is available for Moodle branches up to 3.3 , AMOS only host the plugin's English language strings for branches up to 3.1.

According to the documentation in https://docs.moodle.org/dev/Translating_plugins#If_translations_are_available_in_AMOS_for_some_Moodle_branches_but_not_available_for_other_branches , "The cause is very likely a programming error (see 'Plugins with coding errors' above), that must be fixed by the plugin maintainer. ".

I do not want to seem ironic, but I think it would be very good to fix this soon

Tim Hunt and Eloy Lafuente are two of the best known/respected/loved/productive Moodle heroes for many of us.