Problem/Motivation
In #3106216: Remove unused variables from core we introduced the sniff DrupalPractice.CodeAnalysis.VariableAnalysis
to detect unused variables in Drupal Core.
To narrow the scope the decision was made to exclude all the test-classes.
This issue is created to make that sniff run without errors on all test-classes.
Steps to reproduce
Proposed resolution
- Remove the line <exclude-pattern>*/tests/*</exclude-pattern>
from sniff DrupalPractice.CodeAnalysis.VariableAnalysis
in core/phpcs.xml.dist
- Fix all and any errors
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#20 | 3251754-20-9.4.x.patch | 104.67 KB | longwave |
#20 | 3251754-20-10.0.x.patch | 96.31 KB | longwave |
Issue fork drupal-3251754
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
SpokjePostponed on #3106216: Remove unused variables from core
Comment #3
longwaveThe parent issue is committed so this can be worked on now.
Comment #4
SpokjeComment #6
SpokjeThanks @tstoeckler for the On-The-Fly review :)
Comment #7
SpokjeComment #8
longwaveA few more comments, mostly things that look like they can be removed entirely now.
Comment #9
tstoecklerNo problem, and thanks for the fixes, looking pretty close now 👍
Comment #10
SpokjeComment #11
daffie CreditAttribution: daffie commentedThe MR looks good.
Comment #12
SpokjeThanks @longwave and @daffie for their eagled-eyed reviews.
Comment #13
SpokjeComment #14
daffie CreditAttribution: daffie commentedAll the code changes look good to me.
The file core/phpcs.xml.dist has the exclude-pattern removed.
The testbot is happy.
For me it is RTBC.
Comment #15
longwaveRTBC +1
Comment #16
alexpottThis needs to go on 10.0.x first.
Comment #17
SpokjeOk...
What's the reasoning behind that, and would that reasoning apply to all RTBC-ed Coding standards issues?
Comment #18
alexpott@Spokje everything has to go into 10.x first because otherwise there is a future Drupal without this fixed. And yes it applies to all coding standards patches currently rtbc.
Comment #19
SpokjeThanks for clearing that up.
I'm sure somebody else would love to keep RTBCed coding standards up to date with the ever moving core releases for months, I've done so for a few issues that were RTBC for 2 months and longer. I'm not keen on doing that again for 2+ months for the D10 version and then the needs-a-backport D9.4.x version.
If those changes are too big, too disruptive, no fun to look through, fine with me, but then there should be a ruling about how big/how many changes a MR/patch can have as a maximum, because this seems now like a lot of time that would be more usefully spend elsewhere.
_drops EUR 0.02 and all Coding standards issue_
Comment #20
longwaveReuploading patch for 9.4.x, rerolled for 10.0.x.
Comment #21
longwaveNW following #3174402: Fix unused variable $unpublished in TrackerTest.php
Also not sure why PHPStan is failing on AssertHelperTraitTest, maybe a symptom of #3259355: Always do a full phpstan analysis on DrupalCI?
Comment #22
mallezieTesting if phpstan causes the problem here.
Comment #23
malleziePHPstan gives same result on both partial and full scan.
In our phpstan config we have
excludePaths:
# Skip test fixtures.
- */tests/fixtures/*.php
This skips the AssertHelperTestClass class.
Comment #24
mallezieComment #25
mondrakeAssertHelperTraitTest and the fixture will anyway be removed with #3261266: Remove deprecated code from the testing framework (base classes, listeners, etc), so we may want to postpone this on that
Comment #26
alexpottThis is no longer unused.
Comment #30
quietone CreditAttribution: quietone at PreviousNext commentedClosed #3338899: Remove unused variables [$resource,$key] from ResourceTest as a duplicate, adding credit.
Adding parent.
Comment #31
quietone CreditAttribution: quietone at PreviousNext commentedDiscussed this longwave and they suggested a different parent. I am changing the parent now. I will add a comment to the previous parent since this is using a sniff.
Comment #32
quietone CreditAttribution: quietone at PreviousNext commentedChange parent to the meta implementing this sniff.