Postponed on #3054969: Add sniff for \Drupal vs Drupal
Problem/Motivation
The leading \ for class names is used inconsistently. This issue is to ensure class names in comments have a leading '\'.
Original Issue Summary
The @deprecated tag for RESPONSIVE_IMAGE_EMPTY_IMAGE contains a full class name which is missing the leading "\".
Steps to reproduce
Proposed resolution
Review
Commit
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | 2912687-38.patch | 165.99 KB | codersukanta |
| #38 | interdiff_33-38.txt | 1.04 KB | codersukanta |
| #34 | interdiff-30-33.txt | 631 bytes | atul4drupal |
| #33 | interdiff_29-33.txt | 0 bytes | ridhimaabrol24 |
| #33 | 2912687-33.patch | 166.73 KB | ridhimaabrol24 |
Comments
Comment #2
angel.hPatch added.
Comment #3
valthebaldLet's check if there are other missing slashes in type comments?
Comment #4
angel.hFound other occurrences in comments and added a patch.
Comment #5
valthebaldUpdating issue title and summary to better reflect what the patch does
Comment #6
wengerkEverything seems fine for the component
responsive_image.module. I apply it on 8.5.x-dev.I just found a "typo" on the DockBlock of
shortcut_set_assign_userincore/modules/shortcut/shortcut.module. The parameter & type/class were inverted.I think we can also fix this into this patch.
Also, to go further, I try to found every other
// Drupal\or* Drupal\in the core and found plenty others (63 results), should we have to fix them in this issue or another one with a more general context should be created ?Comment #7
ndobromirov commentedTogether with Nevena Kostova we've found a bit more broken paths in doc blocks through the following reg-ex search (400+), during the code sprints in Vienna 2017.
Note that it is not filtering out the findings in strings in php code for some reason (there are some false-positives in the search results), but this are easy to ignore when checked manually and they are like 20-30% of the results count.
The regex was run in NetBeans reg-ex search (case insensitive way) for the whole Drupal core code-base.
Comment #8
angel.hI'll get right on it. Thanks @ndobromirov.
Comment #9
angel.hPatch done. Intentionally skipped working on strings and limited it to comments only.
Comment #10
ndobromirov commentedHey @angel.h thanks for the great effort on fixing all the things.
The patch is HUGE (~200KB) :D.
Here are some small things that popped during the review.
This is a code example, making it close to a code change, as it's likely that people will copy-paste that.
It might be one of the false-positives from the search...
Are this double slashes correct overall?
This is a file path, so either revert back or check that it's a class and drop the .php extension it ends with.
Comment #11
ivan berezhnov commentedComment #13
wengerkRe-rolled for 8.6.x (commit
7c1de1efa1) & apply suggestions of #10Comment #14
wengerkComment #16
wengerkIt fails because of deprecation usage, what should we do ?
Comment #17
wengerkDuring my previous re-roll in #13, I made a mistake during renaming with
Drupal\Tests->DrupalTestsmy bad.I also found couple of missing \Drupal.
Checkout the interdiff for more infos.
Comment #18
wengerkComment #19
idebr commentedThe contents of the patch does not match the issue description.
Comment #23
jhedstromThis was improperly under the responsive_image queue. It also may be a duplicate of an existing issue, but I couldn't find one.
Comment #25
daffie commentedThe patch is failing the testbot and properly needs a reroll for 9.1.
Comment #26
ridhimaabrol24 commentedComment #27
ridhimaabrol24 commentedRerolled patch for 9.1
Comment #29
atul4drupal commentedComment #30
ridhimaabrol24 commented@atul4drupal I was working on it. Fixing failed test case
Comment #31
atul4drupal commentedRegarding #30: Thanks for working on this.
Its a long file to review, here are few findings:
1) #10.2 is still not addressed
2) +++ b/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php
- $this->assertStringContainsString('The class Drupal\Tests\Scripts\TestSiteApplicationTest contained in', $process->getErrorOutput());
+ $this->assertStringContainsString('The class \Drupal\Tests\Scripts\TestSiteApplicationTest contained in', $process->getErrorOutput());
this appears to be a scope creep and unnecessary change.
Comment #32
ridhimaabrol24 commentedComment #33
ridhimaabrol24 commentedFixing suggestions in 10.2
Comment #34
atul4drupal commented#33 thanks for the patch.
Adding the interdiff to help trace the differrence/change from #30, you mistakenly seems to have added a blank interdiff.
Comment #35
atul4drupal commented#33 : looks good for the fix however 31.2 is more of a code change and got introduced since #13, this certainly is not in scope of this and must be left unchanged unless we have a PHPCS rule in place for usage of \Drupal
There are several open/postponed issues with respect to inconsistent usage of '\' across the application, for reference adding https://www.drupal.org/project/drupal/issues/3123593#comment-13531928
https://www.drupal.org/project/drupal/issues/3082854#comment-13658012
Comment #36
atul4drupal commentedComment #37
codersukanta commentedComment #38
codersukanta commentedUpdating the patch based on #31.2.
Comment #39
atul4drupal commented#38 looks good and addresses the issue.
Its RTBC +1
Will wait for clarity on the PHPCS rule for "\Drupal" as also mentioned in #35, before moving this ticket any further.
Comment #41
quietone commentedChanged the parent to a Meta covering all issues about the leading \ in class names.
As, atul4drupal points out this is postponed on the sniff.
Comment #42
quietone commented