public function UpgradeStatusCommands::checkstyle in Upgrade Status 8.3
Same name and namespace in other branches
- 8.2 src/Commands/UpgradeStatusCommands.php \Drupal\upgrade_status\Commands\UpgradeStatusCommands::checkstyle()
Analyze projects output as XML.
@command upgrade_status:checkstyle @option all Analyze all projects. @option skip-existing Return results from a previous scan of a project if available, otherwise start a new one. @option ignore-uninstalled Ignore uninstalled projects. @option ignore-contrib Ignore contributed projects. @option ignore-custom Ignore custom projects. @aliases us-cs
Parameters
array $projects: List of projects to analyze.
array $options: Additional options for the command.
Throws
\InvalidArgumentException Thrown when one of the passed arguments is invalid or no arguments were provided.
File
- src/
Commands/ UpgradeStatusCommands.php, line 88
Class
- UpgradeStatusCommands
- Upgrade Status Drush command
Namespace
Drupal\upgrade_status\CommandsCode
public function checkstyle(array $projects, array $options = [
'all' => FALSE,
'skip-existing' => FALSE,
'ignore-uninstalled' => FALSE,
'ignore-contrib' => FALSE,
'ignore-custom' => FALSE,
]) {
$extensions = $this
->doAnalyze($projects, $options);
$xml = new \SimpleXMLElement("<?xml version='1.0'?><checkstyle/>");
foreach ($extensions as $type => $list) {
foreach ($list as $name => $extension) {
$result = $this->resultFormatter
->getRawResult($extension);
if (is_null($result)) {
$this
->logger()
->error('Project scan @name failed.', [
'@name' => $name,
]);
continue;
}
foreach ($result['data']['files'] as $filepath => $errors) {
$short_path = str_replace(DRUPAL_ROOT . '/', '', $filepath);
$file_xml = $xml
->addChild('file');
$file_xml
->addAttribute('name', $short_path);
foreach ($errors['messages'] as $error) {
$severity = 'error';
if ($error['upgrade_status_category'] == 'ignore') {
$severity = 'info';
}
elseif ($error['upgrade_status_category'] == 'later') {
$severity = 'warning';
}
$error_xml = $file_xml
->addChild('error');
$error_xml
->addAttribute('line', $error['line']);
$error_xml
->addAttribute('message', $error['message']);
$error_xml
->addAttribute('severity', $severity);
}
}
}
}
$this
->output()
->writeln($xml
->asXML());
}