Merge 6fc34a0aa5
into 943c8124ac
This commit is contained in:
commit
5183162bde
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
78
public/assets/js/build-plugins/lint.js
Normal file
78
public/assets/js/build-plugins/lint.js
Normal file
|
@ -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 $('<table class="table table-striped" id="phplint-data">' +
|
||||
'<thead>' +
|
||||
'<tr>' +
|
||||
' <th>File</th>' +
|
||||
' <th>Line</th>' +
|
||||
' <th>Message</th>' +
|
||||
'</tr>' +
|
||||
'</thead><tbody></tbody></table>');
|
||||
},
|
||||
|
||||
onUpdate: function(e) {
|
||||
if (!e.queryData) {
|
||||
$('#build-lint-warnings').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
this.rendered = true;
|
||||
this.lastData = e.queryData;
|
||||
|
||||
var errors = this.lastData[0].meta_value;
|
||||
var tbody = $('#phplint-data tbody');
|
||||
tbody.empty();
|
||||
|
||||
if (errors.length == 0) {
|
||||
$('#build-lint-warnings').hide();
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i in errors) {
|
||||
var file = errors[i].file;
|
||||
|
||||
if (ActiveBuild.fileLinkTemplate) {
|
||||
var fileLink = ActiveBuild.fileLinkTemplate.replace('{FILE}', file);
|
||||
fileLink = fileLink.replace('{LINE}', errors[i].line);
|
||||
|
||||
file = '<a target="_blank" href="'+fileLink+'">' + file + '</a>';
|
||||
}
|
||||
|
||||
var row = $('<tr>' +
|
||||
'<td>'+file+'</td>' +
|
||||
'<td>'+errors[i].line+'</td>' +
|
||||
'<td>'+errors[i].message+'</td></tr>');
|
||||
|
||||
tbody.append(row);
|
||||
}
|
||||
|
||||
$('#build-lint-warnings').show();
|
||||
}
|
||||
});
|
||||
|
||||
ActiveBuild.registerPlugin(new lintPlugin());
|
Loading…
Reference in a new issue