Skip to content

Commit

Permalink
Revert "Pick the PHPCSExtra CommaAfterLastSniff Sniff to moodle"
Browse files Browse the repository at this point in the history
This reverts commit 1c295bb.

Now that PHPCSExtra 1.2.0 has been released, we can revert this commit
and switch back to use the upstream Sniff.

A few more modifications (composer...) come to point to the new
PHPCSExtra version.

Fixes moodlehq#82
  • Loading branch information
stronk7 committed Dec 4, 2023
1 parent 009aa39 commit fe954c3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 239 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"phpcsstandards/php_codesniffer": "^3.7.2",
"phpcsstandards/phpcsextra": "^1.1.0",
"phpcsstandards/phpcsextra": "^1.2.0",
"phpcompatibility/php-compatibility": "dev-develop#0a17f9ed"
},
"config": {
Expand Down
226 changes: 0 additions & 226 deletions moodle/Sniffs/Arrays/CommaAfterLastSniff.php

This file was deleted.

8 changes: 4 additions & 4 deletions moodle/Tests/NormalizedArraysArraysCommaAfterLastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @copyright 2023 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* @covers MoodleHQ\MoodleCS\moodle\Sniffs\Arrays\CommaAfterLastSniff
* @covers \PHPCSExtra\NormalizedArrays\Sniffs\Arrays\CommaAfterLastSniff
*/
class NormalizedArraysArraysCommaAfterLastTest extends MoodleCSBaseTestCase
{
Expand All @@ -37,16 +37,16 @@ public function testNormalizedArraysArraysCommaAfterLast() {

// Define the standard, sniff and fixture to use.
$this->set_standard('moodle');
$this->set_sniff('moodle.Arrays.CommaAfterLast');
$this->set_sniff('NormalizedArrays.Arrays.CommaAfterLast');
$this->set_fixture(__DIR__ . '/fixtures/normalizedarrays_arrays_commaafterlast.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors([
79 => '@Source: moodle.Arrays.CommaAfterLast.FoundSingleLine',
82 => '@Source: moodle.Arrays.CommaAfterLast.MissingMultiLine',
79 => '@Source: NormalizedArrays.Arrays.CommaAfterLast.FoundSingleLine',
82 => '@Source: NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLine',
87 => 1,
95 => 1,
97 => 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
defined('MOODLE_INTERNAL') || die(); // Make this always the 1st line in all CS fixtures.

// Disabling this error as we do in our ruleset, so tests run the same.
// phpcs:disable moodle.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine
// phpcs:disable NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine

// All these are good / valid code.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
defined('MOODLE_INTERNAL') || die(); // Make this always the 1st line in all CS fixtures.

// Disabling this error as we do in our ruleset, so tests run the same.
// phpcs:disable moodle.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine
// phpcs:disable NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine

// All these are good / valid code.

Expand Down
7 changes: 1 addition & 6 deletions moodle/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@
Affects all major branches since Moodle 3.9.
Require a comma after the last element in a multi-line array, but prevent in a single-line array definition
TODO: Enable this back and remove our copied Sniff below once PHPCSExtra v1.2.0 is released.
-->
<rule ref="NormalizedArrays.Arrays.CommaAfterLast">
<exclude name="NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine" />
</rule>
-->
<rule ref="moodle.Arrays.CommaAfterLast">
<exclude name="moodle.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine" />
</rule>

<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.Classes.OpeningBraceSameLine"/>
Expand Down

0 comments on commit fe954c3

Please sign in to comment.