Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove filehascopyright, filehaslicense #139

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lang/en/local_moodlecheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,3 @@

$string['rule_categoryvalid'] = 'Category tag is valid';
$string['error_categoryvalid'] = 'Category <b>{$a->category}</b> is not valid';

$string['rule_filehascopyright'] = 'Files have @copyright tag';
$string['error_filehascopyright'] = 'File-level phpdocs block does not have @copyright tag';

$string['rule_filehaslicense'] = 'Files have @license tag';
$string['error_filehaslicense'] = 'File-level phpdocs block does not have @license tag';
30 changes: 0 additions & 30 deletions rules/phpdocs_basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
local_moodlecheck_registry::add_rule('functionarguments')->set_callback('local_moodlecheck_functionarguments');
local_moodlecheck_registry::add_rule('variableshasvar')->set_callback('local_moodlecheck_variableshasvar');
local_moodlecheck_registry::add_rule('definedoccorrect')->set_callback('local_moodlecheck_definedoccorrect');
local_moodlecheck_registry::add_rule('filehascopyright')->set_callback('local_moodlecheck_filehascopyright');
local_moodlecheck_registry::add_rule('filehaslicense')->set_callback('local_moodlecheck_filehaslicense');
local_moodlecheck_registry::add_rule('phpdocsinvalidinlinetag')->set_callback('local_moodlecheck_phpdocsinvalidinlinetag');
local_moodlecheck_registry::add_rule('phpdocsuncurlyinlinetag')->set_callback('local_moodlecheck_phpdocsuncurlyinlinetag');
local_moodlecheck_registry::add_rule('phpdoccontentsinlinetag')->set_callback('local_moodlecheck_phpdoccontentsinlinetag');
Expand Down Expand Up @@ -381,31 +379,3 @@ function local_moodlecheck_definedoccorrect(local_moodlecheck_file $file) {
}
return $errors;
}

/**
* Makes sure that files have copyright tag
*
* @param local_moodlecheck_file $file
* @return array of found errors
*/
function local_moodlecheck_filehascopyright(local_moodlecheck_file $file) {
$phpdocs = $file->find_file_phpdocs();
if ($phpdocs && !count($phpdocs->get_tags('copyright', true))) {
return [['line' => $phpdocs->get_line_number($file, '@copyright')]];
}
return [];
}

/**
* Makes sure that files have license tag
*
* @param local_moodlecheck_file $file
* @return array of found errors
*/
function local_moodlecheck_filehaslicense(local_moodlecheck_file $file) {
$phpdocs = $file->find_file_phpdocs();
if ($phpdocs && !count($phpdocs->get_tags('license', true))) {
return [['line' => $phpdocs->get_line_number($file, '@license')]];
}
return [];
}
29 changes: 0 additions & 29 deletions tests/fixtures/classtags.php

This file was deleted.

18 changes: 0 additions & 18 deletions tests/moodlecheck_rules_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,6 @@ public function test_constantclass(): void {
$this->assertSame(0, $found->length);
}

/**
* Assert that classes do not need to have any particular phpdocs tags.
*
* @covers ::local_moodlecheck_filehascopyright
* @covers ::local_moodlecheck_filehaslicense
*/
public function test_classtags(): void {
global $PAGE;

$output = $PAGE->get_renderer('local_moodlecheck');
$path = new local_moodlecheck_path('local/moodlecheck/tests/fixtures/classtags.php ', null);

$result = $output->display_path($path, 'xml');

$this->assertStringNotContainsString('classeshavecopyright', $result);
$this->assertStringNotContainsString('classeshavelicense', $result);
}

/**
* Ensure that token_get_all() does not return PHP Warnings.
*
Expand Down
Loading