One of the main reasons to use Drupal is to minimize how much custom code needs to be maintained for a website. Every unique problem can be decomposed into the same problems that everyone has. These problems should be solved by modules on drupal.org.
This module calculates how many lines of code (LoC) of private innovation there is in a Drupal site.
Full report is available at Reports => Private Innovation. Total custom LoC is on status page.
drush pi will output a summary.