Part of meta-issue #3268741: [meta] Fix Drupal.Commenting.DocComment.ShortSingleLine
This issue will be the last child of the parent to complete. It will enable the sniff and fix any remaining errors. Postponing until the sibling issues are complete.
Step 1: Preparation
Open the file core/phpcs.xml.dist and add a line for the sniff of this ticket. The sniff name is in the issue title. Make sure your patch will include the addition of this line.
Step 2: Install & configure PHPCS
Install PHP CodeSniffer and the ruleset from the Coder module:
$ composer install
$ ./vendor/bin/phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer
Once you have installed the phpcs package, you can list all the sniffs available to you like this:
$ ./vendor/bin/phpcs --standard=Drupal -e
This will give you a big list of sniffs, and the Drupal-based ones should be present.
Step 3: Prepare the phpcs.xml file
To speed up the testing you should make a copy of the file phpcs.xml.dist (in the core/ folder) and save it as phpcs.xml. This is the configuration file for PHP CodeSniffer.
We only want this phpcs.xml file to specify the sniff we're interested in. So we need to remove all the rule items, and add only our own sniff's rule. Rule items look like this:
<rule ref="Drupal.Commenting.DocComment.ShortSingleLine"/>
Remove all of them, and add only the sniff from this issue title. This will make sure that our tests run quickly, and are not going to contain any output from unrelated sniffs.
Step 4: Run the test
Now you are ready to run the test! From within the core/ folder, run the following command to launch the test:
$ cd core/
$ ../vendor/bin/phpcs -p
This takes a couple of minutes. The -p flag shows the progress, so you have a bunch of nice dots to look at while it is running.
Step 5: Fix the failures
When the test is complete it will present you a list of all the files that contain violations of your sniff, and the line numbers where the violations occur. You could fix all of these manually, but thankfully phpcbf can fix many of them. You can call phpcbf like this:
$ ../vendor/bin/phpcbf
This will fix the errors in place. You can then make a diff of the changes using git. You can also re-run the test with phpcs and determine if that fixed all of them.
Release notes snippet
The following coding standards check has been enabled in core:
Drupal.Commenting.DocComment.ShortSingleLine
| Comment | File | Size | Author |
|---|---|---|---|
| #75 | 3123060-75.9_5_x-hotfix.patch | 1.27 KB | dww |
| #68 | 3123060-68-10.0.patch | 6.35 KB | quietone |
| #68 | 3123060-68-9.5.patch | 19.9 KB | quietone |
| #68 | interdiff-66-68-10.0.txt | 2.87 KB | quietone |
| #68 | interdiff-66-68-19.5.txt | 13.62 KB | quietone |
Issue fork drupal-3123060
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3123060-fix-drupal.commenting.doccomment.shortsingleline-coding
changes, plain diff MR !500
- 3123060-fix-drupal.commenting.doccomment.shortsingleline-coding-10-0-x
changes, plain diff MR !1886
- 2937882-fix-drupal.classes.propertydeclaration-coding-for-realz
changes, plain diff MR !525
Comments
Comment #5
spokjeComment #9
spokjeComment #10
spokjeComment #11
quietone commentedThere are a lot of changes in that MR. I only reviewed those in a migrate namespace.
Comment #12
spokjeTell me about it, I manually changed them all ;)
Thanks for the partial review!
I think attacking it in chunks is the only way to keep your sanity.
Comment #13
quietone commentedThis time I started at the top of the MR and worked down. The next file for me start at is core/lib/Drupal/Core/Image/ImageInterface.php.
Comment #14
longwaveWow, this one will be nice to fix but will be tricky to drive home - there's a lot to discuss here I think. Great start though - and yes reviewing it is quite the effort, I will carry on later.
Comment #15
quietone commentedMy next starting point is core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php
Comment #18
quietone commentedI think my comments are getting shorter and shorter - there are so many changes to review here.
I looked at the two unresolved issues. I did not review the resolution of my previous comments.
My next starting point is core/modules/media/tests/src/Functional/UrlResolverTest.php
Comment #19
spokje@quietone: I can't blame you, there are a lotof changes to review indeed.
Short comments are fine with me, with so many stuff to review we can skip the politeness of "Maybe we can use ...", or "Perhaps this fits better.".
Just whack in your proposed text, since so far, they were always better then my feeble attempts.
Thanks for sticking with this, it's a lot of work, but I really would like this sniff in to stop it from getting worse.
Comment #20
spokjeComment #21
quietone commentedI finally made it to the end.
@Spokje You have made a lot of nice changes! Yes, would be good to get this in but it is 480K. That is a lot to ask of a committer in one issue.
I may not get back to this until the end of the week.
Comment #22
spokje@quiteone:
🎉🥳
Which you changed to even better stuff ;)
Agreed, but I couldn't see a nice way of splitting this into smaller sub-issues without it taking a long time.
I hope having it in a MR makes reviewing (Thank you, @quiteone and @longwave) and commiting a bit easier due to the nice(?) GitLab GUI for changes.
No problem, I'm happy the both of you went through it in the first place.
Comment #23
quietone commentedI am hoping to resolve all the current issues and then review again from top to bottom with a freshly rebased MR.
Comment #24
spokjeThus spoketh @quietone in #24
Godspeed, my son! ;)
I've resolved a few comments where you agreed with me and made 2 changes you've suggested.
In the process also rebased the MR.
Comment #25
quietone commentedComment #26
quietone commentedTrying to address the unresolved issues.
I intend to start reviewing this again from top to bottom as is said.
Comment #27
spokjeBrave man!
Comment #29
quietone commentedStarting from the top again. The next file to review is core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php.
Comment #30
spokjeThanks @quietone, resolved all but one thread and rebased MR on
9.3.xComment #31
quietone commentedNext file for me is core/lib/Drupal/Core/Image/ImageInterface.php
Comment #32
quietone commentedI have not yet reviewed the changes from recent reviews.
Next starting point is core/modules/action
Comment #33
quietone commentedNext up is module/quickedit
Comment #34
quietone commentedFinished reviewing the remaining files. Phew! I keep seeing things to improve and had to be careful to stay in scope. I hope I succeeded.
Comment #35
spokjeThanks @quietone, I know this is a "monster" to review, I think you did _very_ well :)
2 remaining issues.
Comment #36
quietone commented@Spokje, thanks. thins is looking really good! I think we need another set of eyes (plus resolve the remaining unresolved) before having a committer look at this.
I do want to point out there are summary lines for tests here that start with 'Create ...'. Some of those got changed on my suggestion and perhaps are out of scope. If that is true, I hope they can stay as the change is an improvement. But not all the summary lines for tests that start with 'Create ...' have been changed. Along the way I became more concerned about scope and didn't comment on those. So, there are some inconsistencies in the changes here. Overall, though the additional coding standard is met and there are many improvements.
Comment #37
spokje@quietone:
Fully agreed.
I see the phrase "many improvements", so I'm happy with a bit of scope-creep there.
Although I think a follow-up for getting _all_ the summary lines for tests that start with 'Create ...' changed is needed?
Comment #38
spokje1 unresolved thread left.
Comment #39
spokjeRerolled, resolved one of the threads from @quietone.
One more open thread, set to NR to get more eyes/brains/random body-parts on that one.
Comment #40
daffie commented@skopje: Feel free to disagree, good arguments win the day. Also #3224583: The testbot does not run PHPCS on all files when core/phpcs.xml.dist is changed has landed, therefor you might get more fails from the testbot.
Comment #41
spokje- Rebased MR on
9.4.x- Merged latest commits
Comment #42
spokje9.4.x9.4.xAlthough there's still one open thread, putting this on NR to get more eyes/brains/random body parts on this issue.
Comment #43
daffie commentedThe MR looks good to me. Just a couple of nitpicks.
I have created #3250482: The docblock of \Drupal\views\Plugin\views\cache\CachePluginBase::cacheSetMaxAge() is wrong.
Comment #44
spokjeResolved all threads, thanks again @daffie for his eagle-eyed review.
Comment #45
daffie commentedAll the changes look good to me.
The correct change is made to the file core/phpcs.xml.dist.
The IS is in order.
For me it is RTBC.
Comment #46
longwaveAdded release note snippet to the IS.
Comment #47
daffie commented#3250482: The docblock of \Drupal\views\Plugin\views\cache\CachePluginBase::cacheSetMaxAge() is wrong has landed. A small reroll is needed.
Comment #48
longwaveResolved conflicts in CachePluginBase and ToolbarAdminMenuTest.
Comment #49
daffie commentedBack to RTBC.
Comment #50
alexpottWe need to get a version of this that applies to 10.0.x as well - sorry.
Comment #53
ankithashettyHere is an MR for 10.0.x branch.
Changes made to
/core/modules/field_ui/tests/src/Unit/FieldUiRouteEnhancerTest.phpandcore/tests/Drupal/KernelTests/Core/File/NameMungingTest.phpfiles in 9.4.x MR are ignored in this new MR as they no longer exist in 10.0.x branch.Thanks!
Comment #54
xjmThanks everyone for all your work on this!
I discussed this issue with @quietone and have a couple thoughts:
First of all, in its current form, this is a disruptive (and easily disrupted) change set that would be best done as a scheduled beta target. Tagging accordingly. The next beta phase begins May 23.
Secondly, given the scope and nature of this change set, this is an issue where I would split addressing the coding standards rule into several logically scoped steps. Specific notes:
I did have a think about whether it would be better to go ahead with the current MRs since so much work has gone into them already, versus spending more time splitting them up. I think using a
git add -por interactive merge would make it fairly doable to split this up without too much effort. Splitting it up might also help us avoid having to schedule the patch (and therefore having to spend more time later getting it to apply again).Those are my thoughts for now, although I'll think more about it overnight and maybe I can help split it up quickly.
Thanks everyone! Truly impressive effort here.
Comment #55
quietone commentedChanging parent.
Making this one the final issue to be done when all the children are complete. This one will enable the sniff and fix any remaining errors.
Postponing until the sibling issues are complete.
Comment #56
xjmComment #57
quietone commentedHere is the patch that just enables the sniff.
Comment #59
wim leers#3268741: [meta] Fix Drupal.Commenting.DocComment.ShortSingleLine is not complete and per #55, this is blocked on all other children of #3268741: [meta] Fix Drupal.Commenting.DocComment.ShortSingleLine being completed first.
Hence removing , since this unfortunately did not make it intoI think this will be a beta target again, but now for the next beta? Keeping the tag.9.4.xin time.Also, it might be better to mark #3268838: Fix functions and test modules for Drupal.Commenting.DocComment.ShortSingleLine as a beta target for
9.5.x, since that'll likely get more eyes on the issues that are actually blocking this one? But … #3268741: [meta] Fix Drupal.Commenting.DocComment.ShortSingleLine is targeting10.0.x, it never even targeted9.4.x. Which is probably why that didn't happen?Comment #60
quietone commentedYes, removing beta target tag.
Comment #62
longwaveThe sibling issues both landed so we can enable the sniff and fix any stragglers here.
Comment #63
quietone commentedAh, you beat me to changing the status!
Comment #64
quietone commentedIt looks it was decided to fix the class properties as well in this last issue. That was only 12 files and the patch is small, so that is reasonable.
Comment #65
longwaveA few nits:
This is difficult because of the length of the snake_case_words but "Tests adding editor_image_lazy_load filter to editor_file_reference." is a bit clearer?
in -> is
"The source_row_status for the current map row."
field -> fields
Comment #66
quietone commented@longwave, thanks for the review.
Comment #67
daffie commentedAll comment changes look good to me.
The PHPCS rule has been enabled in the patch.
For me it is RTBC.
Comment #68
quietone commented@daffie, thank you.
Adding patches for 9.5.x and 10.0.x.
Comment #70
longwaveWe can only enable the sniff in a minor release, so I committed the change to phpcs.xml.dist to 10.1.x only and skipped it for the other branches.
Committed and pushed to 10.1.x, 10.0.x and 9.5.x. Thanks!
Comment #73
longwaveWhoops, committed 10.0.x and 9.5.x with the wrong commit message - reverted and re-committed with the right message.
Comment #74
dwwWhoops, this is breaking testing on the 9.5.x branch right now. E.g. see https://www.drupal.org/pift-ci-job/2657088 (from #3356283: Fork laminas/laminas-diactoros):
Since this patch touched classy.theme on the 9.5.x branch, we need to update
core/tests/Drupal/Tests/Core/Theme/ClassyPreprocessUnchangedTest.phpto match.Not sure if this should be reverted and re-re-committed, or if we just want a hot-fix. Should the hot-fix be here or a separate issue?
Thanks!
-Derek
p.s. Oh wow, the 9.5.x test failed the same way above. See https://www.drupal.org/pift-ci-job/2655998...
Comment #75
dwwHere's the hotfix for the current 9.5.x branch. Not sure if it should go here or a follow-up, but making it easier for whomever wants to move this forward.
Thanks!
-Derek
Comment #76
dwwp.s. I swapped the order of the hash and the $hash since
assertSame()wants the expected value first. The failure output was confusing.Comment #77
daffie commentedLooks good to me.
Comment #79
longwaveMy bad, I thought it was a random fail and didn't check properly. Pushed #75 as a hotfix to 9.5.x, many thanks for spotting and fixing this!
Comment #80
quietone commented@dww and longwave, Thank you! I should have come back and checked on this.