moodle-extra doesn't catch 'Functions must not contain multiple empty lines in a row'
individual-it opened this issue · comments
my .phpcs.xml
looks like this
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MoodleCore">
<rule ref="moodle-extra"/>
</ruleset>
and in db/install.php
I have this code:
} else {
$issuerdata->image = $ocislogourl;
}
$issuer = core\oauth2\api::create_issuer($issuerdata);
$result = $issuer->is_valid();
if (!$result) {
return $result;
}
The multi empty line issue is not reported by phpcs
When I change the rule to <rule ref="moodle"/>
it works correctly.
The Moodle-extra ruleset needs to also be included with the Moodle ruleset as per the docs. Can you check with that config?
Same issue, if I add both moodle
and moodle-extra
I think moodle
is already included in moodle-extra
, see https://github.com/moodlehq/moodle-cs/blob/main/moodle-extra/ruleset.xml#L10
btw. the local/codechecker
plugin detects the issue correctly
This is a curious case, I've tried here with this simple php script:
<?php // phpcs:disable moodle
function something() {
echo "Hello World";
echo "Hello World";
echo "Hello World";
}
And this is what I get:
With the "moodle" standard:
$ vendor/bin/phpcs -s --standard=moodle pp.php && echo "ok!" || echo "problem!"
FILE: /Users/stronk7/git_moodle/moodle/pp.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
| | (Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines)
----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------
Time: 245ms; Memory: 16MB
problem!
With the "moodle-extra" standard:
$ vendor/bin/phpcs -s --standard=moodle-extra pp.php && echo "ok!" || echo "problem!"
ok!
(I've tried the above with the testing file being within Moodle, within moodle-cs and in an empty directory, to avoid any [.]phpcs.xml[.dist]
interference. Same result always)
Really curious, I've over-looked the moodle-extra
ruleset and have not found anything disabling that SuperfluousWhitespace
sniff. Sure that there is a reason, but we have to find it.
Ciao :-)