Updating PHPLint plugin to output to be build log
This commit is contained in:
parent
6eb180ed5f
commit
ea80d49a03
|
@ -432,6 +432,7 @@ PHPCI',
|
|||
// Plugins that generate errors:
|
||||
'php_mess_detector' => 'PHP Mess Detector',
|
||||
'php_code_sniffer' => 'PHP Code Sniffer',
|
||||
'php_lint' => 'PHP Lint',
|
||||
'php_unit' => 'PHP Unit',
|
||||
'php_cpd' => 'PHP Copy/Paste Detector',
|
||||
'php_docblock_checker' => 'PHP Docblock Checker',
|
||||
|
|
|
@ -19,13 +19,14 @@ use PHPCI\Model\Build;
|
|||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class Lint implements PHPCI\Plugin
|
||||
class Lint implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
|
||||
{
|
||||
protected $directories;
|
||||
protected $recursive = true;
|
||||
protected $ignore;
|
||||
protected $phpci;
|
||||
protected $build;
|
||||
protected $errors = 0;
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
|
@ -59,6 +60,22 @@ class Lint implements PHPCI\Plugin
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this plugin can be executed.
|
||||
* @param $stage
|
||||
* @param Builder $builder
|
||||
* @param Build $build
|
||||
* @return bool
|
||||
*/
|
||||
public static function canExecute($stage, Builder $builder, Build $build)
|
||||
{
|
||||
if ($stage == 'test') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes parallel lint
|
||||
*/
|
||||
|
@ -69,14 +86,20 @@ class Lint implements PHPCI\Plugin
|
|||
|
||||
$php = $this->phpci->findBinary('php');
|
||||
|
||||
$this->phpci->logExecOutput(false);
|
||||
|
||||
foreach ($this->directories as $dir) {
|
||||
if (!$this->lintDirectory($php, $dir)) {
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->phpci->logExecOutput(true);
|
||||
|
||||
$this->phpci->quiet = false;
|
||||
|
||||
$this->build->storeMeta('phplint-warnings', $this->errors);
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
@ -140,8 +163,24 @@ class Lint implements PHPCI\Plugin
|
|||
{
|
||||
$success = true;
|
||||
|
||||
if (!$this->phpci->executeCommand($php . ' -l "%s"', $this->phpci->buildPath . $path)) {
|
||||
$this->phpci->logFailure($path);
|
||||
if (!$this->phpci->executeCommand($php . ' -d display_errors=0 -l "%s" 2>&1', $this->phpci->buildPath . $path)) {
|
||||
$output = $this->phpci->getLastOutput();
|
||||
|
||||
preg_match('/Parse error:\s*syntax error,(.+?)\s+in\s+.+?\s*line\s+(\d+)/', $output, $matches);
|
||||
|
||||
$line = trim($matches[2]);
|
||||
|
||||
$this->build->reportError(
|
||||
$this->phpci,
|
||||
'php_lint',
|
||||
trim((string) $matches[1]),
|
||||
PHPCI\Model\BuildError::SEVERITY_HIGH,
|
||||
$path,
|
||||
(int) $line
|
||||
);
|
||||
|
||||
$this->errors++;
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue