Follow-up to #2707371: Fix several errors in the 'Drupal.Commenting.DocComment' coding standard
Problem/Motivation
Let's fix drupal/coder's sniffs in core.
This issue continues fixing Drupal.Commenting.DocComment
errors. These errors relate to docblock comments and the tags within them.
We'll limit to easy-to-review errors: ShortStartSpace
, SpacingAfter
ShortStartSpace
makes sure the one-line summary is indented properly.
SpacingAfter
makes sure there are no blank lines at the end of docblocks.
Proposed resolution
Add drupal/coder and the phpcs package to your Drupal codebase:
# From Drupal root directory
$ composer require drupal/coder
$ ./vendor/bin/phpcs --config-set installed_paths DRUPALPATH/vendor/drupal/coder/coder_sniffer/
Modify the Drupal.Commenting.DocComment
errors to not be excluded from within core/phpcs.xml.dist
.
Run phpcbf from the core directory:
$ cd core
$ ../vendor/bin/phpcbf
This will fix some errors. Review what it did and fix problematic changes.
Run phpcs from the core directory in order to verify that no errors remain:
$ ../vendor/bin/phpcs -p
To review this issue
Install coder/phpcs as above.
Apply the patch.
Run phpcs from the core directory to verify that no errors remain.
$ cd core
$ ../vendor/bin/phpcs -p
Read the patch to check for errors.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#3 | 2716685_3.patch | 43.4 KB | Mile23 |
Comments
Comment #2
Mile23Comment #3
Mile23WebTestBase.php
still suffers from #2060925: False-positives for @code/@endcode by Drupal.Commenting.DocCommentSniff and Drupal.Commenting.DocCommentAlignment sniff in a rather complex way, soParamGroup
error will stay in the exclude list and I won't fixWebTestBase
(since it isn't broken).However I'll leave all the other changes related to
ParamGroup
in this patch since they're easy to read.ParamGroup
just wants all@param
tags to be together, with no blank lines between them.Since
ShortStartSpace
adjusts the first line of docblocks, auto-fixing it results in some strange spacing for some docblocks with no first line summary. In those cases, I properly indented the whole paragraph.Fixing the remaining
Drupal.Commenting.DocComment
errors will require subjective review, as well as fixing the issues with false positives.Comment #4
Mile23Comment #5
alexpottThe changes here look good and phpcs reports no errors after applying the patch.
Comment #6
alexpottCommitted 1d7b860 and pushed to 8.1.x and 8.2.x. Thanks!