There is a gem puppet-ghostbuster Show archive.org snapshot which can help you find dead code in puppet projects.
To use it, (as of now) it's best to get the latest version from git, as the last release is not yet on rubygems.org.
# Gemfile
gem 'puppet-ghostbuster', git: 'https://github.com/voxpupuli/puppet-ghostbuster.git', ref: 'XXXXX'
After that you can use puppet-lint
to find dead code in your project:
# You probably need to set some ENV Variables, see https://github.com/voxpupuli/puppet-ghostbuster#environment-variables
export HIERA_YAML_PATH="/home/bob/code/puppet/hiera.yaml"
export PUPPETDB_URL="http://localhost:9000"
find . -type f -exec puppet-lint --only-checks ghostbuster_classes,ghostbuster_defines,ghostbuster_files,ghostbuster_hiera_files,ghostbuster_templates {} \+
Keep in mind, there will be a lot of "dead code" e.g. in modules from puppet forge which is ok as it's part of a module you don't use.