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

Issue fork drupal-3123060

Command icon 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:

Comments

jungle created an issue. See original summary.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Spokje made their first commit to this issue’s fork.

spokje’s picture

Assigned: Unassigned » spokje

spokje’s picture

Status: Active » Needs review
spokje’s picture

Assigned: spokje » Unassigned
quietone’s picture

Status: Needs review » Needs work

There are a lot of changes in that MR. I only reviewed those in a migrate namespace.

spokje’s picture

Status: Needs work » Needs review

There are a lot of changes in that MR.

Tell 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.

quietone’s picture

This 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.

longwave’s picture

Wow, 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.

quietone’s picture

My next starting point is core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php

quietone’s picture

Status: Needs review » Needs work

I 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

spokje’s picture

I think my comments are getting shorter and shorter - there are so many changes to review here.

@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.

spokje’s picture

Status: Needs work » Needs review
quietone’s picture

Status: Needs review » Needs work

I 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.

spokje’s picture

@quiteone:

I finally made it to the end.

🎉🥳

@Spokje You have made a lot of nice changes!

Which you changed to even better stuff ;)

Yes, would be good to get this in but it is 480K. That is a lot to ask of a committer in one issue.

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.

I may not get back to this until the end of the week.

No problem, I'm happy the both of you went through it in the first place.

quietone’s picture

I am hoping to resolve all the current issues and then review again from top to bottom with a freshly rebased MR.

spokje’s picture

I am hoping to resolve all the current issues and then review again from top to bottom with a freshly rebased MR.

Thus 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.

quietone’s picture

Issue tags: +Coding standards
quietone’s picture

Trying to address the unresolved issues.

I intend to start reviewing this again from top to bottom as is said.

spokje’s picture

Brave man!

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Starting from the top again. The next file to review is core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php.

spokje’s picture

Thanks @quietone, resolved all but one thread and rebased MR on 9.3.x

quietone’s picture

Next file for me is core/lib/Drupal/Core/Image/ImageInterface.php

quietone’s picture

I have not yet reviewed the changes from recent reviews.

Next starting point is core/modules/action

quietone’s picture

Next up is module/quickedit

quietone’s picture

Finished reviewing the remaining files. Phew! I keep seeing things to improve and had to be careful to stay in scope. I hope I succeeded.

spokje’s picture

Finished reviewing the remaining files. Phew! I keep seeing things to improve and had to be careful to stay in scope. I hope I succeeded.

Thanks @quietone, I know this is a "monster" to review, I think you did _very_ well :)

2 remaining issues.

quietone’s picture

@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.

spokje’s picture

@quietone:

I think we need another set of eyes (plus resolve the remaining unresolved) before having a committer look at this.

Fully agreed.

[snipped] But not all the summary lines for tests that start with 'Create ...' have been changed. So, there are some inconsistencies in the changes here. Overall, though the additional coding standard is met and there are many improvements.

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?

spokje’s picture

1 unresolved thread left.

spokje’s picture

Status: Needs work » Needs review

Rerolled, 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.

daffie’s picture

Status: Needs review » Needs work

@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.

spokje’s picture

Version: 9.3.x-dev » 9.4.x-dev

- Rebased MR on 9.4.x
- Merged latest commits

spokje’s picture

Status: Needs work » Needs review
  • Rebased MR on 9.4.x
  • Merged latest commits of 9.4.x
  • Fixed new violations of Drupal.Commenting.DocComment.ShortSingleLine
  • Resolved threads opened by daffie (thanks @daffie for the Review)

Although there's still one open thread, putting this on NR to get more eyes/brains/random body parts on this issue.

daffie’s picture

spokje’s picture

Status: Needs work » Needs review

Resolved all threads, thanks again @daffie for his eagle-eyed review.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All 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.

longwave’s picture

Issue summary: View changes

Added release note snippet to the IS.

daffie’s picture

Status: Reviewed & tested by the community » Needs work
longwave’s picture

Status: Needs work » Needs review

Resolved conflicts in CachePluginBase and ToolbarAdminMenuTest.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

We need to get a version of this that applies to 10.0.x as well - sorry.

ankithashetty made their first commit to this issue’s fork.

ankithashetty’s picture

Status: Needs work » Needs review

Here is an MR for 10.0.x branch.

Changes made to /core/modules/field_ui/tests/src/Unit/FieldUiRouteEnhancerTest.php and core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php files in 9.4.x MR are ignored in this new MR as they no longer exist in 10.0.x branch.

Thanks!

xjm’s picture

Issue tags: +beta target

Thanks 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:

  1. This patch cannot be reviewed programmatically, so it isn't necessarily a good fit for "one issue, one coding standards rule".
  2. Classes, methods, and member variables all have different docblock standards, so this would be easier to review if the patch were split up into sub-issues by the type of docblock.
  3. A single child issue of all docblocks that are fixed simply by adding a newline would be easily scannable regardless of size.
  4. However, reviewing rewritten documentation is a much larger task. Many of the docblock summaries here have too little information after the update. (I can propose improvements for a lot of them, but holding off on that for now until we settle the scope and scheduling.)
  5. Some of the new documentation also has some grammatical errors. I don't want to give an overwhelming amount of feedback on that either. It'd be more manageable for both reviewers and MR authors to give that feedback on smaller subsets at a time.
  6. In general, the ideal size change set for reviewability is between 100-400 LOC. (Reference: Best practices for peer code review.) Since this patch is mostly English documentation rather than code, our brains can probably handle the larger end of that, but the current 351 files changes, 1124 insertions, 740 deletions is probably too much.
  7. Edit: Meant to mention also that this in some cases requires reading the whole class etc. to ensure the docs changes are accurate, so that's another reason that smaller subsets of changes would be good.

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 -p or 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.

quietone’s picture

Changing 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.

xjm’s picture

 

quietone’s picture

StatusFileSize
new1.05 KB

Here is the patch that just enables the sniff.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

#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 beta target, since this unfortunately did not make it into 9.4.x in time. I think this will be a beta target again, but now for the next beta? Keeping the tag.

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 targeting 10.0.x, it never even targeted 9.4.x. Which is probably why that didn't happen?

quietone’s picture

Issue tags: -beta target

Yes, removing beta target tag.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

Status: Postponed » Active

The sibling issues both landed so we can enable the sniff and fix any stragglers here.

quietone’s picture

Status: Active » Needs review
StatusFileSize
new9.07 KB

Ah, you beat me to changing the status!

quietone’s picture

Title: Fix 'Drupal.Commenting.DocComment.ShortSingleLine' coding standard » Enable 'Drupal.Commenting.DocComment.ShortSingleLine' coding standard

It 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.

longwave’s picture

Status: Needs review » Needs work

A few nits:

  1. +++ b/core/modules/editor/tests/src/Functional/Update/EditorAddLazyLoadImageFilterUpdateTest.php
    @@ -7,8 +7,7 @@
    + * Tests update of editor_file_reference with editor_image_lazy_load filter.
    

    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?

  2. +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php
    @@ -54,8 +54,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
    +   * An entity that in not yet saved to its persistent storage.
    

    in -> is

  3. +++ b/core/modules/migrate/src/Plugin/Migration.php
    @@ -205,8 +205,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
    +   * The source_row_status for current map row.
    

    "The source_row_status for the current map row."

  4. +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
    @@ -87,16 +87,18 @@ abstract class EntityResourceTestBase extends ResourceTestBase {
    +   * A list of field that need a unique value.
    

    field -> fields

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB
new9.07 KB

@longwave, thanks for the review.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

All comment changes look good to me.
The PHPCS rule has been enabled in the patch.
For me it is RTBC.

quietone’s picture

StatusFileSize
new13.62 KB
new2.87 KB
new19.9 KB
new6.35 KB

@daffie, thank you.

Adding patches for 9.5.x and 10.0.x.

  • longwave committed 40ad0deb on 10.1.x
    Issue #3123060 by Spokje, quietone, longwave, ankithashetty, daffie,...
longwave’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +10.1.0 release notes

We 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!

  • longwave committed 8f222442 on 10.0.x
    Issue #3123060 by Spokje, quietone, longwave, ankithashetty, daffie,...

  • longwave committed 34f60900 on 9.5.x
    Issue #3123060 by Spokje, quietone, longwave, ankithashetty, daffie,...
longwave’s picture

Whoops, committed 10.0.x and 9.5.x with the wrong commit message - reverted and re-committed with the right message.

dww’s picture

Status: Fixed » Needs work

Whoops, 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):

There was 1 failure:

1) Drupal\Tests\Core\Theme\ClassyPreprocessUnchangedTest::testNoNewPreprocess
The file hash for classy.theme has changed. Any additions or changes to preprocess functions should be added to the themes that inherit Classy. 
If the changes to classy.theme are not changes to preprocess functions, update the hash in this test to: '1a5f162bc900c45957aaa89959bcb607' so it will pass.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'1a5f162bc900c45957aaa89959bcb607'
+'c42ff3a1291a258b42f0c44010cd28c7'

Since this patch touched classy.theme on the 9.5.x branch, we need to update core/tests/Drupal/Tests/Core/Theme/ClassyPreprocessUnchangedTest.php to 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...

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new1.27 KB

Here'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

dww’s picture

p.s. I swapped the order of the hash and the $hash since assertSame() wants the expected value first. The failure output was confusing.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

  • longwave committed 91f605eb on 9.5.x
    Hotfix for #3123060 by dww, daffie: Fix hash for classy.theme.
    
longwave’s picture

Status: Reviewed & tested by the community » Fixed

My 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!

quietone’s picture

@dww and longwave, Thank you! I should have come back and checked on this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.