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 |
---|---|---|---|
#46 | interdiff.txt | 776 bytes | TravisCarden |
#46 | drupal-block-code-review-1522384-46.patch | 74.75 KB | TravisCarden |
Comments
Comment #1
TravisCarden CreditAttribution: TravisCarden commentedHere's a patch.
It brings the line under 80 characters, and it avoids the unseemly 21 line array declaration, but if people find it confusing, we can discuss alternatives.
Is line 332 a false positive? It seems like we seldom if ever do this across core.
I don't know if there's a good solution for lines 310 and 335. The comments refer to the whole function, so it doesn't seem right to merge them with another comment (310) or place them right above an individual statement (335). I'd take suggestions.
Comment #2
droplet CreditAttribution: droplet commentedbut worse in performance ?
Comment #3
TravisCarden CreditAttribution: TravisCarden commentedComment #4
webchickSince that's just example code, I'd recommend shortening it to whatever's in core elsewhere that it's not complaining about. The new code definitely raises more questions than it answers, which is particularly a problem since it is code intended to explain to new developers how the code works. :)
Comment #5
TravisCarden CreditAttribution: TravisCarden commentedrange()
:That's nice 'n simple.
Comment #5.0
TravisCarden CreditAttribution: TravisCarden commentedAdded related issue.
Comment #6
TravisCarden CreditAttribution: TravisCarden commentedRerolled for upstream changes and updated summary.
Comment #7
dinakaran.ilango CreditAttribution: dinakaran.ilango commentedi have tested your latest patch in #6 it is showing the same error
Comment #8
lotyrin CreditAttribution: lotyrin commentedCore is exempt from that rule, afaik.
Comment #9
TravisCarden CreditAttribution: TravisCarden commentedYes, core is exempt. This patch nevertheless needs to be rerolled without the
@param
and@return
types per the new directions on the initiative page. I'll get back to it when I can.Comment #10
roborn CreditAttribution: roborn commentedNow, i don't get the error on #7
Here's an updated patch with more fixes.
Only these two warnings left.
Fixing these two warnings makes the comments less readable (a lot). What's the best practice here: ignore the warnings if it's more readable, or be strict about the coding rules?
Comment #11
Lars Toomre CreditAttribution: Lars Toomre commentedIt appears that the patch in #10 does not include any changes to the BlockTest.php file. I wonder why that is.
When this patch is next re-rolled, we need to remember to change class members to use camel case. Hence, members like admin_user need to be changed to adminUser.
Also, we need to check all tests to make sure that there is a blank line after the class declaration and another before the closing brace of the class declaration.
I am not sure if either of these types of issues are being flagged in the Coder Review process.
Finally, when this patch is re-rolled, all type hinting of @param and @return directives should be removed. They instead should be added as a separate patch to #1807674: Add missing type hinting to Block module docblocks.
Comment #12
TravisCarden CreditAttribution: TravisCarden commentedPostponing till feature freeze. If you want to help in the meantime, please work on the blockers on the meta issue. Thanks!
Comment #13
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 #13.0
sphism CreditAttribution: sphism commentedUpdated summary.
Comment #14
TravisCarden CreditAttribution: TravisCarden commentedComment #15
visabhishek CreditAttribution: visabhishek commentedComment #16
visabhishek CreditAttribution: visabhishek commentedI have created a patch after passing through coder. Please review.
Comment #17
saltednut16: drupal-make_block_module_pass_coder_review-1522384-16.patch queued for re-testing.
Comment #19
saltednutComment #20
saltednutHere is a reworking. The following errors still show up but there's some reasons we can't fix them:
This is a case where we declare the PSR-0 namespace of a class.
This is a case where we declare the PSR-0 namespace of a class.
This is a case where we declare the PSR-0 namespace of a class.
This is essentially an API change if I understand correctly so might be worth bringing up in its own issue.
Seems coder doesn't know what to do with a usort function? This looks like proper indentation to me.
This is a case where we declare the PSR-0 namespace of a class.
Comment #21
saltednutComment #23
saltednutComment #25
saltednutcore/modules/block/tests/Drupal/block/Tests/BlockBaseTest.php
was updated. Reroll and fixed error from #23.Comment #26
tim.plunkettThis is a tricky bit of code, and its much clearer when split onto multiple lines like this
Similarly, I don't find this more readable.
This is done on purpose for typehinting. Please revert this change.
If a @todo is multiline, the other lines must be indented 2 extra spaces
This is no longer valid. Put it back to one line and keep the | please
Comment #27
saltednutThanks for the review!
Comment #28
tim.plunkettThis still defeats the purpose of multiline arrays, since it will look *really* weird if we ever need to add a new line to this. Thanks for making the other changes, but I still think this should just be left alone.
Comment #29
saltednutOkay. We should still add the comma though, no?
Comment #30
tim.plunkettSure adding the comma is fine, but this is still wrong
- $settings = array(
- 'values' => &$form_state['values']['settings']
+ $settings = array('values' =>
+ &$form_state['values']['settings'],
);
Comment #31
saltednutAh yeah, of course. Thanks for being so patient with me here.
Comment #32
tim.plunkettThank you, I figured it was okay to nitpick a coding standards fixing issue :)
Looks good to me!
Comment #33
TravisCarden CreditAttribution: TravisCarden commentedSorry; just one more thing:
This is an ingenius little trick to satisfy the translation system's interface (and thus Coder Sniffer), but I'm afraid that the practical result may be equally undesirable: "@label" isn't a string that a translator could possibly do anything meaningful with. It may be better to treat this as a false positive and leave it out of the patch.
@tim.plunkett, do you agree?
Comment #34
tim.plunkettHonestly, we can just drop the t() altogether.
Comment #35
sriharsha.uppuluri CreditAttribution: sriharsha.uppuluri commentedNeeds some rework on this patch. I'm working on this.
Comment #36
sriharsha.uppuluri CreditAttribution: sriharsha.uppuluri commentedI have ignored few errors referring to this comment https://drupal.org/comment/8644877#comment-8644877 point 3.
Comment #37
sriharsha.uppuluri CreditAttribution: sriharsha.uppuluri commentedComment #38
saltednut36: drupal-block-code-review-1522384-36.patch queued for re-testing.
Comment #39
saltednutComment #41
saltednutThis is basically a reroll as block.js has moved to js/block.js
Comment #42
TravisCarden CreditAttribution: TravisCarden commentedUpstream changes necessitated a reroll. There were also some issues that the previous patch didn't address and a few patterns it didn't get quite right. (See the interdiff.txt.) It's possible we could find more niggles if we kept looking, but I believe what I've attached satisfies all the strict requirements. I think we should get this committed before we need to reroll again!
Comment #43
TravisCarden CreditAttribution: TravisCarden commentedD'oh! Missed one little thing.
Comment #44
TravisCarden CreditAttribution: TravisCarden commentedComment #45
tim.plunkettThis is not okay, what's in HEAD is a standard pattern.
Comment #46
TravisCarden CreditAttribution: TravisCarden commentedThanks, @tim.plunkett. I just got the same feedback elsewhere from @webchick. We'll want to fix Coder Sniffer, because it complains about it:
The folks over there like it when we can point to documentation. A quick search didn't turn up any on this topic for me. You don't know of anything do you?
In the meantime, here's a patch with that change removed.
Comment #47
TravisCarden CreditAttribution: TravisCarden commentedUpdate re Coder Sniffer: issues have been filed to fix false positives, and our Coder fork has been patched accordingly. See #1518116-76: [meta] Make Core pass Coder Review.
Comment #48
dcam CreditAttribution: dcam commentedClosed the related issue as a duplicate. There is a 7.x patch in it.
Comment #51
jsobiecki CreditAttribution: jsobiecki commentedComment #52
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 #53
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.