You are here

public function SiteAuditCheckExtensionsUnused::calculateScore in Unused Modules 8

Same name and namespace in other branches
  1. 7 unused_modules.site_audit.inc \SiteAuditCheckExtensionsUnused::calculateScore()

Implements \SiteAudit\Check\Abstract\calculateScore().

Overrides SiteAuditCheckAbstract::calculateScore

File

./unused_modules.site_audit.inc, line 80
Contains \SiteAudit\Check\Extensions\Unused.

Class

SiteAuditCheckExtensionsUnused
@file Contains \SiteAudit\Check\Extensions\Unused.

Code

public function calculateScore() {
  $this->registry['unused_projects'] = [];
  $extensions = _unused_modules_get_modules_by_project();
  foreach ($extensions as $extension_data) {
    if (!$extension_data->project_has_enabled_modules) {
      $whitelisted_extensions = [
        // Intentional stub.
        'views_export',
      ];
      $whitelisted_paths = [
        // Sample.
        'sites/all/modules/coder/coder_upgrade/tests/new/samples',
      ];
      if (!in_array($extension_data->project, $whitelisted_extensions) && !in_array($extension_data->module_path, $whitelisted_paths)) {
        $this->registry['unused_projects'][$extension_data->project] = $extension_data->project_path;
      }
    }
  }
  if (!empty($this->registry['unused_projects'])) {
    ksort($this->registry['unused_projects']);
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
}