diff --git a/PHPCI/Plugin/Lint.php b/PHPCI/Plugin/Lint.php index 90436d70..9322bb7b 100644 --- a/PHPCI/Plugin/Lint.php +++ b/PHPCI/Plugin/Lint.php @@ -26,6 +26,7 @@ class Lint implements PHPCI\Plugin protected $ignore; protected $phpci; protected $build; + protected $failedPaths = array(); /** * Standard Constructor @@ -69,6 +70,8 @@ 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; @@ -77,6 +80,11 @@ class Lint implements PHPCI\Plugin $this->phpci->quiet = false; + $this->phpci->logExecOutput(true); + + $this->build->storeMeta('phplint-warnings', count($this->failedPaths)); + $this->build->storeMeta('phplint-data', $this->failedPaths); + return $success; } @@ -140,8 +148,16 @@ 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 . ' -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); + + $this->failedPaths[] = array( + 'file' => $path, + 'line' => trim($matches[2]), + 'message' => trim($matches[1]) + ); + $success = false; } diff --git a/public/assets/js/build-plugins/lint.js b/public/assets/js/build-plugins/lint.js new file mode 100644 index 00000000..b7fd11b4 --- /dev/null +++ b/public/assets/js/build-plugins/lint.js @@ -0,0 +1,78 @@ +var lintPlugin = ActiveBuild.UiPlugin.extend({ + id: 'build-lint-warnings', + css: 'col-lg-12 col-md-12 col-sm-12 col-xs-12', + title: 'PHP Lint', + lastData: null, + displayOnUpdate: false, + box: true, + rendered: false, + + register: function() { + var self = this; + var query = ActiveBuild.registerQuery('phplint-data', -1, {key: 'phplint-data'}) + + $(window).on('phplint-data', function(data) { + self.onUpdate(data); + }); + + $(window).on('build-updated', function() { + if (!self.rendered) { + self.displayOnUpdate = true; + query(); + } + }); + }, + + render: function() { + + return $('
File | ' + + 'Line | ' + + 'Message | ' + + '
---|