protected function execute(InputInterface $input, OutputInterface $output)
{
$api = $this->getApplication()->getApi();
$analysis = $api->getProject($input->getArgument('project-uuid'))->getLastAnalysis();
if (!$analysis) {
$output->writeln('<error>There are no analyses</error>');
return 1;
}
$helper = new DescriptorHelper($api->getSerializer());
$helper->describe($output, $analysis, $input->getOption('format'), $input->getOption('show-ignored-violations'));
if ('txt' === $input->getOption('format') && OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) {
$output->writeln('');
$output->writeln('Re-run this command with <comment>-v</comment> option to get the full report');
}
if (!($expr = $input->getOption('fail-condition'))) {
return;
}
$el = new ExpressionLanguage();
$counts = array();
$violations = $analysis->getViolations();
if ($violations) {
foreach ($violations as $violation) {
if (!isset($counts[$violation->getCategory()])) {
$counts[$violation->getCategory()] = 0;
}
++$counts[$violation->getCategory()];
if (!isset($counts[$violation->getSeverity()])) {
$counts[$violation->getSeverity()] = 0;
}
++$counts[$violation->getSeverity()];
}
}
$vars = array('analysis' => $analysis, 'counts' => (object) $counts);
if ($el->evaluate($expr, $vars)) {
return 70;
}
}