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.
Part of meta-issue #1518116: [meta] Make Core pass Coder Review
Comment | File | Size | Author |
---|---|---|---|
#54 | contact-coder-1533112-54.patch | 31.96 KB | mcdruid |
#49 | contact-coder-1533112-49.patch | 31.85 KB | herom |
#49 | interdiff-1533112-44-49.txt | 5.87 KB | herom |
Comments
Comment #1
TravisCarden CreditAttribution: TravisCarden commentedDrupal Code Sniffer reports the following, but I suspect it is to be ignored in core. (If someone can confirm, I'll file an issue against the sniffer about it.)
Comment #2
NROTC_Webmaster CreditAttribution: NROTC_Webmaster commentedThat is correct according to the coding standards see http://drupal.org/coding-standards#naming
Although I don't know if this should actually be changed or not.
Comment #3
TravisCarden CreditAttribution: TravisCarden commentedI filed this issue for confirmation: #1533516: Clarify global variables naming standard in Core.
Comment #4
roborn CreditAttribution: roborn commentedErrors in #1 don't show up anymore.
Only these:
Updated the patch to fix it.
Comment #5
TravisCarden CreditAttribution: TravisCarden commentedThanks for the patch, @roborn.
I'm skeptical about this change. I realize I originally introduced it, but coming back to it, I don't see its necessity; so if drupalcs complains about it, I think drupalcs might need to be adjusted. What does everyone else think?
Adding @param and @return types has been excluded from this effort, to be handled in a separate issue. See "Proposed resolution" #5 in the meta issue.
I'm going to leave this in "Needs review" pending comment from someone more knowledgeable than I. We may need to make further changes to the sniffer before we can productively proceed. We'll see.
Comment #6
ramlev CreditAttribution: ramlev commentedI have checked the complete contact module, and it doesn't output any codesniffer errors.
Comment #7
TravisCarden CreditAttribution: TravisCarden commentedThank you, @ramlev, but this patch has the same problems. Please read comment #5.
Comment #8
ramlev CreditAttribution: ramlev commentedAbout #5.1. and the output of the array, i dont really see the issue here, i think it more readable as done in the patch. I can agree with you if the array is done with
$rows[] = [[x, y, z]];
#5.2 - No need for splitting it up in two issues, since we're handling the file already and it's such small a fix.
Comment #9
TravisCarden CreditAttribution: TravisCarden commentedThank you, @ramlev. We'll see what others have to say on #5.1. Concerning #5.2, the decision has been made by those who will be reviewing and committing the patches. It's not up for discussion. I'm postponing this issue for now.
Comment #10
Lars Toomre CreditAttribution: Lars Toomre commentedWhen the patch for this issue is next re-rolled, please remember to include a blank line before the closing brace in the declaration of the class in the files ContactAuthenticatedUserTest.php and ContactPersonalTest.php.
Comment #11
sphism CreditAttribution: sphism commentedWe have the go ahead with all these issues again, see #1518116: [meta] Make Core pass Coder Review for more details
Comment #12
TravisCarden CreditAttribution: TravisCarden commentedAll right, now that the codebase is wildly different, here's another patch. :) Note: It can be helpful, to reduce the "noise" in the patch review, to apply the patch to a local repository and use
git diff --word-diff
to show only the characters that have changed, rather than the entire lines.Comment #13
sphism CreditAttribution: sphism commentedI'll take a look at this and review it today
Comment #14
sphism CreditAttribution: sphism commentedJust downloaded and applied the patch successfully.
contact.module looks good to me
contact.pages.inc looks good too
CategoryListController.php: should the function declarations within a Class have @param and @return documentation?
MessageFormController.php:
not really sure what the point of the ';' is here, probably makes more sense to say "...sender name is not verified as it could potentially ..."
Other than that it's good
Message.php is good
ContactAuthenticatedUserTest.php: I'm not sure about how this stuff is meant to be written so can't really review it, but I think it's correct... OK, according to this php documentation http://php.net/manual/en/language.oop5.visibility.php if you declare a function within a class without declaring it as public, protected or private, then it IS public, so adding the keyword 'public' is probably best practice - i'd say this is all good.
ContactPersonalTest: This one is interesting.... not sure i can review it, it seems correct to me but can someone else please review
ContactSitewideTest: good
ContactUpgradePathTest: good
MessageEntityTest: good
ContactFieldsTest: good
ContactLinkTest: good
drupal-7.contact.database: good
contact_test_views: why do we need an empty file? The changes are good, but seems redundant.
When I run drupalcs on command line I still get a lot of errors, most of them seem to be due to:
Not starting with a capital letter, and not ending with a full stop (period). Has this been filed as an issue with Coder project?
The only other issues I see are the array declarations in ContactSitewideTest.php
I think we should split out the arrays onto multiple lines, the issues are on lines; 98, 111, 148, 219 and 276 - although I'm happy to leave these for the time being since no one's really sure what they are meant to look like :)
Great work @traviscarden, if you can convince me about those few things I'm not sure about (eg private vs protected) i'll mark it RTBC
Comment #15
TravisCarden CreditAttribution: TravisCarden commentedRe: class methods having
@param
and@return
directives, yes they should, unless said methods are overriding other methods on base classes--in which case the overridden methods should have that documentation.Re: method visibility, your assessment is correct. Unspecified methods are treated as public, so my approach has been to just explicitly mark them as such, since doing so makes no functional changes (and since this initiative is about documentation, not functionality, that's how I try to play it until a more senior contributor tells me otherwise).
Re: the empty module file, unless I'm mistaken Drupal doesn't treat something as a module unless it has a .module file--even if it's empty--so that file is necessary.
Re: the
@inheritdoc
comments, make sure you're using the latest version of Coder Sniffer--it has support for those. See the installation guide. I cloned the coder repo in my ~/.drush directory andgit pull
regularly to make sure I have the latest changes. Then I can rundrush dcs .
in any directory on my machine without any bash aliases or fancy business.Re: multi-line array declarations, trust me when I say that making an issue out of that is a good way to get this initiative stalled again. :) That's been a contentious topic, and there's a separate issue for it now, so it's best to just patch Coder Sniffer per #1518116-69: [meta] Make Core pass Coder Review to omit the sniff and move forward.
Comment #16
sphism CreditAttribution: sphism commentedComment #17
jhodgdonThis change is incorrect:
On tests, the getInfo() method does *not* get any documentation. period. Nor setUp(), or tearDown(). If Coder is saying they need docs, Coder is wrong.
I also don't think generally that we are using camelCase for member variables in classes, are we? I'd like to know whether (a) that's the standard or (b) it's generally followed in Core before we try to "fix" this all over core.
Comment #18
TravisCarden CreditAttribution: TravisCarden commentedgetInfo()
,setUp()
, andtearDown()
on test classes. I see there's already an issue to fix this: #1805550: Modify sniff for "Missing function doc comment" for test classes. Is there documentation of this matter that can be referenced there? How does #338403: Use {@inheritdoc} on all class methods (including tests) relate to all this? In any case, I've removed those changes from my patch.Can I set this back to RTBC?
Comment #20
jhodgdonRE #18:
1. Yes that other issue would be good to decide on a more consistent standard, but it isn't decided and has been sitting for months. The current standard is at https://drupal.org/node/325974
2. What I was trying to say was that camelCase for class properties is I think one of those "standards" that has been formally adopted but that most of core doesn't comply with (I think). In cases like that we need to consider whether complying with the adopted standard is a better idea than revising the standard. I'd like to see a survey of class properties in Core to see how many are camel and how many use underscores... but my guess is that we're mostly using underscores and it would be better to change the standard to match what we're doing than to try to enforce a standard that no one follows.
Comment #21
TravisCarden CreditAttribution: TravisCarden commentedHmm. My IDE missed a couple of variables. (That's disconcerting.) Let's try this again.
Comment #22
TravisCarden CreditAttribution: TravisCarden commentedThe patch no longer applies. For whomever rerolls it, please consider the following common issues I've been seeing in this meta issue:
Comment #23
Jalandhar CreditAttribution: Jalandhar commentedComment #24
Jalandhar CreditAttribution: Jalandhar commentedAttaching the patch which fixes all coder reviews. Please review it.
Comment #25
Jalandhar CreditAttribution: Jalandhar commentedComment #26
majoely CreditAttribution: majoely commentedI applied the patch and got an issue with the following:
Patch Failed
core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php:50
core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php:118
patch does not apply
core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
I will look into it and repost soon.
Comment #27
majoely CreditAttribution: majoely commentedI found a couple of things that didn't tie up in the ContactPersonalTest portion of the patch that I found different to the file itself.
1. Line 58 of the 8.x file has four parameters in it were as the path only has three:
2. Line 90 to 102 in the 8.x file is entirely missing from the patch
I started throwing myself down a rabit hole so I stopped looking because I am not sure whether these are errors in the patch or a result of my naive understaing of patches.
Comment #28
majoely CreditAttribution: majoely commentedOk so I slept on it and finished an essay and had an idea, so I will try to create a new patch by removing and redoing the bits that I have problems with.
Comment #29
majoely CreditAttribution: majoely commentedI have created a new patch for this issue by.
Comment #31
majoely CreditAttribution: majoely commentedAttempt two to pass the tests.
Comment #32
majoely CreditAttribution: majoely commentedComment #33
Anonymous (not verified) CreditAttribution: Anonymous commentedPatch #31 needed a reroll, attaching new patch.
Comment #34
herom CreditAttribution: herom commentedreroll, and update.
Comment #36
herom CreditAttribution: herom commentedmissed that one.
Comment #37
Jalandhar CreditAttribution: Jalandhar commentedPatch #36, no longer applies. It needs reroll.
Comment #38
herom CreditAttribution: herom commentedreroll + a few more coder fixes.
Comment #40
herom CreditAttribution: herom commentedsorry, bad reroll.
Comment #43
blattmann CreditAttribution: blattmann commentedI am reviewing/rerolling this now. Patch in #40 does not apply to HEAD right now.
Comment #44
blattmann CreditAttribution: blattmann commentedI've rerolled the patch manually.
Comment #46
herom CreditAttribution: herom commentedIt failed with the "Too many connections" errors. I'll retest to see how it goes.
Comment #49
herom CreditAttribution: herom commentedFixing the test, and a couple more coder issues.
Comment #50
blattmann CreditAttribution: blattmann commented@herom, is there anything else I can do to help on this? i.e. What needs to happen now?
Comment #51
herom CreditAttribution: herom commentedYou can do a review by running Coder against the contact module, to see if any errors are remaining. The parent issue explains how to do that:
Just a note that Coder Sniffer might mark some
/** @var
lines as error, but that is a false-positive.You can also look at the patch to see if all the changes are correct.
If you didn't find any issues with the above, you can mark the issue as RTBC.
Comment #52
jsobiecki CreditAttribution: jsobiecki commentedComment #53
mcdruidComment #54
mcdruidRe-rolled patch.
Only conflict was addition of the $third_party_settings argument to the addContactForm function:
Comment #55
mcdruidComment #56
xjmThanks for all the work here so far. See #1518116-86: [meta] Make Core pass Coder Review. This issue is postponed until the meta issue is either closed or reopened.
Comment #57
pfrenssenClosing in favor of #2571965: [meta] Fix PHP coding standards in core. In this issue the coding standards will be fixed on a sniff-per-sniff basis rather than a module-per-module basis.