Skip to content

Commit 57b2699

Browse files
authored
Merge pull request moodlehq#142 from andrewnicols/removeDocblockDescriptions
Remove phpdocsfistline and functiondescription (moodlehq#142)
2 parents 567fcd6 + a906ece commit 57b2699

File tree

3 files changed

+0
-67
lines changed

3 files changed

+0
-67
lines changed

file.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,20 +1267,6 @@ public function get_original_token_id() {
12671267
return $this->originaltid;
12681268
}
12691269

1270-
/**
1271-
* Returns short description found in phpdocs if found (first line followed by empty line)
1272-
*
1273-
* @return string
1274-
*/
1275-
public function get_shortdescription() {
1276-
$lines = preg_split('/\n/', $this->description);
1277-
if (count($lines) == 1 || (count($lines) && !strlen(trim($lines[1])))) {
1278-
return $lines[0];
1279-
} else {
1280-
return false;
1281-
}
1282-
}
1283-
12841270
/**
12851271
* Returns list of parsed param tokens found in phpdocs
12861272
*

lang/en/local_moodlecheck.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343
$string['rule_noinlinephpdocs'] = 'There are no comments starting with three or more slashes';
4444
$string['error_noinlinephpdocs'] = 'Found comment starting with three or more slashes';
4545

46-
$string['error_phpdocsfistline'] = 'No one-line description found in phpdocs for <b>{$a->object}</b>';
47-
$string['rule_phpdocsfistline'] = 'File-level phpdocs block and class phpdocs should have one-line short description';
48-
4946
$string['error_phpdocsinvalidinlinetag'] = 'Invalid inline phpdocs tag <b>{$a->tag}</b> found';
5047
$string['rule_phpdocsinvalidinlinetag'] = 'Inline phpdocs tags are valid';
5148

@@ -55,9 +52,6 @@
5552
$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)]}';
5653
$string['rule_phpdoccontentsinlinetag'] = 'Inline phpdocs tags have correct contents';
5754

58-
$string['error_functiondescription'] = 'There is no description in phpdocs for function <b>{$a->object}</b>';
59-
$string['rule_functiondescription'] = 'Functions have descriptions in phpdocs';
60-
6155
$string['error_functionarguments'] = 'Phpdocs for function <b>{$a->function}</b> has incomplete parameters list';
6256
$string['rule_functionarguments'] = 'Phpdocs for functions properly define all parameters';
6357

rules/phpdocs_basic.php

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
local_moodlecheck_registry::add_rule('definesdocumented')->set_callback('local_moodlecheck_definesdocumented');
2828
local_moodlecheck_registry::add_rule('noinlinephpdocs')->set_callback('local_moodlecheck_noinlinephpdocs');
29-
local_moodlecheck_registry::add_rule('phpdocsfistline')->set_callback('local_moodlecheck_phpdocsfistline');
30-
local_moodlecheck_registry::add_rule('functiondescription')->set_callback('local_moodlecheck_functiondescription');
3129
local_moodlecheck_registry::add_rule('functionarguments')->set_callback('local_moodlecheck_functionarguments');
3230
local_moodlecheck_registry::add_rule('definedoccorrect')->set_callback('local_moodlecheck_definedoccorrect');
3331
local_moodlecheck_registry::add_rule('phpdocsinvalidinlinetag')->set_callback('local_moodlecheck_phpdocsinvalidinlinetag');
@@ -159,51 +157,6 @@ function local_moodlecheck_phpdoccontentsinlinetag(local_moodlecheck_file $file)
159157
return $errors;
160158
}
161159

162-
/**
163-
* Makes sure that file-level phpdocs and all classes have one-line short description
164-
*
165-
* @param local_moodlecheck_file $file
166-
* @return array of found errors
167-
*/
168-
function local_moodlecheck_phpdocsfistline(local_moodlecheck_file $file) {
169-
$errors = [];
170-
171-
if (($phpdocs = $file->find_file_phpdocs()) && !$file->find_file_phpdocs()->get_shortdescription()) {
172-
$errors[] = [
173-
'line' => $phpdocs->get_line_number($file),
174-
'object' => 'file',
175-
];
176-
}
177-
foreach ($file->get_classes() as $class) {
178-
if ($class->phpdocs && !$class->phpdocs->get_shortdescription()) {
179-
$errors[] = [
180-
'line' => $class->phpdocs->get_line_number($file),
181-
'object' => 'class '.$class->name,
182-
];
183-
}
184-
}
185-
return $errors;
186-
}
187-
188-
/**
189-
* Makes sure that all functions have descriptions
190-
*
191-
* @param local_moodlecheck_file $file
192-
* @return array of found errors
193-
*/
194-
function local_moodlecheck_functiondescription(local_moodlecheck_file $file) {
195-
$errors = [];
196-
foreach ($file->get_functions() as $function) {
197-
if ($function->phpdocs !== false && !strlen($function->phpdocs->get_description())) {
198-
$errors[] = [
199-
'line' => $function->phpdocs->get_line_number($file),
200-
'object' => $function->name,
201-
];
202-
}
203-
}
204-
return $errors;
205-
}
206-
207160
/**
208161
* Checks that all functions have proper arguments in phpdocs
209162
*

0 commit comments

Comments
 (0)