Skip to content

Commit

Permalink
Remove noemptysecondlines check (#133)
Browse files Browse the repository at this point in the history
Already covered by:
* moodle.Files.BoilerplateComment.NoPHP
* PSR12.Files.FileHeader.HeaderPosition
---------

Co-authored-by: Eloy Lafuente <stronk7@moodle.org>
  • Loading branch information
andrewnicols and stronk7 authored Mar 13, 2024
1 parent 0ceee22 commit 90c24e5
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 21 deletions.
3 changes: 0 additions & 3 deletions lang/en/local_moodlecheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@

$string['error_emptynophpfile'] = 'The file is empty or doesn\'t contain PHP code. Skipped.';

$string['rule_noemptysecondline'] = 'Php open tag in the first line is not followed by empty line';
$string['error_noemptysecondline'] = 'Empty line found after PHP open tag';

$string['rule_filephpdocpresent'] = 'File-level phpdocs block is present';
$string['error_filephpdocpresent'] = 'File-level phpdocs block is not found';

Expand Down
16 changes: 0 additions & 16 deletions rules/phpdocs_basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

defined('MOODLE_INTERNAL') || die;

local_moodlecheck_registry::add_rule('noemptysecondline')->set_callback('local_moodlecheck_noemptysecondline')
->set_severity('warning');
local_moodlecheck_registry::add_rule('filephpdocpresent')->set_callback('local_moodlecheck_filephpdocpresent');
local_moodlecheck_registry::add_rule('classesdocumented')->set_callback('local_moodlecheck_classesdocumented');
local_moodlecheck_registry::add_rule('functionsdocumented')->set_callback('local_moodlecheck_functionsdocumented');
Expand All @@ -49,20 +47,6 @@
local_moodlecheck_registry::add_rule('phpdocsuncurlyinlinetag')->set_callback('local_moodlecheck_phpdocsuncurlyinlinetag');
local_moodlecheck_registry::add_rule('phpdoccontentsinlinetag')->set_callback('local_moodlecheck_phpdoccontentsinlinetag');

/**
* Checks if the first line in the file has open tag and second line is not empty
*
* @param local_moodlecheck_file $file
* @return array of found errors
*/
function local_moodlecheck_noemptysecondline(local_moodlecheck_file $file) {
$tokens = &$file->get_tokens();
if ($tokens[0][0] == T_OPEN_TAG && !$file->is_whitespace_token(1) && $file->is_multiline_token(0) == 1) {
return [];
}
return [['line' => 2]];
}

/**
* Checks if file-level phpdocs block is present
*
Expand Down
2 changes: 0 additions & 2 deletions tests/moodlecheck_rules_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ public function test_text_format_errors_and_warnings(): void {
$result = $output->display_path($path, 'text');

$this->assertStringContainsString('tests/fixtures/error_and_warning.php', $result);
$this->assertStringContainsString('2: Empty line found after PHP open tag (warning)', $result);
$this->assertStringContainsString('11: Class someclass is not documented (error)', $result);
$this->assertStringContainsString('12: Function someclass::somefunc is not documented (warning)', $result);
}
Expand All @@ -632,7 +631,6 @@ public function test_html_format_errors_and_warnings(): void {
$result = $output->display_path($path, 'html');

$this->assertStringContainsString('tests/fixtures/error_and_warning.php</span>', $result);
$this->assertStringContainsString('<b>2</b>: Empty line found after PHP open tag (warning)', $result);
$this->assertStringContainsString('<b>11</b>: Class <b>someclass</b> is not documented (error)', $result);
$this->assertStringContainsString('<b>12</b>: Function <b>someclass::somefunc</b> is not documented (warning)', $result);
}
Expand Down

0 comments on commit 90c24e5

Please sign in to comment.