Eiffel Unused Classes PreviousNext

When compiling an Eiffel system, we start from the root class, and then follow all classes it depends on recursively. But the Eiffel universe (the set of all classes available in the clusters and libraries specified in the ECF file) may contain many more classes. It is expected for a reusable library to provide more classes than actually used in a given Eiffel system. But after months of coding, of redesign and refactoring, some user-defined classes may not be needed anymore and we don't necessarily want to have to maintain them.

gedoc can be used to get the list of such unused classes, and/or delete them. Alternatively it can copy in a separate directory the classes which are still used.

Getting the list of unused classes

Here is how to get the list of unused classes:

	gedoc --format=unused_classes --no-force --library=foo project.ecf
where project.ecf is the ECF file describing your Eiffel project. The option --no-force indicates that no class will be deleted, only the list of unused classes will be displayed. The option --library is useful when we are only interested in user-defined classes, and not those coming from reusable libraries. In that case, only the classes in the library foo will be potentially marked as unused. All other classes will be considered as used. Library names can contain wildcards such as --library=str* or --library=@(structure|string). And this option can be used several times to specify several library names. The name of a library is defined as follows in its ECF file: <system name="foo" ...>.

Deleting unused classes

To get rid of the unused classes, you need to replace the option --no-force with the option --interactive:

	gedoc --format=unused_classes --interactive --library=foo project.ecf
With this option, gedoc will ask confirmation each time it needs to delete an unused class. Alternatively you can use the option --force:
	gedoc --format=unused_classes --force --library=foo project.ecf
where the unused classes will be deleted without asking.

Copying used classes

Another solution is to copy to a new directory the classes which are still used:

	gedoc --format=unused_classes --library=foo --output=path/to/directory --library-prefix project.ecf
The original class files (used or not) will be kept untouched. However the class files will be copied in a flat directory, without keeping their cluster hierarchy.


Copyright © 2025, Eric Bezault
mailto:ericb@gobosoft.com
https://www.gobosoft.com
Last Updated: 10 December 2025
HomeTocPreviousNext