Skip to content

Commit

Permalink
Merge pull request #117 from stronk7/code_cleanup_psr12
Browse files Browse the repository at this point in the history
Define moodle-cs own standard, towards better coding
  • Loading branch information
andrewnicols authored Feb 25, 2024
2 parents e2fdd2f + 313e171 commit de914c0
Show file tree
Hide file tree
Showing 62 changed files with 1,480 additions and 1,371 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
if: ${{ !cancelled() }}
run: ./vendor/bin/phpcpd --exclude moodle/Tests moodle

- name: Coding style
if: ${{ !cancelled() }}
run: ./vendor/bin/phpcs -ps .

- name: Run phpunit
if: ${{ !cancelled() }}
run: |
Expand Down
17 changes: 14 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
vendor
# Composer stuff
composer.lock
phpcs.xml
composer.phar
vendor

# PHP_CodeSniffer
.phpcs.xml
phpcs.xml
!phpcs.xml.dist

# PHPUnit
.phpunit.result.cache
phpunit.xml
.phplint-cache
clover.xml
.phpunit.cache

# PHPlint
.phplint.cache

# IDEs and editors
.vscode
15 changes: 9 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Change log

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This project adheres to [Semantic Versioning](https://semver.org/).

The format of this change log follows the advice given at [Keep a CHANGELOG](http://keepachangelog.com).
The format of this change log follows the advice given at [Keep a CHANGELOG](https://keepachangelog.com).

## [Unreleased]
### Added
- Add new `moodle.Commenting.Package` sniff to replace those present in moodle-local_moodlecheck.
- Add new `moodle.Commenting.Category` sniffs to replace those present in moodle-local_moodlecheck.
- New `phpcs.xml.dist` to enforce the coding style to follow by ´moodle-cs´ itself. Basically, PSR12 ruled. CI verified from now on.

### Changed
- Update composer dependencies to current versions, notably `PHP_CodeSniffer` (3.9.0) and `PHPCompatibility` (e5cd2e24).

### Added
- Add new moodle.Commenting.Package sniffs to replace those present in moodle-local_moodlecheck.
- Add new moodle.Commenting.Category sniffs to replace those present in moodle-local_moodlecheck.
- As part of the move to be PSR12 compliant, all the methods used for testing have been converted, without deprecation, to camel case (`setStandard()`, `setSniff()`, ...).
- ACTION REQUIRED: Any clone/fork using `moodle-cs` and having own tests will need to adapt them to the new method names.

### Fixed
- The moodle.Files.MoodleInternal sniff no longer treats Attributes as side-effects.
Expand Down
8 changes: 4 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

Expand All @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/philosophy/why-not-lgpl.html>.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
}
],
"require": {
"php": ">=7.4.0",
"ext-json": "*",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"squizlabs/php_codesniffer": "^3.9.0",
"phpcsstandards/phpcsextra": "^1.2.1",
Expand Down
13 changes: 6 additions & 7 deletions moodle/Sniffs/Commenting/CategorySniff.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
// This file is part of Moodle - http://moodle.org/

// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -12,12 +13,10 @@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.

namespace MoodleHQ\MoodleCS\moodle\Sniffs\Commenting;

// phpcs:disable moodle.NamingConventions

use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil;
use MoodleHQ\MoodleCS\moodle\Util\Docblocks;
use PHP_CodeSniffer\Sniffs\Sniff;
Expand All @@ -27,10 +26,10 @@
* Checks that all test classes and global functions have appropriate @package tags.
*
* @copyright 2024 Andrew Lyons <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class CategorySniff implements Sniff {

class CategorySniff implements Sniff
{
/**
* Register for open tag (only process once per file).
*/
Expand Down
Loading

0 comments on commit de914c0

Please sign in to comment.