Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AuditCommand.php

function AuditCommand::execute

Overrides Command::execute

File

vendor/composer/composer/src/Composer/Command/AuditCommand.php, line 51

Class

AuditCommand

Namespace

Composer\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) : int {
    $composer = $this->requireComposer();
    $packages = $this->getPackages($composer, $input);
    if (count($packages) === 0) {
        $this->getIO()
            ->writeError('No packages - skipping audit.');
        return 0;
    }
    $auditor = new Auditor();
    $repoSet = new RepositorySet();
    foreach ($composer->getRepositoryManager()
        ->getRepositories() as $repo) {
        $repoSet->addRepository($repo);
    }
    $auditConfig = $composer->getConfig()
        ->get('audit');
    $abandoned = $input->getOption('abandoned');
    if ($abandoned !== null && !in_array($abandoned, Auditor::ABANDONEDS, true)) {
        throw new \InvalidArgumentException('--audit must be one of ' . implode(', ', Auditor::ABANDONEDS) . '.');
    }
    $abandoned = $abandoned ?? $auditConfig['abandoned'] ?? Auditor::ABANDONED_FAIL;
    $ignoreSeverities = $input->getOption('ignore-severity') ?? [];
    return min(255, $auditor->audit($this->getIO(), $repoSet, $packages, $this->getAuditFormat($input, 'format'), false, $auditConfig['ignore'] ?? [], $abandoned, $ignoreSeverities));
}
RSS feed
Powered by Drupal