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 phpdocsfistline and functiondescription (#142) #142

Merged
merged 1 commit into from
Mar 27, 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
14 changes: 0 additions & 14 deletions file.php
Original file line number Diff line number Diff line change
Expand Up @@ -1267,20 +1267,6 @@ public function get_original_token_id() {
return $this->originaltid;
}

/**
* Returns short description found in phpdocs if found (first line followed by empty line)
*
* @return string
*/
public function get_shortdescription() {
$lines = preg_split('/\n/', $this->description);
if (count($lines) == 1 || (count($lines) && !strlen(trim($lines[1])))) {
return $lines[0];
} else {
return false;
}
}

/**
* Returns list of parsed param tokens found in phpdocs
*
Expand Down
6 changes: 0 additions & 6 deletions lang/en/local_moodlecheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
$string['rule_noinlinephpdocs'] = 'There are no comments starting with three or more slashes';
$string['error_noinlinephpdocs'] = 'Found comment starting with three or more slashes';

$string['error_phpdocsfistline'] = 'No one-line description found in phpdocs for <b>{$a->object}</b>';
$string['rule_phpdocsfistline'] = 'File-level phpdocs block and class phpdocs should have one-line short description';

$string['error_phpdocsinvalidinlinetag'] = 'Invalid inline phpdocs tag <b>{$a->tag}</b> found';
$string['rule_phpdocsinvalidinlinetag'] = 'Inline phpdocs tags are valid';

Expand All @@ -55,9 +52,6 @@
$string['error_phpdoccontentsinlinetag'] = 'Inline phpdocs tag <b>{$a->tag}</b> with incorrect contents found. It must match {@link [valid URL] [description (optional)]} or {@see [valid FQSEN] [description (optional)]}';
$string['rule_phpdoccontentsinlinetag'] = 'Inline phpdocs tags have correct contents';

$string['error_functiondescription'] = 'There is no description in phpdocs for function <b>{$a->object}</b>';
$string['rule_functiondescription'] = 'Functions have descriptions in phpdocs';

$string['error_functionarguments'] = 'Phpdocs for function <b>{$a->function}</b> has incomplete parameters list';
$string['rule_functionarguments'] = 'Phpdocs for functions properly define all parameters';

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

local_moodlecheck_registry::add_rule('definesdocumented')->set_callback('local_moodlecheck_definesdocumented');
local_moodlecheck_registry::add_rule('noinlinephpdocs')->set_callback('local_moodlecheck_noinlinephpdocs');
local_moodlecheck_registry::add_rule('phpdocsfistline')->set_callback('local_moodlecheck_phpdocsfistline');
local_moodlecheck_registry::add_rule('functiondescription')->set_callback('local_moodlecheck_functiondescription');
local_moodlecheck_registry::add_rule('functionarguments')->set_callback('local_moodlecheck_functionarguments');
local_moodlecheck_registry::add_rule('definedoccorrect')->set_callback('local_moodlecheck_definedoccorrect');
local_moodlecheck_registry::add_rule('phpdocsinvalidinlinetag')->set_callback('local_moodlecheck_phpdocsinvalidinlinetag');
Expand Down Expand Up @@ -159,51 +157,6 @@ function local_moodlecheck_phpdoccontentsinlinetag(local_moodlecheck_file $file)
return $errors;
}

/**
* Makes sure that file-level phpdocs and all classes have one-line short description
*
* @param local_moodlecheck_file $file
* @return array of found errors
*/
function local_moodlecheck_phpdocsfistline(local_moodlecheck_file $file) {
$errors = [];

if (($phpdocs = $file->find_file_phpdocs()) && !$file->find_file_phpdocs()->get_shortdescription()) {
andrewnicols marked this conversation as resolved.
Show resolved Hide resolved
$errors[] = [
'line' => $phpdocs->get_line_number($file),
'object' => 'file',
];
}
foreach ($file->get_classes() as $class) {
if ($class->phpdocs && !$class->phpdocs->get_shortdescription()) {
$errors[] = [
'line' => $class->phpdocs->get_line_number($file),
'object' => 'class '.$class->name,
];
}
}
return $errors;
}

/**
* Makes sure that all functions have descriptions
*
* @param local_moodlecheck_file $file
* @return array of found errors
*/
function local_moodlecheck_functiondescription(local_moodlecheck_file $file) {
$errors = [];
foreach ($file->get_functions() as $function) {
if ($function->phpdocs !== false && !strlen($function->phpdocs->get_description())) {
$errors[] = [
'line' => $function->phpdocs->get_line_number($file),
'object' => $function->name,
];
}
}
return $errors;
}

/**
* Checks that all functions have proper arguments in phpdocs
*
Expand Down
Loading