Merge pull request #209 from elkangaroo/phplint-upstream-update
Update PHP Parallel Lint plugin to reflect upstream changes
This commit is contained in:
commit
8d28273c0c
2 changed files with 71 additions and 10 deletions
|
|
@ -20,15 +20,40 @@ use PHPCI\Model\Build;
|
|||
*/
|
||||
class PhpParallelLint implements \PHPCI\Plugin
|
||||
{
|
||||
protected $directory;
|
||||
protected $preferDist;
|
||||
/**
|
||||
* @var \PHPCI\Builder
|
||||
*/
|
||||
protected $phpci;
|
||||
|
||||
/**
|
||||
* @var \PHPCI\Model\Build
|
||||
*/
|
||||
protected $build;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $directory;
|
||||
|
||||
/**
|
||||
* @var array - paths to ignore
|
||||
*/
|
||||
protected $ignore;
|
||||
|
||||
public function __construct(Builder $phpci, Build $build, array $options = array())
|
||||
{
|
||||
$path = $phpci->buildPath;
|
||||
$this->phpci = $phpci;
|
||||
$this->directory = isset($options['directory']) ? $path . $options['directory'] : $path;
|
||||
$this->build = $build;
|
||||
$this->directory = $phpci->buildPath;
|
||||
$this->ignore = $this->phpci->ignore;
|
||||
|
||||
if (isset($options['directory'])) {
|
||||
$this->directory = $options['directory'];
|
||||
}
|
||||
|
||||
if (isset($options['ignore'])) {
|
||||
$this->ignore = $options['ignore'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -36,10 +61,39 @@ class PhpParallelLint implements \PHPCI\Plugin
|
|||
*/
|
||||
public function execute()
|
||||
{
|
||||
// build the parallel lint command
|
||||
$cmd = "run %s";
|
||||
list($ignore) = $this->getFlags();
|
||||
|
||||
// and execute it
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . $cmd, $this->directory);
|
||||
$phplint = $this->phpci->findBinary('parallel-lint');
|
||||
|
||||
if (!$phplint) {
|
||||
$this->phpci->logFailure('Could not find parallel-lint.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$cmd = $phplint . ' %s "%s"';
|
||||
$success = $this->phpci->executeCommand(
|
||||
$cmd,
|
||||
$ignore,
|
||||
$this->directory
|
||||
);
|
||||
|
||||
$output = $this->phpci->getLastOutput();
|
||||
|
||||
$matches = array();
|
||||
if (preg_match_all('/Parse error\:/', $output, $matches)) {
|
||||
$this->build->storeMeta('phplint-errors', count($matches[0]));
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
protected function getFlags()
|
||||
{
|
||||
$ignore = '';
|
||||
if (count($this->ignore)) {
|
||||
$ignore = ' --exclude ' . implode(' --exclude ', $this->ignore);
|
||||
}
|
||||
|
||||
return array($ignore);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ var plugin = PHPCI.UiPlugin.extend({
|
|||
var query1 = PHPCI.registerQuery('phpmd-warnings', -1, {num_builds: 10, key: 'phpmd-warnings'})
|
||||
var query2 = PHPCI.registerQuery('phpcs-warnings', -1, {num_builds: 10, key: 'phpcs-warnings'})
|
||||
var query3 = PHPCI.registerQuery('phpcs-errors', -1, {num_builds: 10, key: 'phpcs-errors'})
|
||||
var query4 = PHPCI.registerQuery('phplint-errors', -1, {num_builds: 10, key: 'phplint-errors'})
|
||||
|
||||
$(window).on('phpmd-warnings phpcs-warnings phpcs-errors', function(data) {
|
||||
$(window).on('phpmd-warnings phpcs-warnings phpcs-errors phplint-errors', function(data) {
|
||||
self.onUpdate(data);
|
||||
});
|
||||
|
||||
|
|
@ -22,6 +23,7 @@ var plugin = PHPCI.UiPlugin.extend({
|
|||
query1();
|
||||
query2();
|
||||
query3();
|
||||
query4();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -67,7 +69,12 @@ var plugin = PHPCI.UiPlugin.extend({
|
|||
var keys = self.keys;
|
||||
|
||||
for (var i in keys) {
|
||||
var t = {'phpmd-warnings': 'PHPMD Warnings', 'phpcs-warnings': 'PHPCS Warnings', 'phpcs-errors': 'PHPCS Errors'};
|
||||
var t = {
|
||||
'phpmd-warnings': 'PHPMD Warnings',
|
||||
'phpcs-warnings': 'PHPCS Warnings',
|
||||
'phpcs-errors': 'PHPCS Errors',
|
||||
'phplint-errors': 'PHPLint Errors'
|
||||
};
|
||||
titles.push(t[keys[i]]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue