Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The method \Drupal\Tests\field\Kernel\Number\NumberItemTest::setUp()
doesn't have any comment.
Proposed resolution
Add inheritdoc comment.
Comment | File | Size | Author |
---|---|---|---|
#45 | 3264947-45-10.1.x.patch | 258.98 KB | Niklan |
| |||
#45 | interdiff_44_45_10.1.x.txt | 778 bytes | Niklan |
#45 | interdiff_40_45_10.1.x.txt | 848 bytes | Niklan |
#44 | 3264947-44-10.1.x.patch | 257.91 KB | Niklan |
| |||
#44 | interdiff_40_44_10.1.x.txt | 1.46 KB | Niklan |
Comments
Comment #2
NiklanComment #3
longwaveThere are hundreds of setUp methods without docblocks, if we are to fix this I think we should add them all in one go instead of one by one.
Comment #4
Niklan@longwave sounds reasonable. Should be core tests covered by Drupal Coding Standards? Because, it seems like most parts of tests will not pass PHPCS check. I don't understand this is intentional, or they're ignored? Does it even worth to address such issues?
Comment #5
longwaveCoding standards say that all methods should have docblocks, but Drupal core has never fully implemented this and the
Drupal.Commenting.FunctionComment.Missing
rule is currently excluded in phpcs.xml.dist.#3212066: Fix Drupal.Commenting.FunctionComment.Missing is the open issue to work on this, but there are probably hundreds if not thousands of functions/methods that need a docblock adding, and many of those are not inheritdoc so someone has to write a sentence for each. Maybe rescoping this to add docblocks to all
setUp()
methods would be a good start.Comment #6
NiklanComment #7
NiklanHere it is, the all (401) empty
::setUp()
is now having inheritdoc comment.P.s.
Used PHPStorm to do so with search and replace using regex:
Search pattern:
Replace pattern:
Comment #8
NiklanComment #9
marciaibanezI'll review this issue.
Comment #10
marciaibanezI tested the patch, everything seems to work well.
Comment #11
xjmI think the chosen scope makes sense.
Looks like it needs a reroll. It might also need different versions for different branches, so I'd check to see whether the same patch applies to 10.0.x and 9.4.x.
Large cleanups like this are often scheduled as beta targets because they fall out of sync with HEAD so quickly. That way we ensure they're less disruptive to other patches and also get committer attention right away so they don't have to be rerolled so many times while awaiting commit. The beta phase for 9.4 will begin on May 23. @Niklan, if you're available around then, we could schedule recreating this patch for some time that week? Thanks!
@marciaibanez, there is nothing to test with this patch and nothing that would be "working well". Posting that as a review makes it look like no review actually happened.
To get contribution credit for reviewing an issue like this, I would expect to see the reviewer document what references they looked at to confirm that this is the correct fix, how they checked to ensure all the added docblocks were only for test
setUp()
methods, and how they checked to make sure there were no typos. I would also expect them to show the grep or similar commands they used to make sure no othersetUp()
methods in HEAD were still missing docblocks once the patch is applied.So, I haven't assigned @marciaibanez contribution credit for this issue, but hopefully this will help with reviewing similar issues in the future.
Thanks everyone!
Comment #12
quietone CreditAttribution: quietone at PreviousNext commentedAdding tag.
Comment #13
NiklanYeah, sure. So I need to provide two patches for 10.0.x and 9.4.x around May 23 or after that date (next day e.g.)?
Comment #14
TR CreditAttribution: TR commentedThis is not sufficient. Drupal did not consistently use the
:void
return type for thesetUp()
method in Drupal 9 - that was not fully fixed until Drupal 10.So your pattern doesn't find all the places that need a docblock. For example,
core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php
and
core/modules/image/tests/src/Functional/ImageFieldTestBase.php
and
core/modules/serialization/tests/src/Kernel/NormalizerTestBase.php
etc.
This means the patch is going to need a lot of changes for Drupal 10.
IMO this should be done in Drupal 10 first, then backported to Drupal 9 if desired. I would hate to see the effort wasted on fixing this in Drupal 9 and not getting the fixes into Drupal 10 ...
Comment #15
NiklanNice catch! Thank you, I'll adjust search pattern and update patches. Will prioritize 10.0.x patch then.
Comment #16
longwaveAdding a date tag and postponing so we know when to work on this again.
> IMO this should be done in Drupal 10 first
Yes, we will need separate patches for 10.0.x and 9.4.x, with the intent to commit them at the same time.
Comment #17
NiklanSorry for noise, having time to adjust regex pattern for search and replace missing docblocks.
Search:
I removed
: void {
part as mentioned above, not all::setUp()
methods has it in 9.4.x branch. It found 21 more results. We don't need to capture group here ((\: void)?
) because seems like this pattern is enough to find all of them.And updated replace pattern (note an empty line before comment starts):
Attach separate patches for 9.4.x and 10.0.x, will update them on May 23.
Comment #18
TR CreditAttribution: TR commentedThe patches in #17 look good, but a few more things are needed for the D9 patch.
I forgot to mention that in Drupal 9, in addition to the missing
:void
, many of thesetUp()
methods are still declaredpublic
instead ofprotected
. So there are somepublic function setUp()
and somepublic function setUp(): void
methods that also need a docblock. Again, the visibility of thesetUp()
method has been fixed in D10, so this only affects the D9 patch.I'm wondering if we should address
tearDown()
at the same time? We usually do. There are only a few of these, but they are strongly correlated with thesetUp()
changes so it will help minimize disruption if we do them at the same time. (If a class has atearDown()
(not many do) and if thattearDown()
is missing a docblock, thesetUp()
method in that class is almost certainly also missing a docblock. So the classes that need a change totearDown()
will be the same as the classes that need a change tosetUp()
.)Searching for
tearDown()
in D9 has the same problems assetUp()
- some arepublic
, some areprotected
, some have:void
, some don't.Comment #19
NiklanUpdated regex which covers method visibility and both
::setUp()
and::tearDown()
methods.Search:
Replace:
Comment #20
NiklanSaw a new commit (f1aad3c2) into core and seems like this issue should also cover
::setUp()
method with parameters. E.g.\Drupal\Tests\rest\Functional\Views\StyleSerializerTest::setUp()
,\Drupal\Tests\views\Functional\ViewTestBase::setUp()
Should it be addressed? If so, how? E.g.
StyleSerializerTest::setUp()
should have just an inhertdoc docblock, butViewTestBase::setUp()
should also have a parameters docs.UPD:
^$\n(protected|public) function (setUp|tearDown)\(\$
found 58 results in 10.0.x branch. And it seems like this is only for tests that extendsViewTestBase
.Comment #21
NiklanAttaching updated patches.
These patches covers
::setUp()
and::tearDown()
methods.I've also added extended docblock for
ViewTestBase::setUp()
, please someone check my language here:Comment #23
quietone CreditAttribution: quietone at PreviousNext commented@Niklan, hope you don't mind that I rerolled this. I was looking at coding standards issues today and discovered this needed a reroll.
I did not search for any new instances that need this change.
Comment #24
longwaveThanks for rerolling.
This is not allowed according to standards, you can either use
@inheritdoc
alone or a full docblock, but not combine the two. See #1994890: Allow {@inheritdoc} and additional documentation for history and discussion to change this.Comment #25
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedI think
@inheritdoc
will be enough here, so I have made changes as per that.Comment #26
NiklanThank you for helping me, folks.
Both patches miss a new
\Drupal\Tests\ckeditor5\FunctionalJavascript\TableTest::setUp()
empty method for all branches.Providing new patches, the patch for 9.4.x and 9.5.x the same because there is no diff between them.
Comment #28
Wim LeersThis patch was neither RTBC nor passing tests. So moving this back to
9.4.x
for a commit now seems imprudent, since it's not in a committable state.Hence moving this to the next beta target phase. https://www.drupal.org/about/core/policies/core-release-cycles/schedule says is the
9.4.x
beta phase. The9.5.x
equivalent is .Comment #29
quietone CreditAttribution: quietone at PreviousNext commentedYes, I know but I felt like getting this back to green. Let's see if this works.
Comment #30
Wim LeersHehehe … 😄
Who knows 🤞
Comment #31
NiklanI've also completely updated patch for Drupal 9.5.x, but not sure do we need it at this point because target is 10.0.x
Comment #32
borisson_The last test here ran into a random JS fail, queued it again.
Comment #33
quietone CreditAttribution: quietone at PreviousNext commentedNeeds some rerolls here. Neither patch applies to 9.5.x or 10.0.x
Comment #34
NiklanComment #35
quietone CreditAttribution: quietone at PreviousNext commented@Niklan, thanks for keeping this up to date!
The patches apply to 9.5 and 10.0 but not 10.1. Setting to NW for a 10.1 patch.
Comment #36
NiklanAdded patch for Drupal 10.1.
Checked patches for 9.5.x and 10.0.x from #34. They are still valid, interdiffs are empty.
Comment #37
quietone CreditAttribution: quietone at PreviousNext commented@Niklan, thanks!
Removing re-roll tag.
Comment #38
NiklanRe-roll all patches, they have changes.
Comment #39
longwaveThank you for continuing to work on this. However, there are lots of files still missing docblocks for setUp(). I generated a list with:
Comment #40
NiklanI see, these with parameters. Attaching updated patches. But these tests methods are using parameters, shouldn't they have descriptions?
Patches in #48 only adds @inheritdoc comment for
setUp()
andtearDown()
methods without (!) parameters.Patches in this comment adds @inheritdoc to all
setUp()
andtearDown()
methods, even if they have parameters.Command above, still showing a single file for all branches:
I don't know how to handle this one. It looks like (and it tells that in comments) a copy-paste code in PSR code style.
Comment #41
NiklanComment #42
longwaveDCOM58Test was copied from Doctrine and is fine to leave as-is I think.
For the tests with parameters I guess we should document the base classes correctly, but any subclasses that have the same parameters should use @inheritdoc. I will double check this later.
Comment #43
longwaveI reviewed the whole 9.5.x patch as that is the largest (some modules have been removed in 10.0.x). The only issue I found was:
This is the only docblock where new parameters are introduced so this cannot use @inheritdoc. I suggest the docblock is something like:
The docs are borrowed from ViewsKernelTestBase which already has a docblock.
All others in this patch are fine to use @inheritdoc as they extend from other base classes.
Comment #44
NiklanRe-rolled
Comment #45
NiklanWoops, PHPStorm again not found empty setUps for
MigrateExecutableTest
andEntityRevisionTest
in 10.1.x branch. Attaching updated 10.1.x patch and two interdiffs for #40 and #44 patches.Comment #46
longwaveThank you for working on this. I checked the patches for all three branches and can't find any missing docblocks, so this issue is RTBC.
Comment #47
alexpottCommitted 2c468a0 and pushed to 10.1.x. Thanks!
Committed c5b049b and pushed to 10.0.x. Thanks!
Committed 1f60cd2 and pushed to 9.5.x. Thanks!
Backported to 9.5.x to keep things aligned - use --3way to apply all the patch successfully.