I like to keep my codebase nice and neat.

However; when I run 'drush fu [feature name]' or click the 'Generate Feature' button in the UI I occasionally end up with 'crufty' leftover files. Particularly when removing entire Components from an existing feature.

Steps to reproduce;

1. Create a feature called 'sites/all/modules/features/crufty' and include say a content type and some 'Permissions'.
2. Re-create the feature but remove the Permissions, so that only the content type remains. Overwrite the existing feature using the UI by clicking the 'Generate feature' button, being sure that the path is once again 'sites/all/modules/features/crufty'.
3. Observe that the feature is re-created successfully, but that a file named 'crufty.permissions.inc' remains in the folder.

The patch here seeks to address this by parsing all the files remaining in the folder and validating that they are all in fact required by the feature you just updated.

CommentFileSizeAuthor
#1 features-remove-cruft-2544920-1.patch848 bytessamtny
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

samtny’s picture

hefox’s picture

Title: Features should warn about unneeded files » Add warning about unneeded files
Category: Bug report » Feature request
samtny’s picture

Status: Active » Needs review
hefox’s picture

Status: Needs review » Needs work

Looking at patch quickly, off top of head -- people can add whatever files they want to a feature, so this can be lot of false positives that might result in people removing files they do need.

samtny’s picture

Is it a common pattern to 'add whatever files they want to a feature'?

My impression was that Features are made up of exportables only, all of which would be accounted for by the patch in #1 (more-or-less).

If someone can point me to a documented use-case of 'whatever files' added to a Feature then I can withdraw this Feature request.

donquixote’s picture

My impression was that Features are made up of exportables only, all of which would be accounted for by the patch in #1 (more-or-less).

I have been part of multiple teams where this was/is a common practice.
It is a case we must support.

If we were to do this, we would need a way to better distinguish files owned by features from files created by a user.
And once we have this, we can as well delete the files directly instead of leaving this to a site builder or site developer.
Expecting a developer to clean up manually does not scale.

So I would propose to close this as wontfix and continue here:
#1896528: generate features doesn't delete existing files