Merge remote-tracking branch 'upstream/master'

This commit is contained in:
a.cianfarani 2013-08-23 16:06:59 +02:00
commit f28ba71be5
6 changed files with 102 additions and 27 deletions

View file

@ -36,7 +36,7 @@ class Composer implements \PHPCI\Plugin
*/
public function execute()
{
$cmd = PHPCI_DIR . 'composer.phar '. ($this->preferDist ? '--prefer-dist' : null) .' --working-dir="%s" %s';
$cmd = PHPCI_DIR . 'composer.phar --no-ansi --no-interaction '. ($this->preferDist ? '--prefer-dist' : null) .' --working-dir="%s" %s';
return $this->phpci->executeCommand($cmd, $this->directory, $this->action);
}
}

View file

@ -66,18 +66,23 @@ class Pdepend implements \PHPCI\Plugin
throw new \Exception(sprintf('The location %s is not writable.', $this->location));
}
$cmd = PHPCI_BIN_DIR . 'pdepend --summary-xml=%s --jdepend-chart=%s --overview-pyramid=%s "%s"';
$cmd = PHPCI_BIN_DIR . 'pdepend --summary-xml="%s" --jdepend-chart="%s" --overview-pyramid="%s" %s "%s"';
//Remove the created files first
unlink($this->location . DIRECTORY_SEPARATOR . $this->summary);
unlink($this->location . DIRECTORY_SEPARATOR . $this->chart);
unlink($this->location . DIRECTORY_SEPARATOR . $this->pyramid);
$this->removeBuildArtifacts();
// If we need to ignore directories
if (count($this->phpci->ignore)) {
$ignore = ' --ignore=' . implode(',', $this->phpci->ignore);
} else {
$ignore = '';
}
$success = $this->phpci->executeCommand(
$cmd,
$this->location . DIRECTORY_SEPARATOR . $this->summary,
$this->location . DIRECTORY_SEPARATOR . $this->chart,
$this->location . DIRECTORY_SEPARATOR . $this->pyramid,
$ignore,
$this->directory
);
@ -101,4 +106,17 @@ class Pdepend implements \PHPCI\Plugin
return $success;
}
}
/**
* Remove files created from previous builds
*/
protected function removeBuildArtifacts()
{
//Remove the created files first
foreach (array($this->summary, $this->chart, $this->pyramid) as $file) {
if (file_exists($this->location . DIRECTORY_SEPARATOR . $file)) {
unlink($this->location . DIRECTORY_SEPARATOR . $file);
}
}
}
}

View file

@ -17,13 +17,44 @@ namespace PHPCI\Plugin;
*/
class PhpCodeSniffer implements \PHPCI\Plugin
{
protected $directory;
protected $args;
/**
* @var \PHPCI\Builder
*/
protected $phpci;
/**
* @var array
*/
protected $suffixes;
/**
* @var string
*/
protected $directory;
/**
* @var string
*/
protected $standard;
/**
* @var string
*/
protected $tab_width;
/**
* @var string
*/
protected $encoding;
/**
* @param \PHPCI\Builder $phpci
* @param array $options
*/
public function __construct(\PHPCI\Builder $phpci, array $options = array())
{
$this->phpci = $phpci;
$this->suffixes = isset($options['suffixes']) ? (array)$options['suffixes'] : array('php');
$this->directory = isset($options['directory']) ? $options['directory'] : $phpci->buildPath;
$this->standard = isset($options['standard']) ? $options['standard'] : 'PSR2';
$this->tab_width = isset($options['tab_width']) ? $options['tab_width'] : '';
@ -36,32 +67,32 @@ class PhpCodeSniffer implements \PHPCI\Plugin
public function execute()
{
$ignore = '';
if (count($this->phpci->ignore)) {
$ignore = ' --ignore=' . implode(',', $this->phpci->ignore);
}
$standard = '';
if (strpos($this->standard, '/') !== false) {
$standard = ' --standard='.$this->directory.$this->standard;
} else {
$standard = ' --standard='.$this->standard;
}
$tab_width = '';
$suffixes = '';
if (count($this->suffixes)) {
$suffixes = ' --extensions=' . implode(',', $this->suffixes);
}
$tab_width = '';
if (strlen($this->tab_width)) {
$tab_width = ' --tab-width='.$this->tab_width;
}
$encoding = '';
if (strlen($this->encoding)) {
$encoding = ' --encoding='.$this->encoding;
}
$cmd = PHPCI_BIN_DIR . 'phpcs %s %s %s %s "%s"';
return $this->phpci->executeCommand($cmd, $standard, $ignore, $tab_width, $encoding, $this->phpci->buildPath);
$cmd = PHPCI_BIN_DIR . 'phpcs %s %s %s %s %s "%s"';
return $this->phpci->executeCommand($cmd, $standard, $suffixes, $ignore, $tab_width, $encoding, $this->phpci->buildPath);
}
}

View file

@ -17,31 +17,57 @@ namespace PHPCI\Plugin;
*/
class PhpMessDetector implements \PHPCI\Plugin
{
protected $directory;
/**
* Array of PHPMD rules. Possible values: codesize, unusedcode, naming, design, controversial
* @var \PHPCI\Builder
*/
protected $phpci;
/**
* @var array
*/
protected $suffixes;
/**
* Array of PHPMD rules. Can be one of the builtins (codesize, unusedcode, naming, design, controversial)
* or a filenname (detected by checking for a / in it), either absolute or relative to the project root.
* @var array
*/
protected $rules;
/**
* @param \PHPCI\Builder $phpci
* @param array $options
*/
public function __construct(\PHPCI\Builder $phpci, array $options = array())
{
$this->phpci = $phpci;
$this->rules = isset($options['rules']) ? (array)$options['rules'] : array('codesize', 'unusedcode', 'naming');
$this->phpci = $phpci;
$this->suffixes = isset($options['suffixes']) ? (array)$options['suffixes'] : array('php');
$this->rules = isset($options['rules']) ? (array)$options['rules'] : array('codesize', 'unusedcode', 'naming');
foreach ($this->rules as &$rule) {
if ($rule[0] !== '/' && strpos($rule, '/') !== FALSE) {
$rule = $this->phpci->buildPath . $rule;
}
}
}
/**
* Runs PHP Mess Detector in a specified directory.
*/
* Runs PHP Mess Detector in a specified directory.
*/
public function execute()
{
$ignore = '';
if (count($this->phpci->ignore)) {
$ignore = ' --exclude ' . implode(',', $this->phpci->ignore);
}
$cmd = PHPCI_BIN_DIR . 'phpmd "%s" text %s %s';
return $this->phpci->executeCommand($cmd, $this->phpci->buildPath, implode(',', $this->rules), $ignore);
$suffixes = '';
if (count($this->suffixes)) {
$suffixes = ' --suffixes ' . implode(',', $this->suffixes);
}
$cmd = PHPCI_BIN_DIR . 'phpmd "%s" text %s %s %s';
return $this->phpci->executeCommand($cmd, $this->phpci->buildPath, implode(',', $this->rules), $ignore, $suffixes);
}
}

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="<?= PHPCI_URL ?>assets/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script src="//code.jquery.com/jquery-1.8.1.min.js"></script>
<script src="<?= PHPCI_URL ?>assets/js/bootstrap.min.js"></script>
<style type="text/css">

View file

@ -6,7 +6,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900,300italic' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900,300italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="<?= PHPCI_URL ?>assets/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<?= PHPCI_URL ?>assets/css/phpci.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>