Closed (fixed)
Project:
Drupal core
Version:
main
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
25 Mar 2026 at 13:12 UTC
Updated:
13 Apr 2026 at 09:00 UTC
Jump to comment: Most recent
Discovered in #3581155: Investigate if shipmonk/dead-code-detector would be useful to us we have a number of unused property definitions throughout core. This issue deals with kernel tests.
Remove the unused properties.
Check why and when these properties were added in the first place.
Confirm that no test coverage has been unintentionally lost.
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 #3
longwaveComment #5
longwaveComment #6
borisson_I used phpstorm's find usage on these properties and they are not used according to that either. In this case there are a few that are only written to, but they are not being read, so this is also fine imo
So this looks good to me, I also agree with scoping these issues like this.
Comment #7
catchI think we're missing:
from the issue summary.
Comment #8
smustgrave commentedIf each one needs to have it's git history that's a pretty large search should this be broken up?
Comment #9
catchI think it's OK in this issue. For most I would guess they haven't been changed since they were added, so it'll just be git blame then checking the commit. If they were added in the first commit and where never used even then, then it's safe to assume it's cruft from the original MR that wasn't spotted at the time, that may or may not have been used in previous iterations of the MR/patch before it was committed.
If they were used in the original MR but the coverage using them was removed since, then it's a bit more digging.
Comment #10
smustgrave commentedBut still 48 files of checking git history
Comment #11
smustgrave commentedcore/modules/big_pipe/tests/src/Kernel/BigPipeInterfacePreviewThemeSuggestionsTest.php was added originally in #2632750 and checking that ticket that variable was never set.
core/modules/block_content/tests/src/Kernel/BlockContentDeriverTest.php was added originally in #3340159. baseDefinition was never called and blockContentStorage/blockContentDerivative were set but never called.
core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php was added originally in #3245967 and that variable was just never called.
core/modules/content_moderation/tests/src/Kernel/ContentModerationResaveTest.php was added originally in #3181439 and that state variable was set but then never called.
core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php was added originally in #2830740 and those variables were never called or in the one case set and never called.
Every single one I checked were from the original issue and not updated since. So believe it's safe to say that removing these properties is fine. If I had to guess when these tests were made they were copied from an existing test but can't prove that. Maybe if any of these tests get expanded they can add the properties back if they need them.
Hope that works vs checking all 48 haha.
Comment #12
longwaveI think this is fine. The only one that jumped out was TestConfigurableContextAwarePlugin given that's an entire unused test class but even that was added in #2273381: Convert ContextAwarePluginBase to traits and then the test coverage was removed correctly in #3153956: Remove code related to "context from configuration" that was deprecated in Drupal 9 but the setup was not removed at the same time.
Comment #13
catchYeah I think spot checks are great here. If we have a habit of accidentally adding unnecessary boilerplate when tests are committed, or leaving some when we remove other bits of the test on purpose, then we know that's because:
1. People iterate on tests when they're working on the patch and it's easy for cruft to creep in
2. Almost no-one (definitely not me) reviews test additions as closely as test refactors or other code additions/changes.
But if we were somehow adding new unused boilerplate when tests are getting changed, it would be a bit weird.
Committed/pushed to main and 11.x, thanks!