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.
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
Comments
Comment #2
attiks commentedComment #3
longwaveWhile adding braces is good for readability, the closing braces should be on a line on their own.
The empty cases might also warrant adding a comment as to why the block is empty.
Comment #4
duaelfrAs agreed between the mentors at Drupalcon, according to issues to avoid for novices, I am untagging this issue as "Beginner". This issue contains changes across a very wide range of files and might create too many other patches to need to be rerolled at this particular time. This patch has an automated way to be rerolled later so better to implement it after Drupalcon.
Comment #5
andriyun commentedRerolled patch. After phpcbf changes.
Comment #6
droplet commentedvendor libs should be excluded.
Comment #7
andriyun commentedVendor libs are excluded from patch fix-2572693-5.patch :)
Comment #8
andypostnot sure about that, but indent is wrong
indent wrong, in that file
Comment #9
droplet commentedArchiveTar.php should be excluded I think. It's a slightly mod version.
Comment #10
andriyun commentedFix indentation after phpcbf auto correction.
To fix indentation I used Code > Reformat code tool in PhpStorm with with "Only VCS changed text".
It's really powerful option :)
@droplet Can you add more argument and details about reason to exclude ArchiveTar.php file please.
Comment #11
andypostNow patch is great.
ArchiveTar.phpis a part of core so should be fixed as well, another round on it should convert indent to 2spacesComment #12
droplet commentedFixing ArchiveTar.php would bring some headache for next release port. There're more things in ArchiveTar.php can be improve but we skipped on each patching.
Comment #13
alexpottI'm not sure about ArchiveTar.php changes either.
From the top of the file...
See not good reason given here to break that.
Comment #14
droplet commentedArchiveTar.php is 99.9%.
Comment #15
attiks commentedI see 2 proper options:
- we fix the coding standard of ArchiveTar.php
- we move the original ArchiveTar.php to vendor and we provide a wrapper
And 1 not so proper, but easy fix
- we exclude ArchiveTar.php from code sniffer
Personally the last option will help move the rest forward
Comment #16
longwaveWe could just pull in https://github.com/pear/Archive_Tar via Composer?
Comment #17
longwaveActually, #2610984: Add Archive Tar via Composer, with BC shim is already dealing with that.
Comment #18
pfrenssenComment #19
andypostAll this fixes are blocked by #2610984: Add Archive Tar via Composer, with BC shim
Comment #21
pfrenssenComment #22
pfrenssenComment #23
andypostThis rule needs work cos indent is wrong, so manually fixed patch
Comment #24
mile23Patch in #23 gives me this:
...which I suppose is a bit backwards.
But the patch also yields no errors when phpcs is run.
Comment #25
pfrenssenComment #26
mile23Patch no longer applies, so I just re-did the work with phpcbf and some manual whitespace edits.
Comment #27
alexpottThis if should be removed.
The fixer added some space on the end of the line :(
Needs indenting
Comment #28
mile23Fixed the issues in #27, and went through the diff *again* to double-check...
Comment #29
dawehnerLooks great for me now!
Comment #30
alexpottCommitted a6efc8c and pushed to 8.1.x and 8.2.x. Thanks!
Comment #33
dawehner