Closed (fixed)
Project:
Drupal core
Version:
10.3.x-dev
Component:
other
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
4 Nov 2020 at 16:19 UTC
Updated:
18 Jun 2025 at 01:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
adamzimmermann commentedLocally I did the following:
Installed phpcs and other core dependencies.
Pointed phpcs to the 8.x-3.x branch of the coder module that has this unreleased sniff.
Fixed things using the automatic fixing tools.
Found the things that needed manual fixing and addressed them.
Should I include any other file extensions?
I stayed away from filling out empty @todo statements. I didn't want to assume that I was the best person to fill this out. I simply documented that better documentation is needed.
Comment #3
jonathan1055 commentedThis is a great start. To make it better, you can do two things
Just for background info, in #3048495: Fix Drupal.Semantics.FunctionTriggerError coding standard I tried to pull in the -dev release. In /core/composer.json I tried
which did not work. I tried also to get the specific commit
Then I tried changing /core/drupalci.yml
None of the above worked. But finally I did get the new sniff, by patching Coder from within /core/drupalci.yml
This patch from comment #19 in the issue linked above is an example of how to change to drupalci.yml to halt after running the coding standards. I hope these two ideas help, and will save you time.
Comment #4
adamzimmermann commented@jonathan1055 thank you! I'll get back to this next week.
Comment #5
adamzimmermann commentedUploading a patch to run tests with the latest version of coder to verify issues are found.
Comment #6
longwaveComment #7
jonathan1055 commentedNot sure what has happened, but in the dispatcher output, phpcs sniffs.txt we get
Maybe the Coder version change does not work. The log just has
with no mention of 8.3.11. I could not make that work, and ended up having to use a patch on Coder to get the new sniff, see my comments in #3 above.
Comment #8
adamzimmermann commented@jonathan1055 ya it seems it needs something else changed too. I'm going to change it everywhere for the moment, so I can ensure I see the sniff failure.
Fingers crossed that this patch does the trick.
Comment #9
adamzimmermann commentedI am putting this on pause until coder 8.3.11 is included in Drupal core.
Core 9.2 is currently using 8.3.10.
Comment #10
neclimdulIt also has problems with @see and @covers annotations. Are those handled in this updated coder? Should I open some other issues for them?
Comment #11
adamzimmermann commented@neclimdul Those are likely from a previous release and should be separate issues.
https://github.com/pfrenssen/coder/compare/8.3.10...8.3.11
Comment #12
neclimdulNot sure I understand what previous release you're referring to.I was trying to understand if the @todo sniff a generalized annotation sniffer or does it only fix todo problems?
Comment #13
adamzimmermann commentedI'm not referring to a specific release (just some previous release). The @todo sniffing in the latest release is not generalized and only addresses @todo statements.
Hopefully that clears things up!
Comment #14
spokje(@adamzimmermann in #9)
Core 9.2 is now using
Un-postponing.
Comment #15
spokjeAdded parent issue.
Comment #16
spokjeComment #17
spokjeComment #19
spokjeComment #20
longwaveOne little nit and one question about style, otherwise this looks pretty good.
Comment #21
spokjeCommented on style and fixed nit.
Comment #22
quietone commentedMy review may include items out of scope - I am not sure. There are lots of links that use 'project/drupal' instead of just node, not sure if that can be fixed here or not.
Comment #23
jonathan1055 commentedTo speed up the test runs, and to save resources, can you implement the changes to core/drupalci.yml as in patch #5. Not the change to use coder 8.3.11 but the change to remove everything below that. Then the tests just run phpcs and do not waste time and effort running phpunit.
Comment #24
jonathan1055 commentedquietone said
I think we need to:
Only when all three of these are done should we consider anything manual, such as the changes that quietone has highlighted.
Comment #25
spokje@quitone in #22: Fixed them anyway. Maybe a follow-up to check throughout the whole source (or basically module `jsonapi`:innocent:)
@jonathan1055 in #23
I have no clue how to do both of them. I'll just put it back to Needs Work.
Sorry about the manual changes, I only read your comment after I've done those already.
Comment #26
quietone commentedTested locally and the sniff does not care that the sentence following the '@todo' is not in sentence case. If I understand correctly that is what we want? At least that is what I think jonathan1055 is referring to. I am not sure, is a new issue made in coder for that?
Setting to NR for discussion.
Comment #27
spokje@quietone
As far as I understand @jonathan1055 is sure there's a variant of the sniff out there that automagically makes the sentence after the
@todostart with Uppercase.The current sniff, like you already discovered doesn't care about CaPiTaLiSaTiOn, which is not preferable.
Comment #28
spokjeComment #30
spokjeComment #31
spokjeBack to "Needs Work", see #24/#27.
Comment #34
adamzimmermann commentedBased upon my comment here, should this be Needs Review again?
It seems that we have addressed the concerns in #24 and #27
Comment #36
jonathan1055 commentedSo reading your links in https://git.drupalcode.org/project/drupal/-/merge_requests/504#note_116418 it seems we were enforcing a capital letter after the '@todo' but then it was reverted to any non-space character. Lets leave it as-is, and not enforce capitalisation, as there are bound to be examples where the first word is something code-like, such a a lowerCamelCase class and it would just be a pain. Therefore yes I agree with you lets move onwards.
Now that core development has moved on to 10.1.x you might like to start a new MR ad then leave the exitsing one at 9.x in case this gets backported. The first commit on the new MR, in addition to adding the sniff in phpcs.xml.dist, should have two changes in drupalci.yml
(a) to make all files get checked, set sniff-all-files: true
and (b) to save resources and get fast test results by not running any phpunit tests
remove everything below the 'testing' keyword
Comment #38
nikolay shapovalov commentedComment #40
nikolay shapovalov commentedCreate new MR for 11.x branch. Not sure what should be done with drupalci.yml, I think if we use gitlab, then .gitlab-ci.yml should be used.
Waiting for review.
Comment #41
smustgrave commentedCan the changes to the drupalci file be reverted.
Comment #42
nikolay shapovalov commentedRevert changes to the drupalci.yml file.
Comment #44
smustgrave commentedSo searching for "todo:" for example I still get some hits.
So I wonder why the rule didn't find them?
Comment #45
jonathan1055 commentedOpen up the file > and see what they are - they might not be actual todo comments, or rather that the sniff does not think they are.
Comment #46
nikolay shapovalov commentedGreat question.
I found 16 results for "todo:" in .js files the core. I believe this is not the part of this issue, because phpcs doesn't support js file.
And I made search for "todo:" in all files except .js
My suggestion, we just ignore some of the file types or locations on phpcs.
Comment #47
smustgrave commentedSome of the findings in the screenshot aren't in .js file though.
Opened the folders to help, should of done that in first screenshot.
Comment #48
jonathan1055 commentedThanks for the details. Of the six ocurrences you are showing, 2 are .yml 1 is .twig and 1 is .js and the phpcs sniff does not cover those file types.
The last 2 are .php but the text 'todo' is in the middle of a comment. The sniff currently only detects and works on 'todo' when it is at the start of a comment (eiher // or *, with or without the @ tag). But a 'todo' word in the middle of a line, ie following some other words, is not treated as being wrong and needing to be re-formatted for standards.
Here is the todo sniff in Coder. I recall that we commented it quite well :-)
I suppose there could be a case for changing the Coding Standards to try to include and detect a real todo in the middle of a string. Maybe raise that for discussion in the coding standards meeting?
Comment #49
jonathan1055 commentedNow looking through the examples found by @zniki.ru in #46, there are two which are .php files with the 'todo' at the start of the comment.
Those should be found and fixed by the sniff.
Comment #50
nikolay shapovalov commented@jonathan1055
These files is already fixed in the MR.
Maybe I forgot to switch to correct git branch.
I used grep to search for "todo:" and exclude some filetypes:
I was not able to find anything.
Comment #51
jonathan1055 commentedThanks @zniki.ru that is good to hear. So I think this is back to 'needs review' now.
Comment #52
nikolay shapovalov commentedDo we want to fix these violations we manually found in yml, twig, js files?
Comment #53
jonathan1055 commentedYou can do if you want to. But without any sniff/rule to enforce it, there would be nothing to prevent a new occurence being introduced later. It's up to you.
Also, with your grep, I suggest to add
-ito the options to make it case-insensitive.Comment #54
smustgrave commentedRechecked the MR and the .php files from my screenshot are still there.
Should there be a follow up for getting the other file types?
Comment #55
quietone commentedLet's get this back on track.
1) An issue can be made in the Coding standards project to discuss 1) changing the sniff so that the sentence following the '@todo' is capitalized or not and 2) enforcing the rule for non-php files.
2) An issue can be made in Views to decide what to do with the 'todo' statements in those files. They will take more research they are from '09 and '12. They are a special case and should not hold up this issue.
That will allow this enhancement to be added to core.
This also needs a 10.3.x MR.
Comment #56
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #57
quietone commentedComment #58
smustgrave commentedOpened #3444003: The text of an @todo should start with a capitalized word and sniff non-php files in coding standards
#3444004: Decide what to do with the 'todo' statements in view fields in views
Comment #60
xjmOne of the updated @todos was resolved in #3442766: Remove deprecated code from bootstrap and lib/Controller, lib/Config, so I rebased to update for that.
I had a couple other merge conflicts on the update and made the following corrections:
(was missing indentation of the second line)
(had a second, orphaned todo).
Comment #61
xjmHaving circular rebase issues.
Comment #62
xjmI had to force-push a rebase correctly built against 11.x HEAD.
Reviewed locally with
git diff --color-words. There appear to be two things not covered by the sniff:The MR includes a mix of fixing these things in some places and not fixing them in others. There are two options:
I am leaning toward option 2. Edit: It looks like @quietone already recommended this approach too, so we just need to revert the spacing and capitalization fixes in the existing MR.
The URL changes are also out of scope. They are reverting previous improvements, probably from a bad rebase, because the MR has the wrong source branch and there is no 11.x in the issue repo. They should be corrected back to the https and full-path versions.
Comment #63
jonathan1055 commentedFrom #62, in relation to the two things not covered by the sniff, there are already existing Coder issues for both of these:
#3177721: Create sniff for checking the indentation of lines that follow an @todo comment
#3314583: @todo should start with capitalized letter or non-alpha symbol
Comment #64
quietone commentedI restored the URLs and made a fix for a recent commit. I didn't spot any casing errors but it has been a long day for me.
Comment #65
smustgrave commentedNot sure if this should be postponed till the 2 tickets in #63 are done. But marking because this does make a little better now. Can open a follow up though that's actually postponed on those 2 thoughts?
Comment #66
jonathan1055 commentedThe current MR changes 123 files, I've not re-read it again in detail, but it seems good to get those fixed now and not wait on the two subsequernt Coder sniff issues. If we wait, there will be a lot of conflicts/manual fixing again, and probably more new incorrectly formatted ones. Let's not waste the work done here so far, but get it locked in and committed. Doing that now will not make it any harder to fix the finer points when those later issues land.
Comment #67
xjmThis definitely should not be postponed on the other issues; rather, this should go in first.
core/modules/content_moderation/content_moderation.moduleandcore/modules/system/src/Controller/AssetControllerBase.php. (Edit: Other places as well.)core/modules/file/tests/src/Functional/MultipleFileUploadTest.phpand in other places.core/modules/locale/src/PluralFormula.phpis adding a grammatically incomplete sentence to fill out the@todorule.Thanks everyone!
Comment #68
xjmThat said, removing the out-of-scope changes will be a good novice task. I recommend using
git diff --color-wordsto more easily spot the out-of-scope changes.Comment #70
superfluousapostrophe commentedI worked on this at #portland2024 & updated the MR to fix another few coding standard items.
Comment #71
mradcliffeIt looks there are additional changes that are yet to be made that @xjm requested in #68 so I am changing this back to Needs work.
Comment #73
manish-31 commentedI have rebased the MR, resolved conflicts from
/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.phpand/core/modules/system/src/Controller/AssetControllerBase.phpAlso, added some more fixes as per the comment #62.
Comment #74
smustgrave commentedAppears out of scope changes have been reverted.
Comment #75
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #76
manish-31 commentedResolved merge conflicts. Needs review.
Comment #77
larowlanUpdating credits
Comment #81
larowlanCommitted to 11.x and 11.0.x. Needs a 10.4.x and 10.3.x specific version
Would be good to get that in today before the freeze
Comment #83
larowlanComment #84
simeI have review all changes and confirm that only comments are being changed. Mostly these are @todos but there is a small amount of whitespace being fixed (only in comments).
I tested the new rule
These pass
These fail
I didn't dive further into /** */ - everything in core is passing which is the critical part I believe.
Comment #88
larowlanReviewed locally with --color-words
Committed to 10.4.x and backported to 10.3.x
Ran phpcs for that rule for 10.3.x against all files locally and it passed
phpcs --standard=core/phpcs.xml.dist -p --sniffs=Drupal.Commenting.TodoComment coreAsking @quietone if we normally do a change record for this kind of change.
Comment #89
quietone commentedAccording to the recently added Change records, a CR is not needed here.
Comment #91
xjmAmending attribution.