-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore line length limit in docblocks
Note: This does not apply to inline docs. We should _perhaps_ limit this to things like Behat @Given/When/Then but there are other times when this is not helpful too.
- Loading branch information
1 parent
77730c5
commit bb27cfc
Showing
4 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
// 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 | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// 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 <https://www.gnu.org/licenses/>. | ||
|
||
namespace MoodleHQ\MoodleCS\moodle\Tests\Sniffs\Commenting; | ||
|
||
use MoodleHQ\MoodleCS\moodle\Tests\MoodleCSBaseTestCase; | ||
|
||
/** | ||
* Test the MissingDocblockSniff sniff. | ||
* | ||
* @copyright 2024 onwards Andrew Lyons <[email protected]> | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* | ||
* @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Commenting\MissingDocblockSniff | ||
*/ | ||
class LineLengthSniffTest extends MoodleCSBaseTestCase | ||
{ | ||
/** | ||
* @dataProvider fixtureProvider | ||
*/ | ||
public function testSniffWithFixtures( | ||
string $fixture, | ||
?string $fixturePath, | ||
array $errors, | ||
array $warnings | ||
): void { | ||
// xdebug_break(); | ||
$this->setStandard('moodle'); | ||
$this->setSniff('moodle.Files.LineLength'); | ||
$this->setFixture( | ||
sprintf("%s/fixtures/LineLength/%s.php", __DIR__, $fixture), | ||
$fixturePath, | ||
); | ||
$this->setErrors($errors); | ||
$this->setWarnings($warnings); | ||
|
||
$this->verifyCsResults(); | ||
} | ||
|
||
public static function fixtureProvider(): array { | ||
$cases = [ | ||
[ | ||
'fixture' => 'langfile', | ||
'fixturePath' => '/lang/en/assignfeedback_editpdf.php', | ||
'errors' => [], | ||
'warnings' => [], | ||
], | ||
[ | ||
'fixture' => 'standard', | ||
'fixturePath' => null, | ||
'errors' => [ | ||
13 => 'Line exceeds maximum limit of 180 characters; contains 182 characters', | ||
], | ||
'warnings' => [ | ||
|
||
], | ||
], | ||
]; | ||
return $cases; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
$string['example_of_a_very_long_string_name'] = 'This is an example of a very long string with a vey long name which combined will exceed the maximum lenth of your typical Moodle coding style'; |
16 changes: 16 additions & 0 deletions
16
moodle/Tests/Sniffs/Files/fixtures/LineLength/standard.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
class Example | ||
{ | ||
/** | ||
* This is an example of a very long string within the docblock of a class. | ||
* | ||
* Checks that all actiities in the specified section are hidden. You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode. | ||
* | ||
* @Given /^I change the name of the "(?P<activity_name_string>(?:[^"]|\\")*)" activity name to "(?P<new_name_string>(?:[^"]|\\")*)"$/ | ||
*/ | ||
public function i_change_names(): void { | ||
// This is also a really stupidly long comment but this one is not allowed to be over long. The reason we accept long docblock strings but not long comments string is because | ||
// docblocks are used as code. | ||
} | ||
} |