Moodle plugins directory: Code-checker: Versions: 3.1.0 - Fondant chocolate | Moodle.org
Code-checker
Code-checker 3.1.0 - Fondant chocolate
Moodle Code Checker
Changes in version 3.1.0 (20220225) - Fondant chocolate
- PR#176: Avoid some
use
statements to make theMOODLE_INTERNAL
check to be required (stronk7). - PR#177: Make it possible to show the erroring standard/sniff/rule in the UI executions (Ruslan Kabalin).
- PR#178: Warn, for Moodle 4.0 and up, about unit tests missing coverage information (stronk7).
- PR#180: Allow
@codeCoverageIgnore
annotations in inline comments (stronk7). - PR#181: Apply the
ValidFunctionName
sniff to all scoped tokens (stronk7). - PR#183: Ensure that the "other" checks do observe UI defined exclusions (stronk7).
- PR#186: Add support for installing via Composer (Andrew Lyons).
- PR#190: Control spacing around array indexes (stronk7).
- PR#191: Fix a problem about not detecting relevant code in files without any artifact (stronk7).
- Various small fixes and tweaks.
Information
This Moodle plugin uses the PHP CodeSniffer tool to check that code follows the Moodle coding style. It implements and reuses a set of 'sniffs' that check many aspects of the code, including the awesome PHPCompatibility ones.
It was created by developers at the Open University, including Sam Marshall, Tim Hunt and Jenny Gray. It is now maintained by Moodle HQ.
Available releases can be downloaded and installed from .
To install it using git, type this command in the root of your Moodle install:
git clone git://github.com/moodlehq/moodle-local_codechecker.git local/codechecker
Then add /local/codechecker to your git ignore.
Additionally, remember to only use the version of PHPCS located in phpcs/bin/phpcs
rather than installing PHPCS directly. Add the location of the PHPCS executable to your system path, tell PHPCS about the Moodle coding standard with phpcs --config-set installed_paths /path/to/moodle-local_codechecker
and set the default coding standard to Moodle with phpcs --config-set default_standard moodle
. You can now test a file (or folder) with: phpcs /path/to/file.php
.
Alternatively, download the zip from , unzip it into the local folder, and then rename the new folder to "codechecker".
After you have installed this local plugin, you should see a new option in the settings block:
> Site administration -> Development -> Code checker
We hope you find this tool useful. Please feel free to enhance it. Report any idea or bug in the Tracker, thanks!
Composer installation
- Install via composer:
composer global require moodlehq/moodle-local_codechecker
This will install the correct version of phpcs, with the Moodle rules installed, and install the rules.
You can set the Moodle standard as the system default:
phpcs --config-set default_standard moodle
This will inform most IDEs automatically.
IDE Integration
Eclipse:
- Outdated!: If if you use Eclipse for development, you might want to install the PHP CodeSniffer plugin (http://www.phpsrc.org/).
- Create a new "CodeSniffer standard" in the preferences page.
- Point it at the moodle directory inside the codechecker folder.
- Thank Michael Aherne from University of Strathclyde who worked this out!
PhpStorm
- Install the phpcs cli tool
- Open PhpStorm preferences
- Go to PHP > CodeSniffer and supply the path to the phpcs executable
- Go to Inspections > PHP > PHP Code Sniffer Validation
- In the 'coding standard' dropdown select 'custom' and press the [...] button next to the path to the coding standard. Point is at the moodle directory inside the this plugin directory.
Sublime Text
Find documentation here.
- Install PHP CS following steps described in this moodle docs page.
- Go in your Sublime Text to Preferences -> Package Control -> Package Control: Install Package
- Write 'phpcs' in the search field, if you see Phpcs and SublimeLinter-phpcs, click on them to install them.
- If not, check if they are already installed Preferences -> Package Control -> Package Control: Remove Package.
To set your codecheck to moodle standards go to Preferences -> Package Settings -> PHP Code Sniffer -> Settings-User and write:
{ "phpcs_additional_args": { "--standard": "moodle", "-n": " }, }
If you don’t have the auto-save plugin turned on, YOU’RE DONE!
If you have the auto-save plugin turned on, because the codecheck gets triggered on save, the quick panel will keep popping making it impossible to type. To stop quick panel from showing go to Settings-User file and add:
"phpcs_show_quick_panel": false,
The line with the error will still get marked and if you’ll click on it you’ll see the error text in the status bar.
VSCode
Find documentation here.
- Install PHP CS following steps described in this moodle docs page.
- Install PHPSniffer.
Open VSCode settings.json and add the following setting to define standard PHP CS (if you haven't set it as default in your system):
"phpSniffer.standard": "moodle",
Version information
- Version build number
- 2022022500
- Version release name
- 3.1.0 - Fondant chocolate
- Can be updated to
- 4.0.2 - Comp-at-ibility (2023012000), 4.0.3 - Valentine's D (2023021400), 5.0.3 - Bumping bumps (2023121900), 5.0.4 - Depend-a-bot (2024012600), 5.0.5 - Fools plus 9 (2024041000)
- Maturity
- Stable version
- MD5 Sum
- 80ba17e7f6349b9c3bab84e4b889679f
- Supported software
- PHP 7.0, PHP 7.1, Moodle 3.4, PHP 7.2, Moodle 3.5, Moodle 3.6, Moodle 3.7, PHP 7.3, PHP 7.4, Moodle 3.8, Moodle 3.9, Moodle 3.10, Moodle 3.11, PHP 8.0, Moodle 4.0
- Latest release for Moodle 3.4
- Latest release for Moodle 3.5
- Latest release for Moodle 3.6
- The more recent release 4.0.8 - Few hours later (2023092300) exists for Moodle 3.7
- The more recent release 5.0.5 - Fools plus 9 (2024041000) exists for Moodle 3.8
- The more recent release 5.0.5 - Fools plus 9 (2024041000) exists for Moodle 3.9
- The more recent release 5.0.5 - Fools plus 9 (2024041000) exists for Moodle 3.10
- The more recent release 5.0.5 - Fools plus 9 (2024041000) exists for Moodle 3.11
- The more recent release 5.0.5 - Fools plus 9 (2024041000) exists for Moodle 4.0
Version control information
- Version control system (VCS)
- GIT
- VCS repository URL
- VCS branch
- master
- VCS tag
- v3.1.0
Default installation instructions for plugins of the type General plugins (Local)
- Make sure you have all the required versions.
- Download and unpack the module.
- Place the folder in the "local" subdirectory.
- Visit http://yoursite.com/admin to finish the installation.