/** * Generates a short list with number of files, warnings and errors. * * @return string HTML string */ public function getTestResults(Xinc_Build_Interface $build) { $numberOfFiles = $build->getStatistics()->get('checkstyle.numberOfFiles'); if (null !== $numberOfFiles) { $numberOfWarnings = $build->getStatistics()->get('checkstyle.numberOfWarnings'); $numberOfErrors = $build->getStatistics()->get('checkstyle.numberOfErrors'); $content = $this->box('info', 'Number of files: ' . $numberOfFiles); if ($numberOfWarnings > 0) { $content .= $this->box('warning', 'Warnings: ' . $numberOfWarnings); } if ($numberOfErrors > 0) { $content .= $this->box('error', 'Errors: ' . $numberOfErrors); } return $content; } else { return false; } }
/** * Generates statistsics and saves them into the build. * * @param Xinc_Build_Interface $build The actuall build. * @param string $sourceFile The xml file to read stats from. * * @return boolean True if registering was ok, false if it failed. */ public function generateStats(Xinc_Build_Interface $build, $file) { try { /** * @var string Contains content of the XML file */ $strContent = file_get_contents($file); if ('' !== $strContent) { $arStats = $this->parseXml($strContent); /** * set the statistics data */ foreach ($arStats as $strName => $mValue) { $build->getStatistics()->set('checkstyle.' . $strName, $mValue); } } } catch (Exception $e) { Xinc_Logger::getInstance()->error('Could not parse checkstyle xml: ' . $e->getMessage() . "\n" . 'Trace: ' . $e->getTraceAsString()); return false; } return true; }