PHPCS/PHPMD fixes for Technical Debt plugin.

This commit is contained in:
James Inman 2015-02-18 14:26:21 +00:00
commit 58620d9384

View file

@ -122,21 +122,42 @@ class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
}
/**
* Runs in a specified directory, to a specified standard.
* Runs the plugin
*/
public function execute()
{
$this->phpci->logExecOutput(false);
$ignores = $this->ignore;
$ignores[] = 'phpci.yml';
list($errorCount, $data) = $this->getErrorList();
$this->phpci->log("Found $errorCount instances of " . implode(', ', $this->searches));
$this->build->storeMeta('technical_debt-warnings', $errorCount);
$this->build->storeMeta('technical_debt-data', $data);
if ($this->allowed_errors != -1 && $errorCount > $this->allowed_errors) {
$success = false;
}
return $success;
}
/**
* Gets the number and list of errors returned from the search
*
* @return array
*/
public function getErrorList()
{
$dirIterator = new \RecursiveDirectoryIterator($this->directory);
$iterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::SELF_FIRST);
$files = [];
$ignores = $this->ignore;
$ignores[] = 'phpci.yml';
foreach ($iterator as $file) {
$filePath = $file->getRealPath();
$filePath = $file->getRealPath();
$skipFile = false;
foreach ($ignores as $ignore) {
if (stripos($filePath, $ignore) !== false) {
@ -180,16 +201,5 @@ class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
}
}
}
$this->phpci->log("Found $errorCount instances of " . implode(', ', $this->searches));
$this->build->storeMeta('technical_debt-warnings', $errorCount);
$this->build->storeMeta('technical_debt-data', $data);
if ($this->allowed_errors != -1 && $errorCount > $this->allowed_errors) {
$success = false;
}
return $success;
}
}