This is a part of the attempt to fix #2572645: [Meta] Fix 'Drupal.Commenting.FunctionComment' coding standard
This issue is created to tackle the sub-sniff
Drupal.Commenting.FunctionComment.InvalidReturnNotVoid
Some of the issues reported by this sub-sniff is because the specific test in the FunctionComment sniff was not checking for the presence of NULL as a possible return value in the @return comment. This issue has been reported under the coder queue and a patch submitted for the same #2722695: Drupal.Commenting.FunctionComment.InvalidReturnNotVoid raised even when null is a possible return value. Such issues have not been fixed in this patch.
To review:
$ composer require drupal/coder
$ ./vendor/bin/phpcs --config-set installed_paths /PATH/TO/drupal/vendor/drupal/coder/coder_sniffer/
$ cd core
$ ../vendor/bin/phpcs -p -s
Should result in no errors found.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | drupal-coding-standards-2722699-17.patch | 6.56 KB | mfernea |
| #7 | diff-2722699-5-7.txt | 739 bytes | anoopjohn |
| #7 | drupal-coding-standards-function-comment-InvalidReturnNotVoid-2722699-7.patch | 5.22 KB | anoopjohn |
Comments
Comment #2
anoopjohn commentedPlease find attached the patch for the same.
Comment #3
anoopjohn commentedComment #4
mile23The description line should extend all the way out to 80 characters before wrapping.
Same for many others.
Comment #5
anoopjohn commentedThanks for the review Mile23. I have made the changes as recommended and have attached the patch.
Comment #6
mile23Lower-case null.
Comment #7
anoopjohn commentedThanks again for the review Mile23. I have made the corrections as suggested. Sorry I had missed this in the earlier fix. Please find attached the re-rolled patch. Had to fix conflicts in phpcs.xml.dist as well. Interdiff was failing so attaching diff.
Comment #8
anoopjohn commentedComment #9
mile23Looks like a bunch of errors still in there, along with unrelated ThrowsComment errors:
Comment #10
anoopjohn commentedThanks for the Review again Mile23. There are a few false positives for InvalidReturnNotVoid. This has been raised in the coder issue queue and a patch has been submitted there #2722695: Drupal.Commenting.FunctionComment.InvalidReturnNotVoid raised even when null is a possible return value. Once that patch goes in then there would not be any more InvalidReturnNotVoid errors in core. @throws errors are not addressed in this patch as we are trying to fix errors by each sniff or sub-sniff in separate issues as per the plan.
Comment #11
dawehnerThis false positives are fixed as part of 8.2.8, but this has introduced other exceptions, so we basically need to wait until we fix those regressions and then continue with this issue?
Comment #12
mile23So I'd say this should be postponed on #2744463: Add phpcs, coder 8.2.8 as --dev requirements for drupal/core where we'll decide which version of Coder to use.
Comment #16
mfernea commentedComment #17
mfernea commentedHere is the updated patch.
Comment #18
martin107 commentedI am going to sit on this issue until committed - and provide reviews on a quick turn around.
Here is a checklist ... Here is what I can say after a careful visual scan of the patch
1) The patch applies :)
2) All the text description of the return type has been updated with appropriate words.
3) The phpcs.xml.dist has been correctly modified.
4) There are no coding standard warnings issue by the last testbot run
This looks good to me.
Comment #22
catch