$includeDir = "@php_dir@" == "@" . "php_dir@" ? dirname(__FILE__) . "/.." : "@php_dir@/XRef"; require_once "{$includeDir}/XRef.class.php"; try { list($options, $arguments) = XRef::getCmdOptions(); } catch (Exception $e) { error_log($e->getMessage()); error_log("See 'xref-ci --help'"); exit(1); } if (XRef::needHelp() || count($arguments)) { XRef::showHelpScreen("xref-ci - continuous integration server"); exit(1); } $incremental = XRef::getConfigValue("ci.incremental", false); $xref = new XRef(); $xref->loadPluginGroup("lint"); $scm = $xref->getSourceCodeManager(); $storage = $xref->getStorageManager(); $exclude_paths = XRef::getConfigValue("project.exclude-path", array()); // // Normal run: // Find modified files from the last run and find new errors in these files // if (!$storage->getLock("ci")) { error_log("Can't obtain lock - already running?"); exit(0); } $db = $storage->restoreData("ci", "database"); if (!$db) { // initialize the database $db = array();
public function __construct() { $xref = new XRef(); $xref->loadPluginGroup('lint'); $this->xref = $xref; }
// command-line arguments try { list($options, $arguments) = XRef::getCmdOptions(); } catch (Exception $e) { error_log($e->getMessage()); error_log("See 'xref-doc --help'"); exit(1); } //help if (XRef::needHelp() || count($arguments)) { XRef::showHelpScreen("xref-doc - tool to create cross-reference source code reports"); exit(1); } $xref = new XRef(); $xref->setOutputDir(XRef::getConfigValue("doc.output-dir")); $xref->loadPluginGroup("doc"); $plugins = $xref->getPlugins("XRef_IDocumentationPlugin"); $path = XRef::getConfigValue("project.source-code-dir"); $file_provider = new XRef_FileProvider_FileSystem($path); $exclude_paths = XRef::getConfigValue("project.exclude-path", array()); $file_provider->excludePaths($exclude_paths); $numberOfFiles = 0; $numberOfCodeLines = 0; // 1. Call each plugin once for each input file $files = $xref->filterFiles($file_provider->getFiles()); foreach ($files as $filename) { try { $file_content = $file_provider->getFileContent($filename); $pf = $xref->getParsedFile($filename, $file_content); foreach ($plugins as $pluginId => $plugin) { $plugin->generateFileReport($pf);
protected static function showErrors() { // map: error code => array("message" => message, "severity" => severity) $errors = array(XRef::ERROR_CODE_CANT_PARSE_FILE => array("message" => XRef::ERROR_MESSAGE_CANT_PARSE_FILE, "severity" => XRef::FATAL)); $xref = new XRef(); $xref->loadPluginGroup('lint'); foreach ($xref->getPlugins('XRef_ILintPlugin') as $plugin) { $map = $plugin->getErrorMap(); $errors = array_merge($errors, $map); } foreach ($xref->getPlugins('XRef_IProjectLintPlugin') as $plugin) { $map = $plugin->getErrorMap(); $errors = array_merge($errors, $map); } ksort($errors); $format = "%-6s %-10s %s\n"; $spacer = sprintf($format, str_repeat('-', 6), str_repeat('-', 10), str_repeat('-', 50)); printf($format, "Code", "Severity", "Message"); echo $spacer; foreach ($errors as $code => $details) { printf($format, $code, XRef::$severityNames[$details["severity"]], $details["message"]); } echo $spacer; }