Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml shows the following errors/warnings, which should be fixed, when they are not false positives.
FILE: ...l/form_mode_manager/tests/src/Functional/FormModeManagerBase.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
105 | ERROR | The @var tag must be the first tag in a member
| | variable comment
| | (Drupal.Commenting.VariableComment.VarOrder)
171 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
| | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
180 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
| | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
----------------------------------------------------------------------
FILE: ...form_mode_manager/tests/src/Functional/FormModeManagerUiTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
256 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
| | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
340 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
| | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
361 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
| | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
----------------------------------------------------------------------
FILE: ...m_mode_manager/tests/src/Functional/FormModeManagerRouteTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
29 | WARNING | Unused variable $node_type_test_page.
| | (DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable)
239 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
| | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
----------------------------------------------------------------------
FILE: ...s/form_mode_theme_switcher/src/Theme/FormModeThemeNegociator.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically.
| | The first wrong one is
| | Drupal\Core\Config\ConfigFactoryInterface.
| | (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
13 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class
| | name (Drupal.Commenting.ClassComment.Short)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: ...usr/local/form_mode_manager/src/Form/FormModeManagerFormBase.php
----------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
----------------------------------------------------------------------
10 | ERROR | [x] Use statements should be sorted alphabetically.
| | The first wrong one is
| | Drupal\Core\Form\ConfigFormBase.
| | (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
19 | ERROR | [ ] Unnecessarily gendered language in a comment
| | (Drupal.Commenting.GenderNeutralComment.GenderNeutral)
139 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
| | (DrupalPractice.Objects.GlobalFunction.GlobalFunction)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: ...mode_manager/src/Plugin/Derivative/FormModeManagerLocalTasks.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
9 | ERROR | [x] Use statements should be sorted alphabetically. The
| | first wrong one is
| | Drupal\Core\StringTranslation\StringTranslationTrait.
| | (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: ...usr/local/form_mode_manager/src/Plugin/EntityRoutingMap/Term.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
22 | WARNING | The class short comment should describe what the
| | class does and not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
----------------------------------------------------------------------
FILE: ...usr/local/form_mode_manager/src/Plugin/EntityRoutingMap/User.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
22 | WARNING | The class short comment should describe what the
| | class does and not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
----------------------------------------------------------------------
FILE: ...usr/local/form_mode_manager/src/Plugin/EntityRoutingMap/Node.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
22 | WARNING | The class short comment should describe what the
| | class does and not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
----------------------------------------------------------------------
FILE: ...l/form_mode_manager/src/Plugin/EntityRoutingMap/BlockContent.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
25 | WARNING | The class short comment should describe what the
| | class does and not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
----------------------------------------------------------------------
FILE: ...r/local/form_mode_manager/src/EntityFormModeManagerInterface.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
9 | WARNING | The class short comment should describe what the class
| | does and not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
----------------------------------------------------------------------
FILE: ..._mode_manager/src/Controller/FormModeManagerEntityController.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
17 | ERROR | [x] Use statements should be sorted alphabetically. The
| | first wrong one is
| | Drupal\form_mode_manager\EntityRoutingMapManager.
| | (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: /usr/local/form_mode_manager/src/EntityRoutingMapBase.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
7 | ERROR | [x] Use statements should be sorted alphabetically. The
| | first wrong one is
| | Drupal\Core\Plugin\ContainerFactoryPluginInterface.
| | (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
15 | ERROR | [ ] Unnecessarily gendered language in a comment
| | (Drupal.Commenting.GenderNeutralComment.GenderNeutral)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: /usr/local/form_mode_manager/src/FormModeManagerInterface.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
9 | WARNING | The class short comment should describe what the
| | class does and not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
198 | ERROR | Unnecessarily gendered language in a comment
| | (Drupal.Commenting.GenderNeutralComment.GenderNeutral)
----------------------------------------------------------------------
FILE: /usr/local/form_mode_manager/src/EntityRoutingMapInterface.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The
| | first wrong one is
| | Drupal\Component\Plugin\ConfigurableInterface.
| | (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: ...ger/src/Routing/EventSubscriber/EnhanceEntityRouteSubscriber.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
8 | ERROR | [x] Use statements should be sorted alphabetically. The
| | first wrong one is
| | Drupal\form_mode_manager\EntityRoutingMapManager.
| | (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: ...mode_manager/src/Routing/EventSubscriber/FormModesSubscriber.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
11 | ERROR | [x] Use statements should be sorted alphabetically. The
| | first wrong one is
| | Drupal\form_mode_manager\EntityRoutingMapManager.
| | (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: /usr/local/form_mode_manager/src/MenuLinksInfo.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
73 | ERROR | Long array syntax must not be used in doc comment code
| | annotations
| | (Drupal.Commenting.DocCommentLongArraySyntax.DocLongArray)
----------------------------------------------------------------------
Time: 822ms; Memory: 14MB
Comments
Comment #2
rakhi soni commentedI have created a patch to fix the issue of Drupal Coding Standard As Per Phpcs Standard Drupal,, please review.
Comment #3
akshaydalvi212 commentedHi,
I will review this patch.
Comment #4
akshaydalvi212 commentedHi,
After applying the patch, the Drupal coding standard errors are eliminated.
so shifting the issue to Reviewed and tested by the community.
Comment #5
akshaydalvi212 commentedComment #6
dwwThanks!
Comment #7
Tauany Bueno commentedhi! i'll work on it :)
Comment #9
Tauany Bueno commentedHi,
I applied the patch on 8.x-2.x and fixed some other phpcs issues related to @TODO (.txt attached). Also, changed the approach to facilitate future revisions.
Changing the status to needs review.
Comment #10
Joel Guerreiro Borghi Filho commentedHi, I will review this.
Comment #11
Joel Guerreiro Borghi Filho commentedI was not able to apply the #2 patch on 3291954-drupal-coding-standard branch. However, I fixed a couple more errors shown by phpcs after running phpcs (phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml form_mode_manager/)
This patch contains the changes I made to the code. No phpcs errors are showing.
Please review. =)
Comment #12
damiaosj commentedI'll review this one.
Comment #13
damiaosj commentedRevised and tested through @tauanygb branch as said in the comment #9, and applied the patch of the @Joel Guerreiro Borghi Filho as said on the comment #11.
I have made some other fixes by the phpcbf and now seems fine.
Changing status to RTBC.
Comment #14
damiaosj commentedComment #16
dwwThanks for the flurry of activity, everyone! Nice to see so many new folks actively trying to contribute upstream. Welcome!
This was getting confusing and hard to review, since we've now got both patches and an MR. Plus, there's a mix of good changes and stuff that doesn't actually help the code in each of the approaches.
So, to hopefully simplify things, let's start over. I just ran `phpcbf` myself, reviewed the resulting diff, and pushed that to 8.x-2.x.
That leaves everything that phpcs is still complaining about. Let's start clean with a new effort on top of the latest 8.x-2.x code. Some problems with previous approaches:
{@inheritDoc}only works on methods or properties you're inheriting from a parent class where the thing is documented. In this case, there is no parent class, so there's no documentation to inherit.While this might silence the phpcs warning, it's not valid, and doesn't make the code any easier to read or understand.
If we're going to fix these boilerplate class comments, we need to write something valid for each one.
Confusingly, "it's" is short for "it is". You mean "its", the possessive form of "it". English is a terrible language. 😅 I'm so sorry.
Thanks again!
-Derek
Comment #17
dwwRe: #16.1: Looking at patch #2:
This is an equally unhelpful change. 😉
Thanks again,
-Derek
Comment #18
Joel Guerreiro Borghi Filho commentedHello Derek! Thanks for the warm welcome and the helpful direction on the issue!
I Will work on it!
Comment #19
Joel Guerreiro Borghi Filho commentedHello, based on the comment #16, I started out from the 8.x-2.x code, made changes and created this new patch.
Kindly review it please.
Comment #20
Joel Guerreiro Borghi Filho commentedDisregard comment #19 and patch 3293335-8.patch, I uploaded the wrong one. Sorry.
The patch for review is the 3291954-20.patch
Comment #21
elberComment #22
elberHi I applied and revised the patch #20.
I ran the command mentioned in the issue summary ($ phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml form_mode_manager/).
After that I saw that all coding standards was resolved.
Comment #24
kunalgautam commentedMore fixes of PHPCS issues.
Comment #25
kunalgautam commentedComment #26
kunalgautam commentedComment #27
urvashi_vora commentedComment #28
urvashi_vora commentedPatch #26 failed to apply. There are several issues remaining
I will work on them. Assigning it to myself. Thanks
Comment #29
urvashi_vora commentedFixed all remaining issues. Committing the changes. Please review.
Comment #30
mahima_mathur23 commentedComment #31
elberHi I rewieved all the changes
I ran these commands
phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,ymlphpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,ymlPHPCS errors has been fixed.
Rebase already have done
Moving to RTBC
(Tests is failing before the issue)
Comment #32
dwwNot true. Tests are failing like so:
That's because of these kinds of changes in the MR:
This is completely the wrong "fix" for these. We shouldn't use t() at all in tests (unless we're explicitly testing translatability). See #3133726: [meta] Remove usage of t() in tests not testing translation.
For all the changes like the above, we really want:
This is part of why I've come to completely hate these "fix phpcs" issues that everyone seems so excited about trying to get credit for. Y'all use automated tools to get some changes done, then make a mess of things you don't fully understand, then lots of folks pile on to "review" and "validate" the brokenness. The whole thing is a giant waste of time for almost no value. 😢
I'm tempted to close this as "won't fix"...
Comment #33
elberHi I fixed the tests that you mentioned before, but I checked the 8.x-1.x version of this module there has a lot of failing tests like this
My suggestion is opening another issue to fix all the tests in 8.x-1.x branch
Comment #34
elberHi please revise.
Comment #35
roberttabigue commentedHi @Rakhi,
Confirmed fixed the PHPCS errors after applying plain diff file to the Form mode manager module against the 8.x-2.x-dev and with the Drupal core of 9.5.6.
Moving this now to RTBC.
Kindly refer to the screenshots attached, please.
Thank you.
Comment #36
avpaderno{@inheritDoc}is not used for a class documentation comment.It is not even used for an interface documentation comment.
The correct word is its not it's, since that is the possessive for the third person it.
That is not the correct short description for an interface. It does not even make sense, since an interface is not an interface for itself.
A class short description must not start with Class For, nor merely repeat the class name.
Comment #37
avpadernoComment #38
elberI will work on it.
Comment #39
elberHi I just fixed the issues reported before. Please revise
Comment #40
roberttabigue commentedHi @elber,
After applying your MR !6 and rerunning the phpcs, a new warning was displayed.
Kindly refer to the screenshots attached, please.
Thanks.
Comment #41
elberHi it was happening before my changes but I fixed it now, please revise.
Comment #42
roberttabigue commentedHi @elber,
Confirmed fixed now after applying your latest MR.
Moving this now to RTBC.
Please refer the attached screenshot.
Thanks.
Comment #43
avpadernoClass short descriptions do not start with Class.
Interface short descriptions do not start with Interface.
It is form class.
The verb must use the third person singular.
Entity is misspelled, since it is not the first word in the sentence.
No comma is added between to and the following verb.
The verb is not necessary.
The previous change I quoted is correct. This change is not.
{@inheritDoc}is not used in class documentation comments.Comment #44
elberComment #45
avpadernoIt is form class, not FormClass.
English does not put commas between a verb and its object. It is not My cat is, lovely. but My cat is lovely.
I am not sure that is a suitable description for an interface, as an interface just defines a list of methods; it does not load entities.
Assuming that class really creates basic nodes, the verb must use the third person singular.
For a
Termclass, that description does not say much.Adding For (which should not be capitalized) does not improve that documentation comment. It even makes the description wrong, since a
Userclass is not a class for User.Comment #47
lucienchalom commentedTo make the text were we had FormClass more redable, I changed a couple of things. Looks like this now:
The interface description I changed to "An interface to get and return information on form modes."
And for "class node", "class term" and "class user" I changed to "Creates ___ routes".
Are those better?
Thank you for reviewing.
Comment #48
lucienchalom commentedChanged the comments based on the review, thank you!
Comment #49
elberHi reviewed the changes.
PHPCS errors has been fixed I ran
Apaderno's suggestions were made
It sounds good to me.
moving to RTBC.
Comment #50
avpadernoComment #52
sakthi_dev commentedComment #53
roberttabigue commentedHi,
Reviewed the latest MR and applied it to the module, confirmed no PHPCS errors were detected.
Please see the attached file.
Moving this to RTBC.
Thank you!
Comment #54
avpadernoComment #55
nitin_lamaComment #56
nitin_lamaComment #57
elberComment #58
avpadernoComment #59
Shreyas gowda commentedComment #62
trackleft2Updated code comments with proper English.
Added string translation back to tests.
While it appears all the PHPCS errors have been resolved,
here were my results running phpunit locally on Drupal 9.5 PHP 8.1
Comment #63
avpadernoComment #64
avpadernoTo make the last point clearer: Tests do not normally set a language for the tested pages, which means that messages in those pages are always in English. It is useless to call
$this->t()ort()when the returned message is the same string passed to that method/function.Comment #65
trackleft2Comment #66
avpadernoThe issue summary reports errors/warnings for 12 files, but the MR changes 18 files. Either the issue summary must be updated, or the MR is changing more files than necessary.
Comment #67
avpadernoComment #68
avpadernoComment #69
elc commentedOh bother. I merged all of the PHPCS changes created as a sub-merge of #3297262: Drupal 10 compatibility fixes into it. That was probably a mistake. It is going to be a mess to merge both together as it currently reports no phpcs output.
Comment #70
trackleft2I've updated the summary
Comment #71
trackleft2@ELC, it was a small mistake, however, it is easy enough to fix. I'll do it.
Comment #72
trackleft2Comment #73
avpadernoComment #74
trackleft2Comment #75
trackleft2Oops introduced some whitespace.
Comment #76
trackleft2Comment #78
dwwHi everyone. Thanks to everyone trying to help in here and improve the code. Sorry I let this drag on for so long. The level of noise being generated in here is very high...
@apaderno: While your desire to educate and train other contributors is very admirable, in this case, I'd recommend either:
I tried to go through and save credit for everyone who seemed to be attempting to contribute here in good faith. A few "contributions" were borderline, apologies if you feel left out.
I rebased this after committing #3291950: Remove t() calls in tests not testing translation, pushed a few other fixes, merged to 8.x-2.x, and pushed commit eadc8e36fc
Calling this fixed at last! 🎉
Comment #80
dww